compatriot 0.0.5 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e100d57f0086c254d7fcd46b1d615dc3ec7570a1
4
- data.tar.gz: 3a474ae56359208e474ea4742b3092797e9a13e4
3
+ metadata.gz: b42a702d988c48093abc7cd8fe13b09d02f3943b
4
+ data.tar.gz: a7c9af901dc60c45d98b18a798fc5f2d81ecdac7
5
5
  SHA512:
6
- metadata.gz: 1f712342dfd796f65140fadb0251325d2e44f91d698f3c58859b721b010f3ca9ddd538ff0c8eb8275860b928ddeb2bf046c46c6cca9f6c16cfc63cfce7e91c53
7
- data.tar.gz: bed0d7c8323e728fa30cadbb044b9ebe8e92829978da39516f7396fa650c91e4cf2b06a402dd0a20f8d50437cb7702438d65a19d0888bb63822875e1097b18fa
6
+ metadata.gz: 5f179d47804b164b070ae0b94e3d7fbe08757e4e9e8b797147e4d6dd2852347b8d26657af4bfe58d33b89577d61c06cadb066e70f34afa50af544f27df5b2d22
7
+ data.tar.gz: 08f1c1500a97095a027b3330ea2c0329e4f3f55012f6f1cac52549cb9f5248806940ae832751d164e4fc620117ccb014be6773cf2d4bc1e216af9af02decc433
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ tmp
18
18
  .DS_STORE
19
19
  spec/sample_app/chromedriver.log
20
20
  TAGS
21
+ screenshots
data/.travis.yml CHANGED
@@ -1,4 +1,13 @@
1
- before_script: "sh -e /etc/init.d/xvfb start && sudo add-apt-repository ppa:chromium-daily/dev && sudo aptitude update && sudo aptitude -y -q install unzip chromium-browser"
2
- script: "bundle exec rake travis"
1
+ before_script:
2
+ - "mkdir -p /tmp/bin"
3
+ - "cd /tmp/bin && wget http://chromium.googlecode.com/files/chromedriver_linux32_16.0.902.0.zip && unzip chromedriver_linux32_16.0.902.0.zip && cd -"
4
+ - "export PATH=/tmp/bin:$PATH "
5
+ - "export DISPLAY=:99.0"
6
+ - "sh -e /etc/init.d/xvfb start"
7
+ - sleep 3 # give xvfb some time to start
8
+ script: "bundle exec rake test"
3
9
  rvm:
4
10
  - 2.1.7
11
+ - 2.2.4
12
+ sudo: false
13
+
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  Compatriot
2
2
  ==========
3
- [![Build Status](https://secure.travis-ci.org/clnclarinet/compatriot.png?branch=master)](http://travis-ci.org/clnclarinet/compatriot)
3
+ [![Build Status](https://secure.travis-ci.org/carols10cents/compatriot.png?branch=master)](http://travis-ci.org/carols10cents/compatriot)
4
4
 
5
5
  **Compat**ibility + **riot**! It's the **friend** that helps with browser compatibility!
6
6
  This Ruby gem makes cross-browser testing less painful.
data/Rakefile CHANGED
@@ -14,13 +14,3 @@ desc "Run tests"
14
14
  task :spec do
15
15
  task("test").execute
16
16
  end
17
-
18
- task :travis do
19
- puts "Grabbing chromedriver..."
20
- mkdir_p "/tmp/bin"
21
- system "cd /tmp/bin && wget http://chromium.googlecode.com/files/chromedriver_linux32_16.0.902.0.zip && unzip chromedriver_linux32_16.0.902.0.zip"
22
-
23
- puts "Starting to run tests..."
24
- system("export PATH=/tmp/bin:$PATH && export DISPLAY=:99.0 && bundle exec rake test && bundle exec cucumber features")
25
- raise "`rake test` failed!" unless $?.exitstatus == 0
26
- end
data/bin/colordiff ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/compatriot/image_differ/color_differ'
4
+
5
+ Compatriot::ColorDiffer.diff_to_file(ARGV[0], ARGV[1], ARGV[2])
data/compatriot.gemspec CHANGED
@@ -2,15 +2,14 @@
2
2
  require File.expand_path('../lib/compatriot/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Carol Nichols"]
6
- gem.email = ["carol.nichols@gmail.com"]
7
- gem.description = 'Finds likely UI browser cross-compatibility issues.'
5
+ gem.authors = ["Carol (Nichols || Goulding)", "Jeff Koenig"]
6
+ gem.email = ["carol.nichols@gmail.com", "jkoenig311@gmail.com"]
7
+ gem.description = 'Compare screenshots in your tests!'
8
8
  gem.summary = %q{
9
- Runs a command in multiple browsers using selenium then compares the
10
- screenshots and presents those likely to have cross-browser incompatibilities.
9
+ Add assertions that screenshots taken during your tests do not differ from a base image. Test that the page looks the same as the last test run or that the page looks the same in multiple browsers!
11
10
  }
12
11
 
13
- gem.homepage = "https://github.com/clnclarinet/compatriot"
12
+ gem.homepage = "https://github.com/carols10cents/compatriot"
14
13
 
15
14
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
15
  gem.files = `git ls-files`.split("\n")
@@ -23,12 +22,11 @@ Gem::Specification.new do |gem|
23
22
  gem.add_development_dependency 'minitest', '~> 5.8', '>= 5.8.2'
24
23
  gem.add_development_dependency 'sinatra', '~> 1.4', '>= 1.4.6'
25
24
  gem.add_development_dependency 'mocha', '~> 1.1', '>= 1.1.0'
26
- gem.add_development_dependency 'cucumber', '~> 2.1', '>= 2.1.0'
27
- gem.add_development_dependency 'aruba', '~> 0.10.0'
28
- gem.add_development_dependency 'relish', '~> 0.7.1'
25
+ gem.add_development_dependency 'pry'
29
26
 
30
27
  gem.add_runtime_dependency 'capybara', '~> 2.5', '>= 2.5.0'
31
28
  gem.add_runtime_dependency 'selenium-webdriver', '~> 2.48', '>= 2.48.1'
32
29
  gem.add_runtime_dependency 'rake', '~> 10.4', '>= 10.4.2'
33
30
  gem.add_runtime_dependency 'chunky_png', '~> 1.3', '>= 1.3.5'
31
+ gem.add_runtime_dependency 'oily_png', '~> 1.2.0'
34
32
  end
data/lib/compatriot.rb CHANGED
@@ -6,10 +6,51 @@ require "compatriot/image_differ/image_differ"
6
6
 
7
7
  module Compatriot
8
8
  class << self
9
- attr_accessor :app
9
+ attr_accessor :app, :screenshot_directory
10
+
11
+ def configure
12
+ yield self
13
+ end
10
14
 
11
15
  def run(paths)
12
16
  Compatriot::Runner.start(app, paths)
13
17
  end
18
+
19
+ def take_screenshot(page, test, description)
20
+ filename = filename_for_test(test, description)
21
+ control_image_path = filepath_for_screenshot('control', filename)
22
+ variable_image_path = filepath_for_screenshot('variable', filename)
23
+
24
+ if File.exist?(control_image_path)
25
+ screenshot_type = 'variable'
26
+ else
27
+ screenshot_type = 'control'
28
+ end
29
+ temp = page.save_screenshot filepath_for_screenshot(screenshot_type, filename)
30
+ end
31
+
32
+ def percentage_changed(page, test, description = '')
33
+ variable_img_path = take_screenshot(page, test, description)
34
+ control_img_path = filepath_for_screenshot('control', filename_for_test(test, description))
35
+ diff = Compatriot::ColorDiffer.diff(variable_img_path, control_img_path, self.screenshot_directory + '/')
36
+ variable_image = ChunkyPNG::Image.from_file(variable_img_path)
37
+ Compatriot::ColorDiffer.color_difference_percentage(variable_image, diff)
38
+ end
39
+
40
+ def filename_for_test(test, description)
41
+ test_name = test.name.match(/test_[0-9]+_(.*)/)[1]
42
+ class_name = test.class.name
43
+ filename = class_name + '_' + test_name
44
+ filename += '_' + description unless description.empty?
45
+ filename.tr(' ', '_').downcase + '.png'
46
+ end
47
+
48
+ def filepath_for_screenshot(type, filename)
49
+ File.expand_path(self.screenshot_directory + '/' + type + '/' + filename)
50
+ end
51
+ end
52
+
53
+ Compatriot.configure do |config|
54
+ config.screenshot_directory = './compatriot/screenshots'
14
55
  end
15
- end
56
+ end
@@ -1,9 +1,28 @@
1
- require 'chunky_png'
1
+ require 'oily_png'
2
2
  include ChunkyPNG::Color
3
3
 
4
4
  module Compatriot
5
5
  class ColorDiffer
6
6
 
7
+ def self.diff_to_file(filename1, filename2, output_filename)
8
+ image1 = ChunkyPNG::Image.from_file(filename1)
9
+ image2 = ChunkyPNG::Image.from_file(filename2)
10
+
11
+ output = ChunkyPNG::Image.new(image1.width, image1.height, WHITE)
12
+ diff = []
13
+
14
+ each_pixel(image1) do |x, y|
15
+ pixel1 = image1[x,y]
16
+ pixel2 = image2[x,y]
17
+ unless pixel1 == pixel2
18
+ output[x,y], score = color_difference_of_pixels(pixel1, pixel2)
19
+ diff << score
20
+ end
21
+ end
22
+
23
+ output.save(output_filename)
24
+ end
25
+
7
26
  def self.diff(filename1, filename2, results_directory)
8
27
  image1 = ChunkyPNG::Image.from_file(filename1)
9
28
  image2 = ChunkyPNG::Image.from_file(filename2)
@@ -22,6 +41,8 @@ module Compatriot
22
41
  end
23
42
 
24
43
  save_diff_image(output, filename1, filename2)
44
+
45
+ diff
25
46
  end
26
47
 
27
48
  def self.save_diff_image(output, filename1, filename2)
@@ -31,10 +52,16 @@ module Compatriot
31
52
  "diffs",
32
53
  filename
33
54
  )
55
+ create_directory_if_necessary(path)
34
56
  output.save(path)
35
57
  File.join("diffs", filename)
36
58
  end
37
59
 
60
+ def self.create_directory_if_necessary(file)
61
+ dir = File.dirname(file)
62
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
63
+ end
64
+
38
65
  def self.diff_name(image1, image2)
39
66
  browser1 = File.basename(File.dirname(image1))
40
67
  browser2 = File.basename(File.dirname(image2))
@@ -53,10 +80,9 @@ module Compatriot
53
80
  end
54
81
 
55
82
  # Not called anywhere
56
- def color_difference_total_score
57
- pixels_total = image1.width * image1.height
58
- pixels_changed = diff.length
59
- pixels_changed_percentage = (diff.inject {|sum, value| sum + value} / pixels_total) * 100
83
+ def self.color_difference_percentage(image, diff)
84
+ return 0 if diff.length == 0
85
+ (diff.reduce(:+) / image.pixels.length) * 100
60
86
  end
61
87
 
62
88
  def self.each_pixel(image)
@@ -67,4 +93,4 @@ module Compatriot
67
93
  end
68
94
  end
69
95
  end
70
- end
96
+ end
@@ -1,3 +1,3 @@
1
1
  module Compatriot
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/images/1.png ADDED
Binary file
data/spec/images/2.png ADDED
Binary file
@@ -0,0 +1,91 @@
1
+ require_relative '../spec_helper'
2
+ require 'pry'
3
+
4
+ describe Compatriot do
5
+ let(:class_stub) { stub_everything('class', name: 'important_test') }
6
+ let(:stubbed_test) { stub_everything('test', name: 'test_001_will do something important', class: class_stub) }
7
+ let(:page) { Page.new }
8
+
9
+ SCREENSHOTS_DIR = './tmp/test/screenshots'
10
+ CONTROL_IMG_FILENAME = 'important_test_will_do_something_important_and_has_a_description.png'
11
+ CONTROL_IMG = "#{SCREENSHOTS_DIR}/control/#{CONTROL_IMG_FILENAME}"
12
+ CONTROL_IMG2 = "#{SCREENSHOTS_DIR}/control/important_test_will_do_something_important_another.png"
13
+ VARIABLE_IMG = "#{SCREENSHOTS_DIR}/variable/important_test_will_do_something_important_and_has_a_description.png"
14
+ DIFF_IMG = "#{SCREENSHOTS_DIR}/diffs/color_variable_vs_control_important_test_will_do_something_important_and_has_a_description.png"
15
+
16
+ class Page
17
+ def save_screenshot filepath
18
+ root_dir = File.join(File.dirname(__FILE__), '../')
19
+ image_name = filepath.include?('control') ? '1' : '2'
20
+ src_img = root_dir + "/images/#{image_name}.png"
21
+ filepath_dir = File.dirname(filepath)
22
+ FileUtils.mkdir_p(filepath_dir) unless File.directory?(filepath_dir)
23
+ FileUtils.cp(src_img, filepath)
24
+ filepath
25
+ end
26
+ end
27
+
28
+ def setup_control_image
29
+ Page.new.save_screenshot CONTROL_IMG
30
+ end
31
+
32
+ before do
33
+ FileUtils.remove_dir(SCREENSHOTS_DIR) if File.directory?(SCREENSHOTS_DIR)
34
+ Compatriot.configure do |config|
35
+ config.screenshot_directory = SCREENSHOTS_DIR
36
+ end
37
+ end
38
+
39
+ describe 'no control image is found' do
40
+ it 'it will create one' do
41
+ Compatriot.take_screenshot(page, stubbed_test, 'and has a description')
42
+ Compatriot.take_screenshot(page, stubbed_test, 'another')
43
+
44
+ assert File.exist?(CONTROL_IMG), 'control image not found'
45
+ assert File.exist?(CONTROL_IMG2), 'control image not found'
46
+ end
47
+ end
48
+
49
+ describe 'control image is found' do
50
+ before do
51
+ setup_control_image
52
+ end
53
+
54
+ it 'stores a variable image' do
55
+ Compatriot.take_screenshot(page, stubbed_test, 'and has a description')
56
+ assert File.exist?(VARIABLE_IMG)
57
+ end
58
+
59
+ it 'stores the image difference' do
60
+ Compatriot.percentage_changed(page, stubbed_test, 'and has a description')
61
+ assert File.exist?(DIFF_IMG)
62
+ end
63
+
64
+ it 'returns the percentage difference' do
65
+ result = Compatriot.percentage_changed(page, stubbed_test, 'and has a description')
66
+ assert_equal(0.81, result.round(2))
67
+ end
68
+
69
+ it 'returns 0 % if there is no difference' do
70
+ Compatriot::ColorDiffer.stubs(:diff).returns([])
71
+ result = Compatriot.percentage_changed(page, stubbed_test, 'and has a description')
72
+ assert_equal(0.0, result.round(2))
73
+ end
74
+ end
75
+
76
+ describe 'configuration' do
77
+ before do
78
+ @screenshot_directory = 'tmp/test_configuration'
79
+ @control_file = @screenshot_directory + '/control/' + CONTROL_IMG_FILENAME
80
+ Compatriot.configure do |config|
81
+ config.screenshot_directory = @screenshot_directory
82
+ end
83
+ FileUtils.remove_dir(@screenshot_directory) if File.directory?(SCREENSHOTS_DIR)
84
+ end
85
+
86
+ it 'can set the screenshot directory' do
87
+ Compatriot.take_screenshot(page, stubbed_test, 'and has a description')
88
+ assert File.exist?(@control_file), 'control image not found'
89
+ end
90
+ end
91
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compatriot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Carol Nichols
7
+ - Carol (Nichols || Goulding)
8
+ - Jeff Koenig
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-11-04 00:00:00.000000000 Z
12
+ date: 2016-01-05 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: minitest
@@ -71,53 +72,19 @@ dependencies:
71
72
  - !ruby/object:Gem::Version
72
73
  version: 1.1.0
73
74
  - !ruby/object:Gem::Dependency
74
- name: cucumber
75
+ name: pry
75
76
  requirement: !ruby/object:Gem::Requirement
76
77
  requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '2.1'
80
78
  - - ">="
81
79
  - !ruby/object:Gem::Version
82
- version: 2.1.0
80
+ version: '0'
83
81
  type: :development
84
82
  prerelease: false
85
83
  version_requirements: !ruby/object:Gem::Requirement
86
84
  requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '2.1'
90
85
  - - ">="
91
86
  - !ruby/object:Gem::Version
92
- version: 2.1.0
93
- - !ruby/object:Gem::Dependency
94
- name: aruba
95
- requirement: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: 0.10.0
100
- type: :development
101
- prerelease: false
102
- version_requirements: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - "~>"
105
- - !ruby/object:Gem::Version
106
- version: 0.10.0
107
- - !ruby/object:Gem::Dependency
108
- name: relish
109
- requirement: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: 0.7.1
114
- type: :development
115
- prerelease: false
116
- version_requirements: !ruby/object:Gem::Requirement
117
- requirements:
118
- - - "~>"
119
- - !ruby/object:Gem::Version
120
- version: 0.7.1
87
+ version: '0'
121
88
  - !ruby/object:Gem::Dependency
122
89
  name: capybara
123
90
  requirement: !ruby/object:Gem::Requirement
@@ -198,10 +165,26 @@ dependencies:
198
165
  - - ">="
199
166
  - !ruby/object:Gem::Version
200
167
  version: 1.3.5
201
- description: Finds likely UI browser cross-compatibility issues.
168
+ - !ruby/object:Gem::Dependency
169
+ name: oily_png
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: 1.2.0
175
+ type: :runtime
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: 1.2.0
182
+ description: Compare screenshots in your tests!
202
183
  email:
203
184
  - carol.nichols@gmail.com
204
- executables: []
185
+ - jkoenig311@gmail.com
186
+ executables:
187
+ - colordiff
205
188
  extensions: []
206
189
  extra_rdoc_files: []
207
190
  files:
@@ -213,11 +196,9 @@ files:
213
196
  - Gemfile
214
197
  - README.md
215
198
  - Rakefile
199
+ - bin/colordiff
216
200
  - compatriot.gemspec
217
201
  - examples/compatriot_tests.rb
218
- - features/list_of_urls.feature
219
- - features/step_definitions/cli_steps.rb
220
- - features/support/env.rb
221
202
  - lib/compatriot.rb
222
203
  - lib/compatriot/browser.rb
223
204
  - lib/compatriot/image_differ/color_differ.rb
@@ -225,14 +206,17 @@ files:
225
206
  - lib/compatriot/results_presenter.rb
226
207
  - lib/compatriot/runner.rb
227
208
  - lib/compatriot/version.rb
209
+ - spec/images/1.png
210
+ - spec/images/2.png
228
211
  - spec/sample_app/public/images/smileyface.jpg
229
212
  - spec/sample_app/sample_app.rb
230
213
  - spec/spec_helper.rb
231
214
  - spec/unit/browser_spec.rb
215
+ - spec/unit/compatriot_spec.rb
232
216
  - spec/unit/image_differ/color_differ_spec.rb
233
217
  - spec/unit/image_differ/image_differ_spec.rb
234
218
  - spec/unit/runner_spec.rb
235
- homepage: https://github.com/clnclarinet/compatriot
219
+ homepage: https://github.com/carols10cents/compatriot
236
220
  licenses:
237
221
  - MIT
238
222
  metadata: {}
@@ -255,16 +239,17 @@ rubyforge_project:
255
239
  rubygems_version: 2.4.8
256
240
  signing_key:
257
241
  specification_version: 4
258
- summary: Runs a command in multiple browsers using selenium then compares the screenshots
259
- and presents those likely to have cross-browser incompatibilities.
242
+ summary: Add assertions that screenshots taken during your tests do not differ from
243
+ a base image. Test that the page looks the same as the last test run or that the
244
+ page looks the same in multiple browsers!
260
245
  test_files:
261
- - features/list_of_urls.feature
262
- - features/step_definitions/cli_steps.rb
263
- - features/support/env.rb
246
+ - spec/images/1.png
247
+ - spec/images/2.png
264
248
  - spec/sample_app/public/images/smileyface.jpg
265
249
  - spec/sample_app/sample_app.rb
266
250
  - spec/spec_helper.rb
267
251
  - spec/unit/browser_spec.rb
252
+ - spec/unit/compatriot_spec.rb
268
253
  - spec/unit/image_differ/color_differ_spec.rb
269
254
  - spec/unit/image_differ/image_differ_spec.rb
270
255
  - spec/unit/runner_spec.rb
@@ -1,31 +0,0 @@
1
- Feature: list_of_urls
2
-
3
- Passing a list of URLs to Compatriot.run will visit each of them in each browser and take a screenshot.
4
-
5
- Scenario: List of URLs
6
- Given a Sinatra app named "simple_app.rb" with:
7
- """ruby
8
- get '/' do
9
- 'Hello'
10
- end
11
-
12
- get '/goodbye' do
13
- 'Goodbye'
14
- end
15
- """
16
- And a file named "compatriot_urls.rb" with:
17
- """ruby
18
- $:.unshift(File.expand_path('../../lib', File.dirname(__FILE__)))
19
- require 'compatriot'
20
- require_relative 'simple_app'
21
- Compatriot.app = SimpleApp
22
- Compatriot.run(%w[
23
- /
24
- /goodbye
25
- ])
26
-
27
- """
28
- And the directory "tmp/results" does not exist
29
- When I run `ruby compatriot_urls.rb`
30
- Then "tmp/results" should have 1 subdirectory
31
- And there should be results for 2 screenshots
@@ -1,60 +0,0 @@
1
- module CompatriotHelpers
2
- def create_sinatra_app(file_name, content)
3
- app_class = camelize(file_name.gsub(/\.rb$/, ''))
4
- beginning_sinatra_app = <<-HERE
5
- require 'sinatra/base'
6
- require 'rack'
7
- require 'yaml'
8
-
9
- class #{app_class} < Sinatra::Base
10
- set :root, File.dirname(__FILE__)
11
- set :static, true
12
- HERE
13
-
14
- ending_sinatra_app = <<-HERE
15
-
16
- end
17
-
18
- if __FILE__ == $0
19
- Rack::Handler::WEBrick.run #{app_class}, :Port => 8070
20
- end
21
- HERE
22
- beginning_sinatra_app + content + ending_sinatra_app
23
- end
24
-
25
- def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
26
- if first_letter_in_uppercase
27
- lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
28
- else
29
- lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1]
30
- end
31
- end
32
- end
33
- World(CompatriotHelpers)
34
-
35
- Given /^a Sinatra app named "([^"]*)" with:$/ do |file_name, content|
36
- write_file(file_name, create_sinatra_app(file_name, content))
37
- end
38
-
39
- Then /^"([^"]*)" should have (\d+) subdir/ do |directory, subdirectory_count|
40
- cd('.') {
41
- expect((Dir.entries(directory) - [".", ".."]).size).to eql subdirectory_count.to_i
42
- }
43
- end
44
-
45
- Then /^there should be results for (\d+) screenshots?$/ do |screenshot_count|
46
- screenshot_count = screenshot_count.to_i
47
- results_tmp_dir = "tmp/results"
48
- cd('.') {
49
- current_results_dir = (Dir.entries(results_tmp_dir) - [".", ".."]).first
50
- current_results_dir = File.join(results_tmp_dir, current_results_dir)
51
-
52
- firefox_dir = File.join(current_results_dir, "firefox")
53
- chrome_dir = File.join(current_results_dir, "chrome")
54
- diffs_dir = File.join(current_results_dir, "diffs")
55
-
56
- expect(Dir.glob(File.join(firefox_dir, "*.png")).size).to eql 2
57
- expect(Dir.glob(File.join(chrome_dir, "*.png")).size).to eql 2
58
- expect(Dir.glob(File.join(diffs_dir, "*.png")).size).to eql 2
59
- }
60
- end
@@ -1,5 +0,0 @@
1
- require 'aruba/cucumber'
2
-
3
- Aruba.configure do |config|
4
- config.exit_timeout = 60
5
- end