rspec-page-regression 0.2.1 → 0.2.99
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +2 -0
- data/lib/rspec/page-regression/file_paths.rb +2 -2
- data/lib/rspec/page-regression/matcher.rb +2 -2
- data/lib/rspec/page-regression/version.rb +1 -1
- data/rspec-page-regression.gemspec +1 -1
- data/spec/match_expectation_spec.rb +34 -34
- data/spec/spec_helper.rb +1 -0
- data/spec/support/helpers.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53b6e6168816a2ebc4280a5edfc30beb6ba3cff1
|
4
|
+
data.tar.gz: 4fbebd25f84151737f2fba2d38b4da73a09d0e5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e14de72676cbdbe042084cd1a6df1719d4335a1a6aec9ab2d9eb7c2fbceaeff573d43915aaf89cc3f91febe7adb927e5efd22a870e80a42bdf8f119848c52138
|
7
|
+
data.tar.gz: 6f55c9e7849ba912d212e9dc10d01c104f1d4fbfc2cd54775e3ac945a6b42f05f1542d4552b54664b14fe7bd371583c8b4edd1aeb755bcb1676e5376a76fda33
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -144,6 +144,8 @@ Don't forget to include specs (`rake spec`) to verify your functionality. Code
|
|
144
144
|
|
145
145
|
Release Notes:
|
146
146
|
|
147
|
+
* 0.2.1 - Explicit dependency on rspec ~> 2.14.0
|
148
|
+
|
147
149
|
* 0.2.0 - Support selenium. Thanks to [@edwinvdgraaf](https://github.com/edwinvdgraaf)
|
148
150
|
|
149
151
|
* 0.1.2 - Remove existing difference images so they won't be shown in cases where files couldn't be differenced.
|
@@ -9,7 +9,7 @@ module RSpec::PageRegression
|
|
9
9
|
def initialize(example, expected_path = nil)
|
10
10
|
expected_path = Pathname.new(expected_path) if expected_path
|
11
11
|
|
12
|
-
descriptions = description_ancestry(example.metadata)
|
12
|
+
descriptions = description_ancestry(example.metadata[:example_group])
|
13
13
|
descriptions.pop if descriptions.last =~ %r{
|
14
14
|
^
|
15
15
|
(then_+)? (page_+)? (should_+)? match_expectation
|
@@ -37,7 +37,7 @@ module RSpec::PageRegression
|
|
37
37
|
|
38
38
|
def description_ancestry(metadata)
|
39
39
|
return [] if metadata.nil?
|
40
|
-
description_ancestry(metadata[:
|
40
|
+
description_ancestry(metadata[:parent_example_group]) << metadata[:description].parameterize("_")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -5,7 +5,7 @@ module RSpec::PageRegression
|
|
5
5
|
RSpec::Matchers.define :match_expectation do |expectation_path|
|
6
6
|
|
7
7
|
match do |page|
|
8
|
-
@filepaths = FilePaths.new(
|
8
|
+
@filepaths = FilePaths.new(RSpec.current_example, expectation_path)
|
9
9
|
Renderer.render(page, @filepaths.test_image)
|
10
10
|
@comparison = ImageComparison.new(@filepaths)
|
11
11
|
@comparison.result == :match
|
@@ -30,7 +30,7 @@ module RSpec::PageRegression
|
|
30
30
|
end
|
31
31
|
|
32
32
|
failure_message_for_should_not do |page|
|
33
|
-
"Test image
|
33
|
+
"Test image expected to not match expectation image"
|
34
34
|
end
|
35
35
|
|
36
36
|
def viewer
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "activesupport"
|
22
22
|
spec.add_dependency "oily_png"
|
23
23
|
spec.add_dependency "poltergeist"
|
24
|
-
spec.add_dependency "rspec", "
|
24
|
+
spec.add_dependency "rspec", "2.99"
|
25
25
|
spec.add_dependency "which_works"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bourne"
|
@@ -13,19 +13,19 @@ describe "match_expectation" do
|
|
13
13
|
@match_argument = nil
|
14
14
|
}
|
15
15
|
|
16
|
-
context "using
|
16
|
+
context "using expect().to" do
|
17
17
|
|
18
18
|
When {
|
19
19
|
begin
|
20
|
-
@page.
|
20
|
+
expect(@page).to match_expectation @match_argument
|
21
21
|
rescue RSpec::Expectations::ExpectationNotMetError => e
|
22
22
|
@error = e
|
23
23
|
end
|
24
24
|
}
|
25
25
|
|
26
26
|
context "framework" do
|
27
|
-
Then { @driver.
|
28
|
-
Then { @driver.
|
27
|
+
Then { expect(@driver).to have_received(:resize).with(1024, 768) }
|
28
|
+
Then { expect(@driver).to have_received(:save_screenshot).with(test_path, @opts) }
|
29
29
|
|
30
30
|
context "selenium" do
|
31
31
|
Given {
|
@@ -39,7 +39,7 @@ describe "match_expectation" do
|
|
39
39
|
@driver.unstub(:resize)
|
40
40
|
}
|
41
41
|
|
42
|
-
Then { @window.
|
42
|
+
Then { expect(@window).to have_received(:resize_to).with(1024, 768) }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -47,7 +47,7 @@ describe "match_expectation" do
|
|
47
47
|
Given { use_test_image "A" }
|
48
48
|
Given { use_expected_image "A" }
|
49
49
|
|
50
|
-
Then { @error.
|
50
|
+
Then { expect(@error).to be_nil }
|
51
51
|
end
|
52
52
|
|
53
53
|
|
@@ -55,35 +55,35 @@ describe "match_expectation" do
|
|
55
55
|
Given { use_test_image "A" }
|
56
56
|
Given { use_expected_image "B" }
|
57
57
|
|
58
|
-
Then { @error.
|
59
|
-
Then { @error.message.
|
60
|
-
Then { @error.message.
|
58
|
+
Then { expect(@error).to_not be_nil }
|
59
|
+
Then { expect(@error.message).to include "Test image does not match expected image" }
|
60
|
+
Then { expect(@error.message).to match viewer_pattern(test_path, expected_path, difference_path) }
|
61
61
|
|
62
|
-
Then { difference_path.read.
|
62
|
+
Then { expect(difference_path.read).to eq fixture_image("ABdiff").read }
|
63
63
|
end
|
64
64
|
|
65
65
|
context "when test image is missing" do
|
66
66
|
Given { use_expected_image "A" }
|
67
67
|
|
68
|
-
Then { @error.
|
69
|
-
Then { @error.message.
|
70
|
-
Then { @error.message.
|
68
|
+
Then { expect(@error).to_not be_nil }
|
69
|
+
Then { expect(@error.message).to include "Missing test image #{test_path}" }
|
70
|
+
Then { expect(@error.message).to match viewer_pattern(expected_path) }
|
71
71
|
context "with previously-created difference image" do
|
72
72
|
Given { preexisting_difference_image }
|
73
|
-
Then { difference_path.
|
73
|
+
Then { expect(difference_path).to_not be_exist }
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
context "when expected image is missing" do
|
78
78
|
Given { use_test_image "A" }
|
79
79
|
|
80
|
-
Then { @error.
|
81
|
-
Then { @error.message.
|
82
|
-
Then { @error.message.
|
83
|
-
Then { @error.message.
|
80
|
+
Then { expect(@error).to_not be_nil }
|
81
|
+
Then { expect(@error.message).to include "Missing expectation image #{expected_path}" }
|
82
|
+
Then { expect(@error.message).to match viewer_pattern(test_path) }
|
83
|
+
Then { expect(@error.message).to include "mkdir -p #{expected_path.dirname} && cp #{test_path} #{expected_path}" }
|
84
84
|
context "with previously-created difference image" do
|
85
85
|
Given { preexisting_difference_image }
|
86
|
-
Then { difference_path.
|
86
|
+
Then { expect(difference_path).to_not be_exist }
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -91,21 +91,21 @@ describe "match_expectation" do
|
|
91
91
|
Given { use_test_image "Small" }
|
92
92
|
Given { use_expected_image "A" }
|
93
93
|
|
94
|
-
Then { @error.
|
95
|
-
Then { @error.message.
|
96
|
-
Then { @error.message.
|
94
|
+
Then { expect(@error).to_not be_nil }
|
95
|
+
Then { expect(@error.message).to include "Test image size 256x167 does not match expectation 512x334" }
|
96
|
+
Then { expect(@error.message).to match viewer_pattern(test_path, expected_path) }
|
97
97
|
context "with previously-created difference image" do
|
98
98
|
Given { preexisting_difference_image }
|
99
|
-
Then { difference_path.
|
99
|
+
Then { expect(difference_path).to_not be_exist }
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
context "with match argument" do
|
104
104
|
Given { @match_argument = "/this/is/a/test.png" }
|
105
|
-
Then { @error.message.
|
105
|
+
Then { expect(@error.message).to include "Missing expectation image /this/is/a/test.png" }
|
106
106
|
context "with previously-created difference image" do
|
107
107
|
Given { preexisting_difference_image }
|
108
|
-
Then { difference_path.
|
108
|
+
Then { expect(difference_path).to_not be_exist }
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -113,12 +113,12 @@ describe "match_expectation" do
|
|
113
113
|
Given do
|
114
114
|
RSpec::Core::Example.any_instance.stubs :metadata => {
|
115
115
|
file_path: __FILE__,
|
116
|
-
description: "Then page.
|
116
|
+
description: "Then expect(page).to match_expectation",
|
117
117
|
example_group: { description: "parent" }
|
118
118
|
}
|
119
119
|
end
|
120
|
-
Then { @driver.
|
121
|
-
Then { @error.message.
|
120
|
+
Then { expect(@driver).to have_received(:save_screenshot).with(Pathname.new("tmp/spec/expectation/parent/test.png"), @opts) }
|
121
|
+
Then { expect(@error.message).to include "Missing expectation image spec/expectation/parent/expected.png" }
|
122
122
|
end
|
123
123
|
|
124
124
|
context "with page size configuration" do
|
@@ -127,15 +127,15 @@ describe "match_expectation" do
|
|
127
127
|
config.page_size = [123, 456]
|
128
128
|
end
|
129
129
|
end
|
130
|
-
Then { @driver.
|
130
|
+
Then { expect(@driver).to have_received(:resize).with(123, 456) }
|
131
131
|
end
|
132
132
|
|
133
133
|
end
|
134
134
|
|
135
|
-
context "using
|
135
|
+
context "using expect().to_not" do
|
136
136
|
When {
|
137
137
|
begin
|
138
|
-
@page.
|
138
|
+
expect(@page).to_not match_expectation
|
139
139
|
rescue RSpec::Expectations::ExpectationNotMetError => e
|
140
140
|
@error = e
|
141
141
|
end
|
@@ -145,15 +145,15 @@ describe "match_expectation" do
|
|
145
145
|
Given { use_test_image "A" }
|
146
146
|
Given { use_expected_image "B" }
|
147
147
|
|
148
|
-
Then { @error.
|
148
|
+
Then { expect(@error).to be_nil }
|
149
149
|
end
|
150
150
|
|
151
151
|
context "when files match" do
|
152
152
|
Given { use_test_image "A" }
|
153
153
|
Given { use_expected_image "A" }
|
154
154
|
|
155
|
-
Then { @error.
|
156
|
-
Then { @error.message.
|
155
|
+
Then { expect(@error).to_not be_nil }
|
156
|
+
Then { expect(@error.message).to eq "Test image expected to not match expectation image" }
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/helpers.rb
CHANGED
@@ -13,12 +13,12 @@ module Helpers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def getpath(root, base)
|
16
|
-
(root + "expectation" + group_path(
|
16
|
+
(root + "expectation" + group_path(RSpec.current_example.metadata[:example_group]) + "#{base}.png").relative_path_from Pathname.getwd
|
17
17
|
end
|
18
18
|
|
19
19
|
def group_path(metadata)
|
20
20
|
return Pathname.new("") if metadata.nil?
|
21
|
-
group_path(metadata[:
|
21
|
+
group_path(metadata[:parent_example_group]) + metadata[:description].parameterize("_")
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-page-regression
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.99
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: '2.99'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: '2.99'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: which_works
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|