motion-juxtapose 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +18 -0
- data/Rakefile +12 -0
- data/app/app_delegate.rb +8 -0
- data/app/controllers/test_controller.rb +14 -0
- data/lib/juxtapose/application/lib/image.rb +9 -1
- data/lib/juxtapose/application/lib/spec.rb +3 -3
- data/lib/juxtapose/application/spec/models/spec_spec.rb +11 -0
- data/lib/juxtapose/screenshotter.rb +27 -11
- data/lib/juxtapose/version.rb +1 -1
- data/spec/controllers/test_controller_spec.rb +53 -0
- data/spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-passes-when-there-is-an-identical-accepted-screenshot/accepted-screenshot/accepted.png +0 -0
- data/spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-raises-an-error-and-produces-diffs-on-failure/going-to-differ-screenshot/accepted.png +0 -0
- data/spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-raises-an-error-when-screens-are-different-sizes/different-sized-screenshot/accepted.png +0 -0
- metadata +14 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0543dfe3a91b130a2a8faf863307dd63e3ba619d
|
4
|
+
data.tar.gz: b12e0a693f99ef3d63eb0a73674f0ab94a232142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f676239c5499c311ed923ab84de8aadd96092459db5a563136352be7d828d986bbf336973313d95192910446d3e5f461268976b48782c3ec775c7a353108fd33
|
7
|
+
data.tar.gz: 013fe557fbbe9ebdcbc0a8dd1d5920a3fd89d312cca5f140936ec35fe97a989e57f96e96d92e3cf157278c2d4b92dea4c7cc855ec8cc9fc31d7a363767a40736
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -76,6 +76,24 @@ Juxtapose comes with a small webapp that you can use to view your screenshot spe
|
|
76
76
|
|
77
77
|
To start it, run `bundle exec juxtapose` in the root of your project and browse to localhost:4567.
|
78
78
|
|
79
|
+
## Release Notes
|
80
|
+
|
81
|
+
#### v.0.1.1
|
82
|
+
|
83
|
+
* Raise error if screenshot sizes don't match ([@mdenomy](http://github.com/mdenomy))
|
84
|
+
* Bug fix: Differentiate image status by filename, not full path. Fixes #8.
|
85
|
+
|
86
|
+
#### v.0.1.0
|
87
|
+
|
88
|
+
* Initial release.
|
89
|
+
|
90
|
+
## Contributors
|
91
|
+
|
92
|
+
* [Joe Lind](http://github.com/joelind)
|
93
|
+
* [Thomas Mayfield](http://github.com/thegreatape )
|
94
|
+
* [Jeffrey Chupp](http://github.com/semanticart)
|
95
|
+
* [Michael Denomy](http://github.com/mdenomy)
|
96
|
+
|
79
97
|
|
80
98
|
## Contributing
|
81
99
|
|
data/Rakefile
CHANGED
@@ -1 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
$:.unshift('/Library/RubyMotion/lib')
|
3
|
+
require 'motion/project/template/ios'
|
1
4
|
require "bundler/gem_tasks"
|
5
|
+
Bundler.setup
|
6
|
+
Bundler.require
|
7
|
+
|
8
|
+
require 'motion-juxtapose'
|
9
|
+
|
10
|
+
Motion::Project::App.setup do |app|
|
11
|
+
app.name = 'juxtapose-tests'
|
12
|
+
app.detect_dependencies = false
|
13
|
+
end
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
3
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
4
|
+
@window.rootViewController = TestController.alloc.init
|
5
|
+
@window.makeKeyAndVisible
|
6
|
+
true
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class TestController < UIViewController
|
2
|
+
def viewDidLoad
|
3
|
+
super
|
4
|
+
self.view.backgroundColor = UIColor.whiteColor
|
5
|
+
@label = UILabel.alloc.initWithFrame(CGRectZero)
|
6
|
+
@label.text = "Juxtapose"
|
7
|
+
@label.sizeToFit
|
8
|
+
|
9
|
+
@label.center =
|
10
|
+
[self.view.frame.size.width / 2,
|
11
|
+
self.view.frame.size.height / 2]
|
12
|
+
self.view.addSubview(@label)
|
13
|
+
end
|
14
|
+
end
|
@@ -21,15 +21,15 @@ class Spec
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def accepted
|
24
|
-
images.select
|
24
|
+
images.select(&:accepted?).first
|
25
25
|
end
|
26
26
|
|
27
27
|
def current
|
28
|
-
images.select
|
28
|
+
images.select(&:current?).first
|
29
29
|
end
|
30
30
|
|
31
31
|
def diff
|
32
|
-
images.select
|
32
|
+
images.select(&:diff?).first
|
33
33
|
end
|
34
34
|
|
35
35
|
def as_json
|
@@ -23,6 +23,17 @@ describe Spec do
|
|
23
23
|
]
|
24
24
|
end
|
25
25
|
|
26
|
+
it "only uses the file name to determine accepted/current/diff status" do
|
27
|
+
spec_dir ="#{@specs_dir}/ios7.0/currently_logged_in_user"
|
28
|
+
FileUtils.mkdir_p(spec_dir)
|
29
|
+
|
30
|
+
FileUtils.touch("#{spec_dir}/accepted.png")
|
31
|
+
|
32
|
+
spec = Spec.new @specs_dir, spec_dir
|
33
|
+
expect(spec.current).to be_nil
|
34
|
+
expect(spec.accepted.img).to eq("#{spec_dir}/accepted.png")
|
35
|
+
end
|
36
|
+
|
26
37
|
it "serializes to JSON" do
|
27
38
|
spec_dir ="#{@specs_dir}/ios7.0/user_views_home_screen"
|
28
39
|
FileUtils.mkdir_p(spec_dir)
|
@@ -95,22 +95,38 @@ module Juxtapose
|
|
95
95
|
|
96
96
|
success = true
|
97
97
|
if File.exists? filename(:accepted )
|
98
|
-
|
99
|
-
|
100
|
-
out.chomp!
|
101
|
-
(out == '0').tap do |verified|
|
102
|
-
if verified
|
103
|
-
`rm #{filename(:current)}`
|
104
|
-
`rm #{filename(:diff)}`
|
105
|
-
else
|
106
|
-
success = false
|
107
|
-
end
|
108
|
-
end
|
98
|
+
raise "Screenshots are different sizes" unless same_size?
|
99
|
+
success = screenshots_match?
|
109
100
|
else
|
110
101
|
raise "No accepted screen shot for #{filename :accepted}"
|
111
102
|
end
|
112
103
|
|
113
104
|
success
|
114
105
|
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def same_size?
|
110
|
+
identify_command = "identify -format '%wx%h '"
|
111
|
+
out = `#{identify_command} \"#{filename :current}\" \"#{filename :accepted}\" 2>&1`
|
112
|
+
sizes = out.split
|
113
|
+
sizes.length == 2 && sizes.uniq.length == 1
|
114
|
+
end
|
115
|
+
|
116
|
+
def screenshots_match?
|
117
|
+
match = true
|
118
|
+
compare_command = "compare -fuzz #{fuzz_factor}% -metric AE -dissimilarity-threshold 1 -subimage-search"
|
119
|
+
out = `#{compare_command} \"#{filename :current}\" \"#{filename :accepted}\" \"#{filename :diff}\" 2>&1`
|
120
|
+
out.chomp!
|
121
|
+
(out == '0').tap do |verified|
|
122
|
+
if verified
|
123
|
+
`rm #{filename(:current)}`
|
124
|
+
`rm #{filename(:diff)}`
|
125
|
+
else
|
126
|
+
match = false
|
127
|
+
end
|
128
|
+
end
|
129
|
+
match
|
130
|
+
end
|
115
131
|
end
|
116
132
|
end
|
data/lib/juxtapose/version.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
describe 'screenshot testing under bacon' do
|
2
|
+
extend Juxtapose
|
3
|
+
|
4
|
+
tests TestController
|
5
|
+
|
6
|
+
it "raises an error when no accepted screenshot is present" do
|
7
|
+
error = nil
|
8
|
+
begin
|
9
|
+
it_should_look_like "no accepted screenshot"
|
10
|
+
rescue RuntimeError => e
|
11
|
+
error = e
|
12
|
+
end
|
13
|
+
error.should.not.be.nil
|
14
|
+
error.message.should =~ /No accepted screen shot for/
|
15
|
+
end
|
16
|
+
|
17
|
+
it "passes when there is an identical accepted screenshot" do
|
18
|
+
it_should_look_like "accepted screenshot"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "raises an error and produces diffs on failure" do
|
22
|
+
Dispatch::Queue.main.async do
|
23
|
+
view("Juxtapose").text = "Changed!"
|
24
|
+
end
|
25
|
+
|
26
|
+
wait 1.0 do
|
27
|
+
error = nil
|
28
|
+
begin
|
29
|
+
it_should_look_like "going to differ screenshot"
|
30
|
+
rescue RuntimeError => e
|
31
|
+
error = e
|
32
|
+
end
|
33
|
+
error.should.not.be.nil
|
34
|
+
error.message.should =~ /Screenshot did not match/
|
35
|
+
|
36
|
+
spec_dir = "spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-raises-an-error-and-produces-diffs-on-failure/going-to-differ-screenshot"
|
37
|
+
|
38
|
+
File.should.exist(File.join( ENV["RUBYMOTION_PROJECT_DIR"], spec_dir, "current.png"))
|
39
|
+
File.should.exist(File.join( ENV["RUBYMOTION_PROJECT_DIR"], spec_dir, "diff.png"))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises an error when screens are different sizes" do
|
44
|
+
error = nil
|
45
|
+
begin
|
46
|
+
it_should_look_like "different sized screenshot"
|
47
|
+
rescue RuntimeError => e
|
48
|
+
error = e
|
49
|
+
end
|
50
|
+
error.should.not.be.nil
|
51
|
+
error.message.should =~ /Screenshots are different sizes/
|
52
|
+
end
|
53
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-juxtapose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Lind
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|
@@ -109,6 +109,8 @@ files:
|
|
109
109
|
- LICENSE.txt
|
110
110
|
- README.md
|
111
111
|
- Rakefile
|
112
|
+
- app/app_delegate.rb
|
113
|
+
- app/controllers/test_controller.rb
|
112
114
|
- bin/juxtapose
|
113
115
|
- images/diff-view.png
|
114
116
|
- images/initial-view.png
|
@@ -155,6 +157,10 @@ files:
|
|
155
157
|
- lib/juxtapose/version.rb
|
156
158
|
- lib/motion-juxtapose.rb
|
157
159
|
- motion-juxtapose.gemspec
|
160
|
+
- spec/controllers/test_controller_spec.rb
|
161
|
+
- spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-passes-when-there-is-an-identical-accepted-screenshot/accepted-screenshot/accepted.png
|
162
|
+
- spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-raises-an-error-and-produces-diffs-on-failure/going-to-differ-screenshot/accepted.png
|
163
|
+
- spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-raises-an-error-when-screens-are-different-sizes/different-sized-screenshot/accepted.png
|
158
164
|
homepage: https://github.com/terriblelabs/motion-juxtapose
|
159
165
|
licenses:
|
160
166
|
- MIT
|
@@ -175,8 +181,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
181
|
version: '0'
|
176
182
|
requirements: []
|
177
183
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.2.2
|
179
185
|
signing_key:
|
180
186
|
specification_version: 4
|
181
187
|
summary: Screenshot-based assertions for RubyMotion projects
|
182
|
-
test_files:
|
188
|
+
test_files:
|
189
|
+
- spec/controllers/test_controller_spec.rb
|
190
|
+
- spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-passes-when-there-is-an-identical-accepted-screenshot/accepted-screenshot/accepted.png
|
191
|
+
- spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-raises-an-error-and-produces-diffs-on-failure/going-to-differ-screenshot/accepted.png
|
192
|
+
- spec/screens/iphone-retina/ios_7.0.3/screenshot-testing-under-bacon-raises-an-error-when-screens-are-different-sizes/different-sized-screenshot/accepted.png
|