-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathbuilder_test.rb
More file actions
44 lines (34 loc) · 1.16 KB
/
Copy pathbuilder_test.rb
File metadata and controls
44 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require "test_helper"
require "image_processing/vips"
require "pathname"
describe "ImageProcessing::Builder" do
before do
@portrait = fixture_image("portrait.jpg")
end
it "instruments pipeline execution" do
pipeline = ImageProcessing::Vips
.source(@portrait)
.loader(shrink: 2)
.resize_to_limit(500, 500)
.saver(strip: true)
.convert("png")
instrumenter_called = false
pipeline = pipeline.instrumenter do |**options, &block|
instrumenter_called = true
assert_equal @portrait, options[:source]
assert_equal Hash[shrink: 2], options[:loader]
assert_equal [[:resize_to_limit, [500, 500]]], options[:operations]
assert_equal Hash[strip: true], options[:saver]
assert_equal "png", options[:format]
block.call
end
pipeline.call
assert instrumenter_called
end
it "handles instrumenter not returning pipeline result" do
pipeline = ImageProcessing::Vips
.source(@portrait)
.instrumenter { |**, &block| block.call and :foo }
assert_kind_of Tempfile, pipeline.call
end
end