compaa 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.
- data/.gitignore +8 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/Guardfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +18 -0
- data/app.rb +9 -0
- data/bin/compaa +65 -0
- data/compaa.gemspec +37 -0
- data/config.ru +6 -0
- data/features/compaa.feature +38 -0
- data/features/step_definitions/compaa_steps.rb +51 -0
- data/features/support/env.rb +29 -0
- data/features/support/file_helpers.rb +23 -0
- data/features/support/matchers.rb +13 -0
- data/fixtures/sample_generated.png +0 -0
- data/fixtures/sample_generated.png_difference.gif +0 -0
- data/fixtures/sample_reference.png +0 -0
- data/lib/compaa.rb +3 -0
- data/lib/compaa/difference_image.rb +37 -0
- data/lib/compaa/generated_image.rb +36 -0
- data/lib/compaa/version.rb +3 -0
- data/log/newrelic_agent.log +416 -0
- data/spec/difference_image_spec.rb +56 -0
- data/spec/generated_image_spec.rb +68 -0
- data/spec/spec_helper.rb +6 -0
- data/views/index.haml +86 -0
- metadata +232 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'cucumber' do
|
5
|
+
watch(%r{^features/.+\.feature$})
|
6
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
7
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
8
|
+
end
|
9
|
+
|
10
|
+
guard 'minitest' do
|
11
|
+
watch(%r|^spec/(.*)_spec\.rb|)
|
12
|
+
watch(%r|^lib/compaa/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
|
13
|
+
watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
14
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Jamie English
|
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,32 @@
|
|
1
|
+
[](https://travis-ci.org/jamienglish/compaa)
|
2
|
+
|
3
|
+
# compaa
|
4
|
+
|
5
|
+
As a companion to `Symilaa`, `Compaa` compares screenshots and presents the user
|
6
|
+
with a prompt to accept or reject the new screenshot.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'compaa'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install compaa
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
See cucumber features.
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'cucumber/rake/task'
|
6
|
+
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
Rake::TestTask.new :spec do |t|
|
10
|
+
t.libs << 'spec'
|
11
|
+
t.pattern = 'spec/**/*_spec.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
Cucumber::Rake::Task.new :features do |t|
|
15
|
+
t.cucumber_opts = 'features --format pretty'
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => [:spec, :features]
|
data/app.rb
ADDED
data/bin/compaa
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'methadone'
|
5
|
+
require 'compaa'
|
6
|
+
require 'sinatra'
|
7
|
+
require 'watir-webdriver'
|
8
|
+
require 'cgi'
|
9
|
+
|
10
|
+
class App
|
11
|
+
include Methadone::Main
|
12
|
+
include Methadone::CLILogging
|
13
|
+
|
14
|
+
PORT = '7788'
|
15
|
+
|
16
|
+
main do
|
17
|
+
|
18
|
+
sinatra_pid = fork do
|
19
|
+
user_project_path = Dir.pwd
|
20
|
+
|
21
|
+
Dir.chdir(File.dirname(__FILE__))
|
22
|
+
Dir.chdir("../")
|
23
|
+
puts Dir.pwd
|
24
|
+
|
25
|
+
puts "ln -s #{user_project_path} #{Dir.pwd}/public"
|
26
|
+
|
27
|
+
exec "thin start -p #{PORT}"
|
28
|
+
end
|
29
|
+
|
30
|
+
browser = Watir::Browser.new
|
31
|
+
browser.window.resize_to 1368, 1200
|
32
|
+
|
33
|
+
sleep 3
|
34
|
+
|
35
|
+
Compaa::DifferenceImage.all.each do |difference_image|
|
36
|
+
browser.goto "http://localhost:#{PORT}/?filepath=#{CGI::escape(difference_image.path)}"
|
37
|
+
puts "Comparing: #{difference_image.path}"
|
38
|
+
puts "Would you like to make this the reference image?"
|
39
|
+
|
40
|
+
difference_image.create_reference_image if screenshot_approved?
|
41
|
+
end
|
42
|
+
|
43
|
+
Compaa::GeneratedImage.all.each do |generated_image|
|
44
|
+
next if generated_image.has_reference_image?
|
45
|
+
|
46
|
+
puts "Approving: #{generated_image.path}"
|
47
|
+
generated_image.create_reference_image if screenshot_approved?
|
48
|
+
end
|
49
|
+
|
50
|
+
`kill -9 #{sinatra_pid}`
|
51
|
+
|
52
|
+
browser.close
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.screenshot_approved?
|
57
|
+
STDIN.gets.chomp.downcase.start_with? 'y'
|
58
|
+
end
|
59
|
+
|
60
|
+
version Compaa::VERSION
|
61
|
+
|
62
|
+
use_log_level_option
|
63
|
+
|
64
|
+
go!
|
65
|
+
end
|
data/compaa.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
lib = File.expand_path 'lib', File.dirname(__FILE__)
|
2
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
|
3
|
+
require 'compaa/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'compaa'
|
7
|
+
gem.version = Compaa::VERSION
|
8
|
+
gem.authors = ['BSkyB Helpcentre']
|
9
|
+
gem.email = ['skyhelpcentre@gmail.com']
|
10
|
+
gem.summary = <<-SUMMARY
|
11
|
+
Command line tool to compare screenshots outputted from our
|
12
|
+
screenshot_comparison gem
|
13
|
+
SUMMARY
|
14
|
+
gem.homepage = 'https://github.com/bskyb-commerce-helpcentre/compaa'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split $/
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename f }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ['lib']
|
20
|
+
|
21
|
+
%w[rake aruba simplecov wrong minitest guard-minitest guard-cucumber].each do |lib|
|
22
|
+
gem.add_development_dependency lib
|
23
|
+
end
|
24
|
+
|
25
|
+
gem.add_development_dependency 'rb-inotify' if RUBY_PLATFORM =~ /linux/
|
26
|
+
|
27
|
+
if RUBY_PLATFORM =~ /darwin/
|
28
|
+
gem.add_development_dependency 'rb-fsevent'
|
29
|
+
gem.add_development_dependency 'terminal-notifier-guard'
|
30
|
+
end
|
31
|
+
|
32
|
+
gem.add_dependency 'methadone', '~> 1.2.2'
|
33
|
+
gem.add_dependency 'sinatra'
|
34
|
+
gem.add_dependency 'thin'
|
35
|
+
gem.add_dependency 'haml'
|
36
|
+
gem.add_dependency 'watir-webdriver'
|
37
|
+
end
|
data/config.ru
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: Generate Rake Artifacts Tasks
|
2
|
+
|
3
|
+
In order to be able to view screenshot failures and decide whether accept or reject them
|
4
|
+
As a Help Centre developer
|
5
|
+
I want to be able to compare screenshots
|
6
|
+
|
7
|
+
Scenario: App just runs
|
8
|
+
When I get help for "compaa"
|
9
|
+
Then the exit status should be 0
|
10
|
+
And the banner should be present
|
11
|
+
And the banner should document that this app takes options
|
12
|
+
And the following options should be documented:
|
13
|
+
| --version |
|
14
|
+
And the banner should document that this app takes no arguments
|
15
|
+
|
16
|
+
Scenario: Compare screenshots and approve
|
17
|
+
Given a sample reference screenshot
|
18
|
+
And a sample generated screenshot
|
19
|
+
And a sample difference screenshot
|
20
|
+
When I run `compaa` interactively
|
21
|
+
And I approve the screenshot
|
22
|
+
Then the new reference screenshot should be the same as the sample generated screenshot
|
23
|
+
And the difference image should have been deleted
|
24
|
+
|
25
|
+
Scenario: Compare screenshots and reject
|
26
|
+
Given a sample reference screenshot
|
27
|
+
And a sample generated screenshot
|
28
|
+
And a sample difference screenshot
|
29
|
+
When I run `compaa` interactively
|
30
|
+
And I reject the screenshot
|
31
|
+
Then the new reference screenshot should be the same as the original reference screenshot
|
32
|
+
|
33
|
+
Scenario: Generated images without corresponding reference images require approval
|
34
|
+
Given a sample generated screenshot
|
35
|
+
And no reference images or difference images
|
36
|
+
When I run `compaa` interactively
|
37
|
+
And I approve the screenshot
|
38
|
+
Then the new reference screenshot should be the same as the sample generated screenshot
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Given /^no reference images or difference images$/ do
|
2
|
+
# do nothing
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^a sample reference screenshot$/ do
|
6
|
+
write_file 'artifacts/reference_screenshots/dir/image.png',
|
7
|
+
sample_reference_image
|
8
|
+
end
|
9
|
+
|
10
|
+
Given /^a sample generated screenshot$/ do
|
11
|
+
write_file 'artifacts/screenshots_generated_this_run/dir/image.png',
|
12
|
+
sample_generated_image
|
13
|
+
end
|
14
|
+
|
15
|
+
Given /^a sample difference screenshot$/ do
|
16
|
+
write_file 'artifacts/differences_in_screenshots_this_run/dir/image.png_difference.gif',
|
17
|
+
sample_difference_image
|
18
|
+
end
|
19
|
+
|
20
|
+
When /^I reject the screenshot$/ do
|
21
|
+
type 'No'
|
22
|
+
end
|
23
|
+
|
24
|
+
When /^I approve the screenshot$/ do
|
25
|
+
type 'Yes'
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^the new reference screenshot should be the same as the sample generated screenshot$/ do
|
29
|
+
sample_generated_file_path = File.join fixture_image_path, 'sample_generated.png'
|
30
|
+
new_reference_file_path = File.join current_dir, *%w[artifacts reference_screenshots dir image.png]
|
31
|
+
|
32
|
+
eventually :timeout => RUBY_PLATFORM == 'java' ? 20 : 3 do
|
33
|
+
new_reference_file_path.should be_the_same_file_as sample_generated_file_path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Then /^the new reference screenshot should be the same as the original reference screenshot$/ do
|
38
|
+
original_reference_file_path = File.join fixture_image_path, 'sample_reference.png'
|
39
|
+
new_reference_file_path = File.join current_dir, *%w[artifacts reference_screenshots dir image.png]
|
40
|
+
|
41
|
+
eventually :timeout => RUBY_PLATFORM == 'java' ? 20 : 3 do
|
42
|
+
new_reference_file_path.should be_the_same_file_as original_reference_file_path
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Then /^the difference image should have been deleted$/ do
|
47
|
+
difference_image = File.join current_dir,
|
48
|
+
*%w[artifacts differences_in_screenshots_this_run dir image.png_difference.gif]
|
49
|
+
|
50
|
+
difference_image.should_not exist
|
51
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'methadone/cucumber'
|
3
|
+
require 'wrong'
|
4
|
+
|
5
|
+
include Wrong
|
6
|
+
|
7
|
+
ENV['APP_ENV'] = 'test'
|
8
|
+
|
9
|
+
bin_dir = File.expand_path File.dirname(__FILE__), '../../bin'
|
10
|
+
ENV['PATH'] = bin_dir + File::PATH_SEPARATOR + ENV['PATH']
|
11
|
+
LIB_DIR = File.expand_path File.dirname(__FILE__), '../../lib'
|
12
|
+
|
13
|
+
Before do
|
14
|
+
# Using "announce" causes massive warnings on 1.9.2
|
15
|
+
@puts = true
|
16
|
+
@original_rubylib = ENV['RUBYLIB']
|
17
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
18
|
+
@aruba_timeout_seconds = RUBY_PLATFORM == 'java' ? 20 : 5
|
19
|
+
end
|
20
|
+
|
21
|
+
Aruba.configure do |config|
|
22
|
+
config.before_cmd do |cmd|
|
23
|
+
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
|
24
|
+
end
|
25
|
+
end if RUBY_PLATFORM == 'java'
|
26
|
+
|
27
|
+
After do
|
28
|
+
ENV['RUBYLIB'] = @original_rubylib
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FileHelpers
|
2
|
+
def sample_reference_image
|
3
|
+
fixture_image('sample_reference.png').read
|
4
|
+
end
|
5
|
+
|
6
|
+
def sample_generated_image
|
7
|
+
fixture_image('sample_generated.png').read
|
8
|
+
end
|
9
|
+
|
10
|
+
def sample_difference_image
|
11
|
+
fixture_image('sample_generated.png_difference.gif').read
|
12
|
+
end
|
13
|
+
|
14
|
+
def fixture_image file_name
|
15
|
+
File.new File.join(fixture_image_path, file_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def fixture_image_path
|
19
|
+
File.expand_path "../../fixtures", File.dirname(__FILE__)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
World FileHelpers
|
Binary file
|
Binary file
|
Binary file
|
data/lib/compaa.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Compaa
|
4
|
+
class DifferenceImage < Struct.new(:path)
|
5
|
+
attr_writer :file_manager
|
6
|
+
|
7
|
+
def self.all
|
8
|
+
Dir.glob(File.join %w[artifacts differences_in_screenshots_this_run ** *.gif]).map { |path|
|
9
|
+
new path
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_reference_image
|
14
|
+
file_manager.mkdir_p File.dirname reference_path
|
15
|
+
file_manager.cp generated_path, reference_path
|
16
|
+
file_manager.rm path
|
17
|
+
end
|
18
|
+
|
19
|
+
def reference_path
|
20
|
+
path.gsub(
|
21
|
+
'differences_in_screenshots_this_run', 'reference_screenshots'
|
22
|
+
).gsub('_difference.gif', '')
|
23
|
+
end
|
24
|
+
|
25
|
+
def generated_path
|
26
|
+
path.gsub(
|
27
|
+
'differences_in_screenshots_this_run', 'screenshots_generated_this_run'
|
28
|
+
).gsub('_difference.gif', '')
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def file_manager
|
34
|
+
@file_manager ||= FileUtils
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|