ojo 0.0.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 +7 -0
- data/.gitignore +16 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +106 -0
- data/Rakefile +19 -0
- data/lib/ojo/comparison.rb +88 -0
- data/lib/ojo/locations.rb +26 -0
- data/lib/ojo/output.rb +90 -0
- data/lib/ojo/rails/engine.rb +6 -0
- data/lib/ojo/screenshot.rb +21 -0
- data/lib/ojo/version.rb +3 -0
- data/lib/ojo.rb +13 -0
- data/lib/tasks/ojo.rake +59 -0
- data/ojo.gemspec +28 -0
- data/test/page_objects/test_app/index_page.rb +8 -0
- data/test/page_objects/test_app/test_app_page.rb +6 -0
- data/test/page_objects.rb +13 -0
- data/test/phantom/browser_test.rb +9 -0
- data/test/phantom_test_helper.rb +67 -0
- data/test/test_app/Gemfile +9 -0
- data/test/test_app/Gemfile.lock +100 -0
- data/test/test_app/app/controllers/application_controller.rb +2 -0
- data/test/test_app/app/controllers/local_controller.rb +7 -0
- data/test/test_app/app/views/layouts/local.html.erb +14 -0
- data/test/test_app/app/views/local/index.html.erb +1 -0
- data/test/test_app/config/database.yml +10 -0
- data/test/test_app/config/initializers/ojo_initializer.rb +1 -0
- data/test/test_app/config/routes.rb +4 -0
- data/test/test_app/config.ru +31 -0
- data/test/test_app/log/development.log +260 -0
- data/test/test_app/log/test.log +2762 -0
- data/test/test_app/ojo_development +0 -0
- data/test/test_app/test_app.rb +30 -0
- data/test/test_helper.rb +59 -0
- data/test/unit/comparison_test.rb +185 -0
- data/test/unit/config_test.rb +9 -0
- data/test/unit/files_test.rb +31 -0
- data/test/unit/output_test.rb +38 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b932f9e50044ba852bb5d1db5183ad97edb77df
|
4
|
+
data.tar.gz: dcb373b8c6220e1425d2fbfedfd9da682a5bbee7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 40157f1b72198c07ad7f0324290c3dd7c3a75088d7cb3308c5710def5e9437dfd9b6a097adf3b4eb101e9aeca5826d0a8c172c99a443347b9b5a2f067147f517
|
7
|
+
data.tar.gz: c605a2d3b905fd30846df10150e0fc729ef1f32af06986c10df4909d10eebcfb44bb275b1d728501fa20bd0c31b15b8e8adf0d0589dcd0fb4cb0311885f4ddf2
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.2
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in ojo.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'minitest'
|
7
|
+
gem 'minitest-reporters'
|
8
|
+
gem 'mocha'
|
9
|
+
gem 'awesome_print'
|
10
|
+
gem 'rails', '3.2.16'
|
11
|
+
gem 'poltergeist'
|
12
|
+
gem 'capybara'
|
13
|
+
gem 'ae_page_objects', '1.3.0'
|
14
|
+
gem 'sqlite3'
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 geordie
|
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,106 @@
|
|
1
|
+
# Ojo
|
2
|
+
|
3
|
+
Ojo is not fancy. it just does a simple comparison of two sets of screenshots. the idea is that there is a set of tests or scripts that will compile the two sets (for example, one from a master branch and another from a feature branch). running the rake task that `Ojo` adds to the rails app will tell you if the two sets of files differ. the rake task is `ojo:compare[branch_1,branch_2]`.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/QuantumGeordie/ojo)
|
6
|
+
[](https://codeclimate.com/github/QuantumGeordie/ojo)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'ojo'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install ojo
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### Initialization
|
25
|
+
|
26
|
+
in a rails initializer do something like this to tell `Ojo` where the files to compare are.
|
27
|
+
|
28
|
+
`Ojo.location = '/path/to/screenshots'`
|
29
|
+
|
30
|
+
### Screenshotter
|
31
|
+
|
32
|
+
you can use whatever method of taking the screenshots you would like. Ojo has a concept of a `screenshotter`. you can define it like so:
|
33
|
+
|
34
|
+
Ojo.screenshotter = lambda do |filename|
|
35
|
+
# what ever method of screenshot grabbing you would like
|
36
|
+
# for example, using Capybara...
|
37
|
+
page.save_screenshot(filename)
|
38
|
+
end
|
39
|
+
|
40
|
+
then in your script/test you can do `Ojo.screenshot(data_set, screenshot)`. using the screenshotter is not necessary.
|
41
|
+
|
42
|
+
Ojo.screenshot('master', 'login_page')
|
43
|
+
|
44
|
+
really all you need to do is end up with two sets of PNG files that have the same filenames.
|
45
|
+
|
46
|
+
### Comparison
|
47
|
+
|
48
|
+
After both sets of data have been run, the `Ojo` rake task `ojo:compare[branch_1,branch_2]` can be run to compare the results. as an example, let's say we were making some changes to the login page. we might have an in work `login_page_update` branch that we want to compare to our `master` branch.
|
49
|
+
|
50
|
+
#### Example data sets
|
51
|
+
|
52
|
+
/master
|
53
|
+
/current_user.png
|
54
|
+
/master_only.png
|
55
|
+
/signed_in.png
|
56
|
+
/test_home.png
|
57
|
+
/user.png
|
58
|
+
/login_page_update
|
59
|
+
/login_update_only.png
|
60
|
+
/current_user.png
|
61
|
+
/signed_in.png
|
62
|
+
/test_home.png
|
63
|
+
/user.png
|
64
|
+
|
65
|
+
#### run
|
66
|
+
|
67
|
+
>> rake ojo:compare[master,login_page_update]
|
68
|
+
+-----------------------------------------------------------------------------------------------------------------------------------------+
|
69
|
+
| Ojo v.0.0.1 |
|
70
|
+
| file location: /Users/geordie/src/faktory/tmp/appearance |
|
71
|
+
| 10/17/2014 |
|
72
|
+
+-----------------------------------------------------------------------------------------------------------------------------------------+
|
73
|
+
| master | login_page_update | Results |
|
74
|
+
|--------------------------------------------------------------+--------------------------------------------------------------+-----------|
|
75
|
+
| current_user.png | current_user.png | FAIL |
|
76
|
+
| master_only.png | | -- |
|
77
|
+
| signed_in.png | signed_in.png | PASS |
|
78
|
+
| test_home.png | test_home.png | PASS |
|
79
|
+
| user.png | user.png | FAIL |
|
80
|
+
| | login_update_only.png | -- |
|
81
|
+
+-----------------------------------------------------------------------------------------------------------------------------------------+
|
82
|
+
| Results: 2 files were found to be different |
|
83
|
+
| Difference Files at /path/to/screenshots/diff |
|
84
|
+
+-----------------------------------------------------------------------------------------------------------------------------------------+
|
85
|
+
|
86
|
+
you can see here that not everything passed (or was exactly the same) in each test case. the `user` and `current_user` cases did not pass. to investigate why, you can look at the `diff` directory under `/path/to/screenshots/`. you will see what differences were found in each test case.
|
87
|
+
|
88
|
+
in addition, you can see that there were extra files in each data set. other comparisons are not affected.
|
89
|
+
|
90
|
+
### Rake Tasks
|
91
|
+
|
92
|
+
rake ojo:clear:all # clear all ojo files INCLUDING all data sets
|
93
|
+
rake ojo:clear:diff # clear ojo results only
|
94
|
+
rake ojo:compare[branch_1,branch_2] # use ojo to compare two branches
|
95
|
+
rake ojo:list # list ojo data sets
|
96
|
+
rake ojo:location # show ojo location setting
|
97
|
+
|
98
|
+
the `rake ojo:compare` task can be run without any arguments as well as explicitly stating the data sets/branch names. in this case, the first two valid data sets will be used.
|
99
|
+
|
100
|
+
## Contributing
|
101
|
+
|
102
|
+
1. Fork it ( https://github.com/QuantumGeordie/ojo/fork )
|
103
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
104
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
105
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
106
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
require 'ojo'
|
6
|
+
|
7
|
+
namespace :test do
|
8
|
+
desc 'unit tests'
|
9
|
+
Rake::TestTask.new :units do |t|
|
10
|
+
t.libs << '.'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
13
|
+
t.verbose = false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
task :test => [ 'test:units' ]
|
18
|
+
|
19
|
+
task :default => :test
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Ojo
|
2
|
+
require 'open4'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
def self.compare(branch_1, branch_2)
|
6
|
+
all_files = compile_file_lists(get_branch_files(branch_1), get_branch_files(branch_2))
|
7
|
+
|
8
|
+
FileUtils.mkdir_p(File.join(self.location, 'diff'))
|
9
|
+
|
10
|
+
all_same = true
|
11
|
+
results = { :location => self.location, :branch_1 => branch_1, :branch_2 => branch_2, :results => {} }
|
12
|
+
|
13
|
+
ProgressBar.start({:min => 0, :max => all_files.count, :method => :percent, :step_size => 1})
|
14
|
+
|
15
|
+
all_files.each do |file|
|
16
|
+
diff_file = File.join(self.location, 'diff', File.basename(file))
|
17
|
+
|
18
|
+
file_1 = File.join(location, branch_1, file)
|
19
|
+
file_2 = File.join(location, branch_2, file)
|
20
|
+
|
21
|
+
file_1 = nil unless File.exist?(file_1)
|
22
|
+
file_2 = nil unless File.exist?(file_2)
|
23
|
+
|
24
|
+
this_same = compare_one_set(file_1, file_2, diff_file)
|
25
|
+
results[:results][file] = { :same => this_same, :file_1 => file_1, :file_2 => file_2 }
|
26
|
+
all_same = all_same && (this_same != false)
|
27
|
+
|
28
|
+
File.delete(diff_file) if this_same
|
29
|
+
|
30
|
+
ProgressBar.increment
|
31
|
+
end
|
32
|
+
|
33
|
+
ProgressBar.complete
|
34
|
+
[all_same, results]
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def self.compare_one_set(file_1, file_2, diff_file)
|
40
|
+
same = nil
|
41
|
+
if file_1 && file_2
|
42
|
+
comparison_results = run_comparison(file_1, file_2, 'ae', '2%', diff_file)
|
43
|
+
same = unpack_comparison_results(comparison_results)
|
44
|
+
end
|
45
|
+
same
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.get_branch_files(branch_name)
|
49
|
+
Dir[File.join(self.location, branch_name, '*.png')].map{ |f| File.basename(f) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.compile_file_lists(files_1, files_2)
|
53
|
+
all_files = files_1.dup
|
54
|
+
all_files + files_2.select{ |f2| !files_1.include?(f2) }
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.unpack_comparison_results(packed)
|
58
|
+
return false if packed.include?('image widths or heights differ')
|
59
|
+
|
60
|
+
outputs = packed.split(/\n/)
|
61
|
+
|
62
|
+
outputs.map! do |o|
|
63
|
+
o.strip if o.strip.start_with?('red', 'green', 'blue', 'alpha', 'all')
|
64
|
+
end
|
65
|
+
outputs.compact!
|
66
|
+
|
67
|
+
same = true
|
68
|
+
|
69
|
+
outputs.each do |o|
|
70
|
+
parts = o.split(' ')
|
71
|
+
same = same && parts[1].to_f == 0
|
72
|
+
end
|
73
|
+
|
74
|
+
return same
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.run_comparison(file_1, file_2, metric, fuzz_factor, resulting_file)
|
78
|
+
imagemagick_command = "compare -verbose -metric #{metric} -fuzz #{fuzz_factor} #{file_1} #{file_2} #{resulting_file}"
|
79
|
+
|
80
|
+
output = nil
|
81
|
+
status = Open4::popen4(imagemagick_command) do |pid, stdin, stdout, stderr|
|
82
|
+
output = stderr.read
|
83
|
+
end
|
84
|
+
|
85
|
+
output
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ojo
|
2
|
+
@location = nil
|
3
|
+
|
4
|
+
def self.location=(location)
|
5
|
+
@location = location
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.location
|
9
|
+
@location
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get_data_sets_available
|
13
|
+
data_sets = []
|
14
|
+
if @location
|
15
|
+
data_sets = Dir[File.join(location, '*')].select{ |d| File.directory?(d) && File.basename(d) != 'diff' }.map{ |d| File.basename(d) }
|
16
|
+
end
|
17
|
+
data_sets
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.display_data_sets(data_sets)
|
21
|
+
puts '~'*20 + ' Ojo ' + '~'*20
|
22
|
+
puts 'Data sets that can be compared:'
|
23
|
+
data_sets.each{ |d| puts " #{d}"}
|
24
|
+
puts '~'*45
|
25
|
+
end
|
26
|
+
end
|
data/lib/ojo/output.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
module Ojo
|
2
|
+
def self.display_to_console(data)
|
3
|
+
format_table data
|
4
|
+
|
5
|
+
failure_count = 0
|
6
|
+
|
7
|
+
data[:results].each_key do |basename|
|
8
|
+
file_1 = file_basename(data[:results][basename][:file_1])
|
9
|
+
file_2 = file_basename(data[:results][basename][:file_2])
|
10
|
+
|
11
|
+
color = :blue
|
12
|
+
result_text = '--'
|
13
|
+
|
14
|
+
if test_performed?(data[:results][basename])
|
15
|
+
same = data[:results][basename][:same]
|
16
|
+
color = same ? :green : :red
|
17
|
+
result_text = same ? 'PASS' : 'FAIL'
|
18
|
+
failure_count += 1 unless same
|
19
|
+
end
|
20
|
+
|
21
|
+
one_row file_1, file_2, result_text, color
|
22
|
+
end
|
23
|
+
format_table_footer failure_count, data
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def self.format_table_footer(failure_count, data)
|
29
|
+
Table.footer(results_message(failure_count == 0, failure_count), :justification => :center)
|
30
|
+
Table.footer("Difference Files at #{File.join(data[:location], 'diff')}", :justification => :center)
|
31
|
+
|
32
|
+
Table.tabulate
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.file_basename(filename)
|
36
|
+
out = filename
|
37
|
+
out = File.basename(filename) unless out.nil?
|
38
|
+
out
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.test_performed?(data)
|
42
|
+
!data[:same].nil?
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.format_table_header(data)
|
46
|
+
Table.header("Ojo v.#{VERSION}")
|
47
|
+
Table.header("file location: #{data[:location]}")
|
48
|
+
Table.header(Date.today.strftime('%m/%d/%Y'))
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.format_table(data)
|
52
|
+
format_table_header data
|
53
|
+
|
54
|
+
Table.column(data[:branch_1], :width => 60, :padding => 2, :justification => :left)
|
55
|
+
Table.column(data[:branch_2], :width => 60, :padding => 2, :justification => :left)
|
56
|
+
Table.column('Results', :width => 11, :justification => :center)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.one_row(file_1, file_2, result_text, color)
|
60
|
+
max_printable_length = 50
|
61
|
+
|
62
|
+
formatted_file_1 = make_printable_name(file_1, max_printable_length)
|
63
|
+
formatted_file_2 = make_printable_name(file_2, max_printable_length)
|
64
|
+
|
65
|
+
row_data = [formatted_file_1, formatted_file_2, result_text]
|
66
|
+
Table.row(:data => row_data, :color => color)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.results_message(same, failure_count)
|
70
|
+
results_message = ['Results: ']
|
71
|
+
results_message << 'All Same' if same
|
72
|
+
results_message << "#{failure_count} file#{failure_count > 1 ? 's were' : ' was'} found to be different" unless same
|
73
|
+
results_message.join('')
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.make_printable_name(input, max_length)
|
77
|
+
output = input || ''
|
78
|
+
|
79
|
+
if output.length > max_length
|
80
|
+
how_much_too_long = output.length - max_length
|
81
|
+
center_of_string = output.length / 2
|
82
|
+
front_of_new_string = output[0..(center_of_string - how_much_too_long/2 - 3)]
|
83
|
+
back_of_new_string = output[(center_of_string + how_much_too_long/2 + 3)..output.length]
|
84
|
+
|
85
|
+
output = "#{front_of_new_string}....#{back_of_new_string}"
|
86
|
+
end
|
87
|
+
|
88
|
+
output
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ojo
|
2
|
+
|
3
|
+
@screenshotter = nil
|
4
|
+
|
5
|
+
def self.screenshotter=(screenshotter)
|
6
|
+
@screenshotter = screenshotter
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.screenshotter
|
10
|
+
@screenshotter
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.screenshot(group_name, base_name)
|
14
|
+
raise 'No screenshot method defined for Ojo.screenshoter!' unless @screenshotter
|
15
|
+
raise 'No screenshot location defined for Ojo.location!' unless @location
|
16
|
+
|
17
|
+
filename = File.join(location, group_name, "#{base_name}.png")
|
18
|
+
|
19
|
+
@screenshotter.call filename
|
20
|
+
end
|
21
|
+
end
|
data/lib/ojo/version.rb
ADDED
data/lib/ojo.rb
ADDED
data/lib/tasks/ojo.rake
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
namespace :ojo do
|
4
|
+
desc 'use ojo to compare two branches'
|
5
|
+
task :compare, [:branch_1, :branch_2] => :environment do |t, args|
|
6
|
+
branch_1 = args.fetch(:branch_1, nil)
|
7
|
+
branch_2 = args.fetch(:branch_2, nil)
|
8
|
+
|
9
|
+
unless branch_1 && branch_2
|
10
|
+
branches = Ojo.get_data_sets_available
|
11
|
+
unless branch_1
|
12
|
+
branches.each do |branch|
|
13
|
+
if branch != branch_2
|
14
|
+
branch_1 = branch
|
15
|
+
break
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
unless branch_2
|
21
|
+
branches.each do |branch|
|
22
|
+
if branch != branch_1
|
23
|
+
branch_2 = branch
|
24
|
+
break
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
results = Ojo.compare(branch_1, branch_2)
|
31
|
+
Ojo.display_to_console results[1]
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'show ojo location setting'
|
35
|
+
task :location => :environment do |t|
|
36
|
+
puts Ojo.location
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'list ojo data sets'
|
40
|
+
task :list => :environment do |t|
|
41
|
+
data_sets = Ojo.get_data_sets_available
|
42
|
+
Ojo.display_data_sets(data_sets)
|
43
|
+
end
|
44
|
+
|
45
|
+
namespace :clear do
|
46
|
+
desc 'clear ojo results only'
|
47
|
+
task :diff => :environment do |t|
|
48
|
+
FileUtils.rm_rf File.join(Ojo.location, 'diff')
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'clear all ojo files INCLUDING all data sets'
|
52
|
+
task :all => :environment do |t|
|
53
|
+
data_sets = Ojo.get_data_sets_available
|
54
|
+
FileUtils.rm_rf File.join(Ojo.location, 'diff')
|
55
|
+
data_sets.each { |d| FileUtils.rm_rf(File.join(Ojo.location, d)) }
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
data/ojo.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'ojo/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "ojo"
|
9
|
+
spec.version = Ojo::VERSION
|
10
|
+
spec.authors = ["geordie"]
|
11
|
+
spec.email = ["george.speake@gmail.com"]
|
12
|
+
spec.summary = %q{ojo is the eyes of the appearance test}
|
13
|
+
spec.description = %q{ojo will compare a few sets of screen shots and report results.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = []
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
|
25
|
+
spec.add_dependency 'collimator'
|
26
|
+
spec.add_dependency 'open4'
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '.'))
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'bundler'
|
9
|
+
|
10
|
+
begin
|
11
|
+
Bundler.setup(:default, :development)
|
12
|
+
rescue Bundler::BundlerError => e
|
13
|
+
$stderr.puts e.message
|
14
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
15
|
+
exit e.status_code
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'rails/all'
|
19
|
+
require 'ojo'
|
20
|
+
require 'test_app/test_app'
|
21
|
+
|
22
|
+
require 'minitest/autorun'
|
23
|
+
|
24
|
+
require 'awesome_print'
|
25
|
+
|
26
|
+
require 'capybara/dsl'
|
27
|
+
require 'capybara/rails'
|
28
|
+
require 'capybara/poltergeist'
|
29
|
+
|
30
|
+
require 'page_objects'
|
31
|
+
|
32
|
+
Capybara.default_driver = :poltergeist
|
33
|
+
Capybara.javascript_driver = :poltergeist
|
34
|
+
|
35
|
+
|
36
|
+
module OjoApp
|
37
|
+
class PhantomTestCase < Minitest::Test
|
38
|
+
include Capybara::DSL
|
39
|
+
|
40
|
+
def setup
|
41
|
+
Ojo.screenshotter = lambda do |filename|
|
42
|
+
page.save_screenshot(filename)
|
43
|
+
puts "Screenshot taken and saved to #{filename}"
|
44
|
+
end
|
45
|
+
Capybara.reset!
|
46
|
+
end
|
47
|
+
|
48
|
+
def teardown
|
49
|
+
Capybara.reset!
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def screenshot_path
|
55
|
+
File.join(Rails.root, 'tmp', 'screenshots')
|
56
|
+
end
|
57
|
+
|
58
|
+
def screenshot_file(name)
|
59
|
+
File.join(screenshot_path, branch_name, "#{name}.png")
|
60
|
+
end
|
61
|
+
|
62
|
+
def branch_name
|
63
|
+
`git rev-parse --abbrev-ref HEAD`.chomp
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|