monet 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'monet/compare'
3
+ require 'monet/errors'
4
+
5
+ describe Monet::Compare do
6
+ Given(:image_base) { './spec/fixtures/base.png' }
7
+ Given(:image_same) { './spec/fixtures/same.png' }
8
+ Given(:image_diff) { './spec/fixtures/diff.png' }
9
+ Given(:image_diff_size) { './spec/fixtures/diff_size.png' }
10
+ Given(:diff_name) { './spec/fixtures/base-diff.png' }
11
+
12
+ context "default compare" do
13
+ Given(:compare) { Monet::Compare.new }
14
+
15
+ context "identical image" do
16
+ When(:result) { compare.compare(image_base, image_same) }
17
+ Then { result.should_not be_modified }
18
+ And { File.exist?(diff_name).should be_false }
19
+ end
20
+
21
+ context "modified image" do
22
+ after do
23
+ File.delete(diff_name)
24
+ end
25
+
26
+ When(:result) { compare.compare(image_base, image_diff) }
27
+ Then { result.should be_modified }
28
+ And { File.exist?(diff_name).should be_true }
29
+ end
30
+
31
+ context "rejects mismatched dimensions" do
32
+ When(:result) { compare.compare(image_base, image_diff_size) }
33
+ Then { result.should have_failed(Monet::Errors::DifferentDimensions, /different dimensions/) }
34
+ end
35
+ end
36
+
37
+ context "grayscale compare" do
38
+ after do
39
+ File.delete(diff_name)
40
+ end
41
+
42
+ Given(:compare) { Monet::Compare.new(Monet::Grayscale) }
43
+
44
+ When(:result) { compare.compare(image_base, image_diff) }
45
+
46
+ Then { result.should be_modified }
47
+ And { File.exist?(diff_name).should be_true }
48
+ And { result.pixels_changed.should eq(23800) }
49
+ And { result.percentage_changed.should eq(5.44) }
50
+ end
51
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+ require 'monet/config'
3
+
4
+ describe Monet::Config do
5
+ context "has defaults" do
6
+ When(:config) { Monet::Config.new }
7
+ Then { config.driver.should == :poltergeist }
8
+ And { config.capture_dir.should == File.expand_path("./captures") }
9
+ end
10
+
11
+ context "can pass config to init" do
12
+ When(:config) { Monet::Config.new(capture_dir: "./faker", base_url: "http://hoodie.io") }
13
+ Then { config.driver.should == :poltergeist }
14
+ And { config.capture_dir.should == File.expand_path("./faker") }
15
+ And { config.base_url.should == "http://hoodie.io" }
16
+ end
17
+
18
+ context "can set options" do
19
+ When(:config) do
20
+ Monet::Config.config do |config|
21
+ config.driver = :poltergeist
22
+ config.dimensions = [1440,900]
23
+ config.base_url = "http://www.spider.io/"
24
+
25
+ config.map do |map|
26
+ map.add 'home/index'
27
+ map.add 'home/show'
28
+ end
29
+ end
30
+ end
31
+ Then { config.driver.should == :poltergeist }
32
+ And { config.dimensions.should == [1440,900] }
33
+ And { config.map.paths.should == ["home/index", "home/show"] }
34
+ end
35
+
36
+ context "should require base_url" do
37
+ When(:config) do
38
+ Monet::Config.config do |config|
39
+ config.map do |map|
40
+ map.add 'home/index'
41
+ map.add 'home/show'
42
+ end
43
+ end
44
+ end
45
+ Then { config.should have_failed(Monet::Config::MissingBaseURL, /set the base_url/) }
46
+ end
47
+
48
+ context "can request spider agent instead of explicit paths" do
49
+ When(:config) do
50
+ Monet::Config.config do |config|
51
+ config.base_url = "http://www.spider.io/"
52
+ config.map :spider
53
+ end
54
+ end
55
+ Then { config.map.should be_a(Monet::CaptureMap) }
56
+ And { config.map.type.should == :spider }
57
+ end
58
+ end
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,13 @@
1
+ require 'vcr'
2
+ require 'rspec/given'
3
+ require 'timecop'
4
+
5
+ VCR.configure do |c|
6
+ c.cassette_library_dir = 'spec/cassettes'
7
+ c.hook_into :webmock
8
+ c.configure_rspec_metadata!
9
+ end
10
+
11
+ RSpec.configure do |c|
12
+ c.treat_symbols_as_metadata_keys_with_true_values = true
13
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Luke van der Hoeven
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: poltergeist
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: capybara
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: oily_png
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: spidr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-given
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: timecop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Monet is a web UI change comparer.
126
+ email:
127
+ - hungerandthirst@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - .ruby-gemset
134
+ - .ruby-version
135
+ - .travis.yml
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - lib/monet.rb
141
+ - lib/monet/capture.rb
142
+ - lib/monet/capture_map.rb
143
+ - lib/monet/compare.rb
144
+ - lib/monet/config.rb
145
+ - lib/monet/diff_strategy.rb
146
+ - lib/monet/errors.rb
147
+ - lib/monet/version.rb
148
+ - monet.gemspec
149
+ - spec/capture_map_spec.rb
150
+ - spec/capture_spec.rb
151
+ - spec/cassettes/spider.yml
152
+ - spec/compare_spec.rb
153
+ - spec/config_spec.rb
154
+ - spec/fixtures/base.png
155
+ - spec/fixtures/diff.png
156
+ - spec/fixtures/diff_size.png
157
+ - spec/fixtures/same.png
158
+ - spec/spec_helper.rb
159
+ homepage: http://plukevdh.github.com/monet
160
+ licenses: []
161
+ metadata: {}
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - '>='
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 2.0.6
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: Monet captures your web pages, sets up a baseline and then ensures that future
182
+ changes to either backend or front end code leaves your UI intact. No more wondering
183
+ if CSS changes blow your UI up. Simply capture your page, make changes, run tests
184
+ and compare the diff!
185
+ test_files:
186
+ - spec/capture_map_spec.rb
187
+ - spec/capture_spec.rb
188
+ - spec/cassettes/spider.yml
189
+ - spec/compare_spec.rb
190
+ - spec/config_spec.rb
191
+ - spec/fixtures/base.png
192
+ - spec/fixtures/diff.png
193
+ - spec/fixtures/diff_size.png
194
+ - spec/fixtures/same.png
195
+ - spec/spec_helper.rb