forked from fastlane/fastlane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor_spec.rb
48 lines (43 loc) · 2.25 KB
/
editor_spec.rb
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
45
46
47
48
describe Frameit do
describe Frameit::Editor do
describe "frame!" do
before do
allow_any_instance_of(MiniMagick::Tool::Mogrify).to receive(:call) { '' }
allow(MiniMagick::Image).to receive(:open) { |path| MiniMagick::Image.new(path) }
allow_any_instance_of(MiniMagick::Image).to receive(:height) { 1334 }
allow_any_instance_of(MiniMagick::Image).to receive(:width) { 750 }
allow_any_instance_of(MiniMagick::Image).to receive(:composite) { |instance| instance }
allow_any_instance_of(MiniMagick::Image).to receive(:format) {}
allow_any_instance_of(MiniMagick::Image).to receive(:write) {}
allow_any_instance_of(MiniMagick::Image).to receive(:identify).and_return("0x0+0+0")
expect(Frameit::Offsets).to receive(:image_offset).and_return({
"offset" => "+60+225",
"width" => 752
})
Frameit.config = {}
end
it "properly frame screenshots with captions that include apostrophes" do
expect_any_instance_of(MiniMagick::Tool::Mogrify).to receive(:draw).with("text 0,0 'Don\\'t forget the apostrophes'")
screenshot = Frameit::Screenshot.new('./frameit/spec/fixtures/editor/apostrophes.png', Frameit::Color::BLACK)
Frameit::Editor.new(screenshot).frame!
end
it "does not double escape apostrophes" do
expect_any_instance_of(MiniMagick::Tool::Mogrify).to receive(:draw).with("text 0,0 'Don\\'t forget the apostrophes'")
screenshot = Frameit::Screenshot.new('./frameit/spec/fixtures/editor/escaped-apostrophes.png', Frameit::Color::BLACK)
Frameit::Editor.new(screenshot).frame!
end
end
describe "should_skip?" do
it "returns true with no matching filter in Framefile.json" do
screenshot = Frameit::Screenshot.new('./frameit/spec/fixtures/editor/ignore.png', Frameit::Color::BLACK)
skip = Frameit::Editor.new(screenshot).should_skip?
expect(skip).to be(true)
end
it "returns false with matching filter in Framefile.json" do
screenshot = Frameit::Screenshot.new('./frameit/spec/fixtures/editor/apostrophes.png', Frameit::Color::BLACK)
skip = Frameit::Editor.new(screenshot).should_skip?
expect(skip).to be(false)
end
end
end
end