motion-juxtapose 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/Rakefile +1 -0
- data/bin/juxtapose +15 -0
- data/images/diff-view.png +0 -0
- data/images/initial-view.png +0 -0
- data/lib/juxtapose/application/README.md +1 -0
- data/lib/juxtapose/application/app.rb +42 -0
- data/lib/juxtapose/application/config/karma-e2e.conf.js +37 -0
- data/lib/juxtapose/application/config/karma.conf.js +31 -0
- data/lib/juxtapose/application/css/bootstrap-theme.css +459 -0
- data/lib/juxtapose/application/css/bootstrap-theme.min.css +9 -0
- data/lib/juxtapose/application/css/bootstrap.css +7098 -0
- data/lib/juxtapose/application/css/bootstrap.min.css +9 -0
- data/lib/juxtapose/application/css/styles.css +31 -0
- data/lib/juxtapose/application/fonts/glyphicons-halflings-regular.eot +0 -0
- data/lib/juxtapose/application/fonts/glyphicons-halflings-regular.svg +229 -0
- data/lib/juxtapose/application/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/lib/juxtapose/application/fonts/glyphicons-halflings-regular.woff +0 -0
- data/lib/juxtapose/application/js/angular.min.js +200 -0
- data/lib/juxtapose/application/js/app.js +80 -0
- data/lib/juxtapose/application/js/bootstrap.js +2002 -0
- data/lib/juxtapose/application/js/bootstrap.min.js +9 -0
- data/lib/juxtapose/application/js/underscore-min.js +6 -0
- data/lib/juxtapose/application/lib/image.rb +27 -0
- data/lib/juxtapose/application/lib/project.rb +48 -0
- data/lib/juxtapose/application/lib/spec.rb +43 -0
- data/lib/juxtapose/application/scripts/e2e-test.bat +11 -0
- data/lib/juxtapose/application/scripts/e2e-test.sh +9 -0
- data/lib/juxtapose/application/scripts/test.bat +11 -0
- data/lib/juxtapose/application/scripts/test.sh +9 -0
- data/lib/juxtapose/application/scripts/watchr.rb +19 -0
- data/lib/juxtapose/application/scripts/web-server.js +244 -0
- data/lib/juxtapose/application/spec/javascript/e2e/runner.html +11 -0
- data/lib/juxtapose/application/spec/javascript/e2e/scenarios.js +45 -0
- data/lib/juxtapose/application/spec/javascript/lib/angular/angular-mocks.js +1962 -0
- data/lib/juxtapose/application/spec/javascript/lib/angular/angular-scenario.js +29649 -0
- data/lib/juxtapose/application/spec/javascript/unit/controllersSpec.js +36 -0
- data/lib/juxtapose/application/spec/models/image_spec.rb +26 -0
- data/lib/juxtapose/application/spec/models/project_spec.rb +90 -0
- data/lib/juxtapose/application/spec/models/spec_spec.rb +54 -0
- data/lib/juxtapose/application/spec/spec_helper.rb +17 -0
- data/lib/juxtapose/application/views/index.html.haml +87 -0
- data/lib/juxtapose/screenshotter.rb +116 -0
- data/lib/juxtapose/strategy/frank_strategy.rb +58 -0
- data/lib/juxtapose/strategy/mac_bacon_strategy.rb +92 -0
- data/lib/juxtapose/version.rb +3 -0
- data/lib/motion-juxtapose.rb +15 -0
- data/motion-juxtapose.gemspec +26 -0
- metadata +182 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 164ece95d30c7dc4d2ffa8b9598cd3d6151820a5
|
4
|
+
data.tar.gz: 79a2467b97e83c21f77841c3901c1b41b0125483
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db4f4693c8d26620690a2066ab72d0b6f50a2687bf1d99af5bb3f6c9fb47bb7024901153aba953c3ebf100210c044137e7289942aa5bed8b10b1b7cd53eabd9b
|
7
|
+
data.tar.gz: 04c41f7fab50c2fff3d41b49b27c6228cca9f0850af6ecf9b37011d154810af34990c1bc256d70b02a94c8e4ed971af6be6f1c6825e54d4b01c6cfe73c40128e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Thomas Mayfield
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Juxtapose
|
2
|
+
|
3
|
+
Screenshot-driven assertions for testing RubyMotion applications.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'motion-juxtapose'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install motion-juxtapose
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Juxtapose's workflow generally goes:
|
22
|
+
|
23
|
+
1. Write a test that puts your app in the state you want to capture and take a screenshot (see below for how to do this in Bacon and Frank).
|
24
|
+
2. The first time this screenshot is captured, your test will fail with the error "No accepted screen shot".
|
25
|
+
3. You must provide Juxtapose an accepted screenshot to match against in future test runs. Run the juxtapose server with `bundle exec juxtapose` and browse to http://localhost:4567 — you should the just-captured screenshot, like below.
|
26
|
+
4. If the screenshot looks like what you expect, click Accept to save the image. Future runs of this test will be compared against the accepted one. ![Initial view of screenshots.](images/initial-view.png)
|
27
|
+
5. Run the tests again, and they should be green.
|
28
|
+
6. Later, when you introduce a change (intentionally or not), the tests will fail with the message "Screenshot did not match". Open up the juxtapose server again, and you'll see a comparison of your accepted screenshot with what the test captured. ![Diff view of screenshots.](images/diff-view.png)
|
29
|
+
7. If the change was intentional, you can accept the new screenshot - otherwise, you've got some fixin' to do!
|
30
|
+
|
31
|
+
|
32
|
+
### MacBacon
|
33
|
+
|
34
|
+
Juxtapose provides a single new matcher: `it_should_look_like` takes a single argument, a descriptive string predicate of what the screen should look like.
|
35
|
+
|
36
|
+
Example:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
describe "home controller" do
|
40
|
+
extend Juxtapose
|
41
|
+
|
42
|
+
describe "home controller" do
|
43
|
+
tests HomeViewController
|
44
|
+
|
45
|
+
it "has a button that moves when tapped" do
|
46
|
+
tap "Goodbye, world!"
|
47
|
+
it_should_look_like "when_tapped"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
### Frank
|
54
|
+
|
55
|
+
Add the following config to your features/support/env.rb:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
require 'motion-juxtapose'
|
59
|
+
Juxtapose::FrankStrategy.setup
|
60
|
+
```
|
61
|
+
|
62
|
+
This lets you write a screenshot matcher along the lines of:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
Then /^the screen should match "([^\"]*)"$/ do |template|
|
66
|
+
wait_for_nothing_to_be_animating
|
67
|
+
screenshotter = Juxtapose::Screenshotter.new(self, template)
|
68
|
+
max_attempts = 20
|
69
|
+
expect(screenshotter.attempt_verify(max_attempts)).to eq(true)
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
### Juxtapose Server
|
74
|
+
|
75
|
+
Juxtapose comes with a small webapp that you can use to view your screenshot specs, see diffs between accepted and failing specs and accept any changed images that are expected changes.
|
76
|
+
|
77
|
+
To start it, run `bundle exec juxtapose` in the root of your project and browse to localhost:4567.
|
78
|
+
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
1. Fork it
|
83
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
84
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
85
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
86
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/juxtapose
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'sinatra'
|
5
|
+
require 'haml' # if you use haml views
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'juxtapose/application/app.rb'
|
9
|
+
rescue LoadError => e
|
10
|
+
require 'rubygems'
|
11
|
+
path = File.expand_path '../../lib', __FILE__
|
12
|
+
$:.unshift(path) if File.directory?(path) && !$:.include?(path)
|
13
|
+
require 'juxtapose/application/app.rb'
|
14
|
+
end
|
15
|
+
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
# Juxtapose
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'lib/**/*.rb')).each do |file|
|
2
|
+
require file
|
3
|
+
end
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
class JuxtaposeServer < Sinatra::Base
|
7
|
+
|
8
|
+
set :static, true # set up static file routing
|
9
|
+
set :public_folder, File.expand_path('..', __FILE__) # set up the static dir (with images/js/css inside)
|
10
|
+
|
11
|
+
set :views, File.expand_path('../views', __FILE__) # set up the views dir
|
12
|
+
set :haml, { :format => :html5 } # if you use haml
|
13
|
+
|
14
|
+
get '/' do
|
15
|
+
haml :'/index.html', locals: {specs: project.specs}
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/images*' do |path|
|
19
|
+
send_file path
|
20
|
+
end
|
21
|
+
|
22
|
+
post '/accept' do
|
23
|
+
json_params = JSON.parse(request.body.read)
|
24
|
+
content_type :json
|
25
|
+
|
26
|
+
new_img = Project.accept!(json_params["filename"])
|
27
|
+
{image: {path: File.join("/images", new_img), img: new_img }}.to_json
|
28
|
+
end
|
29
|
+
|
30
|
+
def project
|
31
|
+
Project.new(screens_dir)
|
32
|
+
end
|
33
|
+
|
34
|
+
def screens_dir
|
35
|
+
[ File.join(Dir.pwd, 'spec/screens'), File.join(Dir.pwd, 'features/screens') ].select do |dir|
|
36
|
+
File.exists?(dir)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
JuxtaposeServer.run!
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module.exports = function(config){
|
2
|
+
config.set({
|
3
|
+
|
4
|
+
|
5
|
+
basePath : '../',
|
6
|
+
|
7
|
+
files : [
|
8
|
+
'test-compiled/e2e/**/*.js'
|
9
|
+
],
|
10
|
+
|
11
|
+
autoWatch : false,
|
12
|
+
|
13
|
+
browsers : ['Chrome'],
|
14
|
+
|
15
|
+
frameworks: ['ng-scenario'],
|
16
|
+
|
17
|
+
singleRun : true,
|
18
|
+
|
19
|
+
proxies : {
|
20
|
+
'/': 'http://localhost:8000/'
|
21
|
+
},
|
22
|
+
|
23
|
+
plugins : [
|
24
|
+
'karma-junit-reporter',
|
25
|
+
'karma-chrome-launcher',
|
26
|
+
'karma-firefox-launcher',
|
27
|
+
'karma-jasmine',
|
28
|
+
'karma-ng-scenario'
|
29
|
+
],
|
30
|
+
|
31
|
+
junitReporter : {
|
32
|
+
outputFile: 'test_out/e2e.xml',
|
33
|
+
suite: 'e2e'
|
34
|
+
}
|
35
|
+
|
36
|
+
})}
|
37
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module.exports = function(config){
|
2
|
+
config.set({
|
3
|
+
basePath : '../',
|
4
|
+
|
5
|
+
files : [
|
6
|
+
'js/angular.min.js',
|
7
|
+
'js/underscore-min.js',
|
8
|
+
'js/app.js',
|
9
|
+
'spec/javascript/lib/angular/angular-mocks.js',
|
10
|
+
'spec/javascript/unit/**/*.js'
|
11
|
+
],
|
12
|
+
|
13
|
+
autoWatch : true,
|
14
|
+
|
15
|
+
frameworks: ['jasmine'],
|
16
|
+
|
17
|
+
browsers : ['Chrome'],
|
18
|
+
|
19
|
+
plugins : [
|
20
|
+
'karma-junit-reporter',
|
21
|
+
'karma-chrome-launcher',
|
22
|
+
'karma-firefox-launcher',
|
23
|
+
'karma-jasmine'
|
24
|
+
],
|
25
|
+
|
26
|
+
junitReporter : {
|
27
|
+
outputFile: 'test_out/unit.xml',
|
28
|
+
suite: 'unit'
|
29
|
+
}
|
30
|
+
|
31
|
+
})}
|