gatling 1.1.2 → 1.1.3
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 +1 -0
- data/README.rdoc +32 -11
- data/gatling.gemspec +1 -2
- data/lib/gatling.rb +30 -35
- data/lib/gatling/capture_element.rb +14 -18
- data/lib/gatling/configuration.rb +67 -0
- data/lib/gatling/image.rb +31 -12
- data/lib/gatling/version.rb +2 -1
- data/spec/acceptance/gatling_acceptance_spec.rb +3 -12
- data/spec/acceptance/rspec_matcher_spec.rb +2 -2
- data/spec/capture_spec.rb +15 -71
- data/spec/comparison_spec.rb +0 -4
- data/spec/configuration_spec.rb +53 -25
- data/spec/gatling_spec.rb +46 -53
- data/spec/image_spec.rb +60 -80
- data/spec/integration/gatling_integration_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +62 -25
- data/lib/gatling/config.rb +0 -84
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -28,19 +28,22 @@ Also created are subfolders:
|
|
28
28
|
- /diff - will hold the diff images generated by failed comparison tests
|
29
29
|
- /temp - will only ever hold one screenshot at a time, used to create the cropped element
|
30
30
|
|
31
|
-
|
31
|
+
==== max_no_tries
|
32
|
+
- sets how many times Gatling will try and match the element against the reference image. Handy to reduce fragility of tests due to animations and load times. Defaults to 5.
|
32
33
|
|
33
|
-
|
34
|
+
==== Sleep_between_tries
|
35
|
+
- sets the sleep time (in seconds) between match tries (requires max_no_tries > 1). Defaults to 0.5
|
34
36
|
|
35
|
-
|
37
|
+
==== browser_folders
|
38
|
+
- *Currently only available with Selenium-Webdriver / Capybara* - create reference folders based on the current Selenium driver's browser. Allows for cross-browser visual testing.
|
36
39
|
|
37
|
-
|
40
|
+
==== Configuration settings are set with the following:
|
38
41
|
|
39
|
-
Gatling.config do |
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
Gatling.config do |c|
|
43
|
+
c.reference_image_path = 'some/path'
|
44
|
+
c.max_no_tries = 4
|
45
|
+
c.sleep_between_tries = 5
|
46
|
+
c.browser_folders = false
|
44
47
|
end
|
45
48
|
|
46
49
|
GATLING::CONFIGURATION will be depreciated in future versions.
|
@@ -59,8 +62,26 @@ Gatling will take care of cropping the element and try and make a targeted match
|
|
59
62
|
|
60
63
|
If the matcher fails, the test will fail, an exception will be raised and both a diff image and a new candidate image will be created.
|
61
64
|
|
62
|
-
If no reference image exits, the test will
|
63
|
-
|
65
|
+
If no reference image exits, the test will still pass and a reference file will be created for future comparisons.
|
66
|
+
|
67
|
+
-------------------------------------
|
68
|
+
|
69
|
+
=== Training mode:
|
70
|
+
|
71
|
+
<b>GATLING_TRAINER WILL BE DEPRECIATED.</b> Gatling now saves reference files natively when files do not exists.
|
72
|
+
|
73
|
+
Gatling can be run in training mode which will create reference images where ones do not exist.
|
74
|
+
|
75
|
+
<b>CAUTION: Trainer mode will pass all the test which rely on the Gatling custom matcher, this can mean a false green build.
|
76
|
+
Please make sure you are saving 'clean' references</b>
|
77
|
+
|
78
|
+
Trainer mode will not overwrite existing references. If you are updating, just delete the old reference image.
|
79
|
+
|
80
|
+
To set trainer mode, prefix rspec command line with $GATLING_TRAINER = true
|
81
|
+
|
82
|
+
|
83
|
+
Example:
|
84
|
+
$GATLING_TRAINER = true rspec spec/my_spec.rb
|
64
85
|
|
65
86
|
-------------------------------------
|
66
87
|
|
data/gatling.gemspec
CHANGED
@@ -19,8 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_runtime_dependency('rmagick', ['>=2.13.1'])
|
22
|
-
s.add_runtime_dependency('rspec
|
23
|
-
s.add_runtime_dependency('rspec',['>=2.8.0'])
|
22
|
+
s.add_runtime_dependency('rspec',['>=2.9.0'])
|
24
23
|
s.add_runtime_dependency('capybara',['>=1.1.2'])
|
25
24
|
|
26
25
|
s.add_development_dependency('rake',['>=0.9.2'])
|
data/lib/gatling.rb
CHANGED
@@ -2,7 +2,7 @@ require 'RMagick'
|
|
2
2
|
require 'capybara'
|
3
3
|
require 'capybara/dsl'
|
4
4
|
|
5
|
-
require 'gatling/
|
5
|
+
require 'gatling/configuration'
|
6
6
|
require 'gatling/image'
|
7
7
|
require 'gatling/comparison'
|
8
8
|
require 'gatling/capture_element'
|
@@ -12,51 +12,45 @@ require 'gatling/capture_element'
|
|
12
12
|
#TODO: Make directories as needed
|
13
13
|
|
14
14
|
module Gatling
|
15
|
-
|
16
15
|
class << self
|
17
16
|
|
18
|
-
attr_accessor :reference_image_path, :max_no_tries, :sleep_between_tries, :browser_folders
|
19
|
-
|
20
17
|
def matches?(expected_reference_filename, actual_element)
|
18
|
+
|
19
|
+
@actual_element = actual_element
|
20
|
+
@expected_reference_filename = expected_reference_filename
|
21
|
+
@expected_reference_file = (File.join(Gatling::Configuration.path(:reference), expected_reference_filename))
|
21
22
|
|
22
|
-
expected_reference_file = (File.join(Gatling::Configuration.path(:reference), expected_reference_filename))
|
23
|
-
|
24
|
-
if ENV['GATLING_TRAINER']
|
25
|
-
raise 'GATLING_TRAINER has been depreciated. Gatling will now create reference files where ones are missing. Delete bad references and re-run Gatling to re-train'
|
26
|
-
end
|
27
23
|
|
28
|
-
if !File.exists?(expected_reference_file)
|
29
|
-
|
30
|
-
save_image_as_reference(actual_image)
|
24
|
+
if !File.exists?(@expected_reference_file)
|
25
|
+
save_reference
|
31
26
|
return true
|
32
27
|
else
|
33
|
-
|
28
|
+
reference_file = Gatling::ImageFromFile.new(expected_reference_filename)
|
29
|
+
comparison = compare_until_match(actual_element, reference_file, Gatling::Configuration.max_no_tries)
|
34
30
|
matches = comparison.matches?
|
35
31
|
if !matches
|
36
32
|
comparison.actual_image.save(:candidate)
|
37
33
|
save_image_as_diff(comparison.diff_image)
|
38
34
|
end
|
39
|
-
matches
|
35
|
+
matches
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
43
|
-
def compare_until_match actual_element,
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
while !match && try < max_no_tries
|
49
|
-
actual_image = Gatling::ImageFromElement.new(actual_element, expected_reference_filename)
|
50
|
-
comparison = Gatling::Comparison.new(actual_image, expected_image)
|
51
|
-
match = comparison.matches?
|
39
|
+
def compare_until_match actual_element, reference_file, max_no_tries = Gatling::Configuration.max_no_tries, sleep_time = Gatling::Configuration.sleep_between_tries
|
40
|
+
max_no_tries.times do |i|
|
41
|
+
actual_image = Gatling::ImageFromElement.new(actual_element, reference_file.file_name)
|
42
|
+
@comparison = Gatling::Comparison.new(actual_image, reference_file)
|
43
|
+
match = @comparison.matches?
|
52
44
|
if !match
|
53
45
|
sleep sleep_time
|
54
|
-
try += 1
|
55
46
|
#TODO: Send to logger instead of puts
|
56
|
-
|
47
|
+
i += 1
|
48
|
+
puts "Tried to match #{i} times"
|
49
|
+
else
|
50
|
+
return(@comparison)
|
57
51
|
end
|
58
52
|
end
|
59
|
-
comparison
|
53
|
+
@comparison
|
60
54
|
end
|
61
55
|
|
62
56
|
def save_image_as_diff(image)
|
@@ -72,17 +66,18 @@ module Gatling
|
|
72
66
|
"is now available to be used as a reference. Copy candidate to root reference_image_path to use as reference"
|
73
67
|
end
|
74
68
|
|
75
|
-
def
|
76
|
-
|
77
|
-
puts "#{image.path} already exists. reference image was not overwritten. please delete the old file to update reference"
|
78
|
-
else
|
79
|
-
image.save(:reference)
|
80
|
-
puts "Saved #{image.path} as reference"
|
81
|
-
end
|
69
|
+
def save_reference
|
70
|
+
ImageFromElement.new(@actual_element,@expected_reference_filename).verify_and_save
|
82
71
|
end
|
83
72
|
|
84
|
-
def config
|
85
|
-
|
73
|
+
def config(&block)
|
74
|
+
begin
|
75
|
+
config_class = Gatling::Configuration
|
76
|
+
raise "No block provied" unless block_given?
|
77
|
+
block.call(config_class)
|
78
|
+
rescue
|
79
|
+
raise "Config block has changed. Example: Gatling.config {|c| c.reference_image_path = 'some/path'}. Please see README"
|
80
|
+
end
|
86
81
|
end
|
87
82
|
|
88
83
|
end
|
@@ -1,27 +1,23 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'gatling'
|
2
3
|
|
3
4
|
module Gatling
|
4
|
-
|
5
|
+
module CaptureElement
|
6
|
+
extend Gatling::Configuration
|
5
7
|
|
6
|
-
def
|
7
|
-
@reference_image_path = Gatling::Configuration.reference_image_path
|
8
|
-
@element_to_capture = element_to_capture
|
9
|
-
# @element_to_exclude = element_to_exclude.first
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def capture
|
8
|
+
def self.capture(element)
|
14
9
|
# Getting the element position before screenshot because of a side effect
|
15
10
|
# of WebDrivers getLocationOnceScrolledIntoView method which scrolls the page
|
16
11
|
# regardless of whether the object is in view or not
|
17
|
-
element_position = get_element_position
|
18
|
-
screenshot =
|
19
|
-
|
20
|
-
crop_element(screenshot,
|
12
|
+
element_position = get_element_position(element)
|
13
|
+
screenshot = take_screenshot
|
14
|
+
|
15
|
+
crop_element(screenshot, element, element_position)
|
21
16
|
end
|
22
17
|
|
23
|
-
|
24
|
-
|
18
|
+
private
|
19
|
+
def self.take_screenshot
|
20
|
+
temp_dir = Gatling::Configuration.path(:temp)
|
25
21
|
FileUtils.mkdir_p(temp_dir) unless File.exists?(temp_dir)
|
26
22
|
#captures the uncropped full screen
|
27
23
|
begin
|
@@ -33,7 +29,7 @@ module Gatling
|
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
36
|
-
def get_element_position element
|
32
|
+
def self.get_element_position element
|
37
33
|
element = element.native
|
38
34
|
position = Hash.new{}
|
39
35
|
position[:x] = element.location.x
|
@@ -43,8 +39,8 @@ module Gatling
|
|
43
39
|
position
|
44
40
|
end
|
45
41
|
|
46
|
-
def crop_element image, element_to_crop, position
|
47
|
-
|
42
|
+
def self.crop_element image, element_to_crop, position
|
43
|
+
cropped_element = image.crop(position[:x], position[:y], position[:width], position[:height])
|
48
44
|
end
|
49
45
|
|
50
46
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Gatling
|
4
|
+
module Configuration
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
attr_accessor :reference_image_path, :max_no_tries, :sleep_between_tries, :browser_folders
|
9
|
+
|
10
|
+
attr_reader :paths
|
11
|
+
|
12
|
+
def reference_image_path
|
13
|
+
@reference_image_path ||= default_reference_path
|
14
|
+
@browser_folders ? (reference_path_with_browser_folders) : @reference_image_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def max_no_tries
|
18
|
+
@max_no_tries ||= 5
|
19
|
+
end
|
20
|
+
|
21
|
+
def sleep_between_tries
|
22
|
+
@sleep_between_tries ||= 0.5
|
23
|
+
end
|
24
|
+
|
25
|
+
def path(type)
|
26
|
+
paths = {:reference => reference_image_path,
|
27
|
+
:candidate => File.join(reference_image_path, 'candidate'),
|
28
|
+
:diff => File.join(reference_image_path, 'diff'),
|
29
|
+
:temp => File.join(reference_image_path, 'temp')}
|
30
|
+
paths[type]
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_reference_path
|
34
|
+
begin
|
35
|
+
reference_image_path = File.join(Rails.root, 'spec/reference_images')
|
36
|
+
rescue
|
37
|
+
reference_image_path = 'spec/reference_images'
|
38
|
+
puts "Currently defaulting to #{@reference_image_path}. Overide this by setting reference_image_path=[refpath] in your configuration block"
|
39
|
+
end
|
40
|
+
reference_image_path
|
41
|
+
end
|
42
|
+
|
43
|
+
def reference_path_with_browser_folders
|
44
|
+
begin
|
45
|
+
reference_images_path = File.join(@reference_image_path, browser)
|
46
|
+
rescue
|
47
|
+
reference_images_path = @reference_image_path
|
48
|
+
end
|
49
|
+
reference_images_path
|
50
|
+
end
|
51
|
+
|
52
|
+
def browser
|
53
|
+
begin
|
54
|
+
browser = Capybara.page.driver.browser.browser
|
55
|
+
rescue
|
56
|
+
browser = Selenium.page.driver.browser.browser
|
57
|
+
rescue
|
58
|
+
raise "Currently custom folders are only supported by Capybara. ENV variables are coming."
|
59
|
+
return nil
|
60
|
+
end
|
61
|
+
browser.to_s
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
data/lib/gatling/image.rb
CHANGED
@@ -6,25 +6,22 @@ module Gatling
|
|
6
6
|
attr_reader :type
|
7
7
|
|
8
8
|
def initialize image, file_name
|
9
|
-
|
10
9
|
@file_name = file_name
|
11
|
-
|
12
10
|
@image = image
|
13
|
-
|
14
11
|
end
|
15
12
|
|
16
|
-
def save
|
17
|
-
|
18
|
-
FileUtils::mkdir_p(File.dirname(
|
19
|
-
@image.write
|
20
|
-
|
13
|
+
def save(type = :reference)
|
14
|
+
save_path = path(type)
|
15
|
+
FileUtils::mkdir_p(File.dirname(save_path)) unless File.exists?(save_path)
|
16
|
+
@image.write save_path
|
17
|
+
save_path
|
21
18
|
end
|
22
19
|
|
23
20
|
def exists?
|
24
21
|
File.exists?(path)
|
25
22
|
end
|
26
23
|
|
27
|
-
def path
|
24
|
+
def path(type = :reference)
|
28
25
|
@path = File.join(Gatling::Configuration.path(type), @file_name)
|
29
26
|
end
|
30
27
|
|
@@ -32,9 +29,30 @@ module Gatling
|
|
32
29
|
|
33
30
|
class ImageFromElement < Image
|
34
31
|
|
35
|
-
def initialize
|
32
|
+
def initialize(element, file_name)
|
36
33
|
super(image, file_name)
|
37
|
-
@
|
34
|
+
@element = element
|
35
|
+
@image = capture_image
|
36
|
+
end
|
37
|
+
|
38
|
+
def verify_and_save
|
39
|
+
Gatling::Configuration.max_no_tries.times do
|
40
|
+
comparable = capture_image
|
41
|
+
matches = Gatling::Comparison.new(self,Image.new(comparable,@file_name)).matches?
|
42
|
+
if matches
|
43
|
+
self.save
|
44
|
+
puts "Saved #{self.path} as reference"
|
45
|
+
return()
|
46
|
+
else
|
47
|
+
@image = comparable
|
48
|
+
end
|
49
|
+
end
|
50
|
+
raise 'Could not save a stable image. This could be due to animations or page load times. Saved a reference image, delete it to re-try'
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
def capture_image
|
55
|
+
Gatling::CaptureElement.capture(@element)
|
38
56
|
end
|
39
57
|
|
40
58
|
#TODO: make save a relevant subclass method
|
@@ -42,8 +60,9 @@ module Gatling
|
|
42
60
|
|
43
61
|
class ImageFromFile < Image
|
44
62
|
|
45
|
-
def initialize
|
63
|
+
def initialize(file_name)
|
46
64
|
super(image, file_name)
|
65
|
+
|
47
66
|
@image = Magick::Image.read(path).first
|
48
67
|
end
|
49
68
|
|
data/lib/gatling/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe 'Gatling' do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
before(:each) do
|
11
|
-
@ref_path = Gatling.reference_image_path = File.join(spec_support_root, 'ref_path')
|
11
|
+
@ref_path = Gatling::Configuration.reference_image_path = File.join(spec_support_root, 'ref_path')
|
12
12
|
end
|
13
13
|
|
14
14
|
after(:each) do
|
@@ -48,7 +48,7 @@ describe 'Gatling' do
|
|
48
48
|
"A diff image: #{"black.png"} was created in #{@ref_path}/diff/#{"black.png"} " +
|
49
49
|
"A new reference #{@ref_path}/candidate/#{"black.png"} can be used to fix the test"
|
50
50
|
|
51
|
-
expect {Gatling.matches?("black.png", red_element)}.
|
51
|
+
expect {Gatling.matches?("black.png", red_element)}.to raise_error(RuntimeError, expected_error)
|
52
52
|
|
53
53
|
File.exists?(File.join(@ref_path,'diff', "black.png")).should be_true
|
54
54
|
File.exists?(File.join(@ref_path,'candidate', "black.png")).should be_true
|
@@ -64,7 +64,7 @@ describe 'Gatling' do
|
|
64
64
|
"A diff image: #{"black.png"} was created in #{@ref_path}/diff/#{"black.png"} " +
|
65
65
|
"A new reference #{@ref_path}/candidate/#{"black.png"} can be used to fix the test"
|
66
66
|
|
67
|
-
expect {Gatling.matches?("black.png", red_element)}.
|
67
|
+
expect {Gatling.matches?("black.png", red_element)}.to raise_error(RuntimeError, expected_error)
|
68
68
|
|
69
69
|
File.exists?(File.join(@ref_path,'diff', "black.png")).should be_true
|
70
70
|
File.exists?(File.join(@ref_path,'candidate', "black.png")).should be_true
|
@@ -73,15 +73,6 @@ describe 'Gatling' do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
describe 'Gatling browser folders' do
|
77
|
-
|
78
|
-
it 'should set image path according to the driver\'s browser' do
|
79
|
-
Gatling.browser_folders = true
|
80
|
-
Gatling.reference_image_path = '/some/random/path'
|
81
|
-
Gatling::Configuration.reference_image_path.should == '/some/random/path/firefox'
|
82
|
-
Gatling.browser_folders = false
|
83
|
-
end
|
84
|
-
end
|
85
76
|
|
86
77
|
|
87
78
|
end
|
@@ -5,7 +5,7 @@ describe 'rspec matcher' do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
@black_box = 'black.png'
|
8
|
-
@ref_path = Gatling.reference_image_path = File.join(spec_support_root, 'ref_path')
|
8
|
+
@ref_path = Gatling::Configuration.reference_image_path = File.join(spec_support_root, 'ref_path')
|
9
9
|
create_images_for_web_page
|
10
10
|
end
|
11
11
|
|
@@ -25,7 +25,7 @@ describe 'rspec matcher' do
|
|
25
25
|
it "will fail if images doesn't matches reference" do
|
26
26
|
create_square_image(@ref_path, 'black')
|
27
27
|
red_element = element_for_spec("#red")
|
28
|
-
expect{red_element.should look_like(@black_box)}.
|
28
|
+
expect{red_element.should look_like(@black_box)}.to raise_error
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
data/spec/capture_spec.rb
CHANGED
@@ -2,88 +2,32 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Gatling::CaptureElement do
|
4
4
|
|
5
|
+
# creating a dummy class to test a module
|
6
|
+
class SomeClass
|
7
|
+
end
|
8
|
+
|
5
9
|
before :each do
|
6
|
-
|
7
|
-
Gatling::
|
8
|
-
@capture_element = Gatling::CaptureElement.new capybara_node, capybara_node
|
10
|
+
subject = SomeClass.new
|
11
|
+
subject.extend(Gatling::CaptureElement)
|
9
12
|
end
|
10
13
|
|
11
14
|
after :each do
|
12
15
|
config_clean_up
|
13
16
|
end
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@expected_temp_screenshot_file_pattern = /.*\/temp\/temp-\d+.png/
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should create temp directory when it does not exist' do
|
24
|
-
@webdriver.stub!(:save_screenshot)
|
25
|
-
Magick::Image.stub!(:read).and_return([])
|
26
|
-
|
27
|
-
File.stub!(:'exists?').and_return(false)
|
28
|
-
FileUtils.should_receive(:mkdir_p).with('./temp')
|
29
|
-
|
30
|
-
@capture_element.take_screenshot
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
it 'should work when Gatling is called concurrently from multiple processes' do
|
35
|
-
@webdriver.should_receive(:save_screenshot).with(@expected_temp_screenshot_file_pattern)
|
36
|
-
Magick::Image.should_receive(:read).with(@expected_temp_screenshot_file_pattern).and_return([])
|
37
|
-
|
38
|
-
@capture_element.take_screenshot
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
class Point
|
43
|
-
attr_accessor :x, :y
|
44
|
-
end
|
45
|
-
|
46
|
-
class Size
|
47
|
-
attr_accessor :width, :height
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should get the position of the css element' do
|
51
|
-
|
52
|
-
#Overiding the stupid public method:y of YAML module
|
53
|
-
|
54
|
-
location = Point.new
|
55
|
-
location.x = 1
|
56
|
-
location.y = 2
|
57
|
-
|
58
|
-
size = Size.new
|
59
|
-
size.width = 100
|
60
|
-
size.height = 200
|
18
|
+
it '.capture should return a cropped image' do
|
19
|
+
capybara_element = mock(Capybara::Node::Element)
|
20
|
+
position = {:x => 1, :y => 2, :width => 100, :height => 200}
|
21
|
+
magick_image = Magick::Image.new(position[:width],position[:height])
|
61
22
|
|
62
|
-
mock_element = mock
|
63
|
-
mock_element.stub(:native).and_return(mock_element)
|
64
|
-
mock_element.stub(:location).and_return(location)
|
65
|
-
mock_element.stub(:size).and_return(size)
|
66
23
|
|
67
|
-
|
24
|
+
subject.should_receive(:get_element_position).with(capybara_element).and_return(position)
|
25
|
+
subject.should_receive(:take_screenshot).and_return(magick_image)
|
26
|
+
subject.should_receive(:crop_element).and_return(magick_image)
|
68
27
|
|
69
|
-
|
70
|
-
|
71
|
-
position[:width].should eql(100)
|
72
|
-
position[:height].should eql(200)
|
28
|
+
image = subject.capture(capybara_element)
|
29
|
+
image.class.should == Magick::Image
|
73
30
|
end
|
74
31
|
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# it 'should exclude a specified element from capture' do
|
80
|
-
# element_to_capture =
|
81
|
-
|
82
|
-
# element_to_exclude = 'womething.child'
|
83
|
-
# # @cropped_and_censored_element = (element_to_capture, element_to_exclude).exclude
|
84
|
-
# @cropped_and_censored_element.should_not equal(@element_to_capture)
|
85
|
-
# @cropped_and_censored_element.should_not equal(@element_to_exclude)
|
86
|
-
# end
|
87
|
-
|
88
32
|
end
|
89
33
|
|
data/spec/comparison_spec.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
@@ -31,29 +31,25 @@ describe Gatling::Configuration do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should default to <Rails.root>/spec/reference_images in a rails environment" do
|
34
|
-
|
34
|
+
subject.reference_image_path.should == "fake_rails_root/spec/reference_images"
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should be overrideable in a rails environment" do
|
38
|
-
|
39
|
-
|
38
|
+
subject.reference_image_path = "my custom path"
|
39
|
+
subject.reference_image_path.should == "my custom path"
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should return the directory for a type of image' do
|
43
|
-
|
43
|
+
subject.reference_image_path = "a_path"
|
44
44
|
subject.path(:temp).should == 'a_path/temp'
|
45
45
|
end
|
46
46
|
|
47
|
-
it 'should thrown an error when you ask for the path of an unknown image type' do
|
48
|
-
expect { Gatling::Configuration.path(:unknown)}.should raise_error "Unkown image type 'unknown'"
|
49
|
-
end
|
50
|
-
|
51
47
|
end
|
52
48
|
|
53
49
|
describe "creating custom reference folders" do
|
54
50
|
|
55
51
|
before :each do
|
56
|
-
|
52
|
+
subject.reference_image_path = '/some/ref/path'
|
57
53
|
end
|
58
54
|
|
59
55
|
it "should default to custom folders off" do
|
@@ -61,7 +57,7 @@ describe Gatling::Configuration do
|
|
61
57
|
end
|
62
58
|
|
63
59
|
it "should allow setting custom folders on" do
|
64
|
-
|
60
|
+
subject.browser_folders = true
|
65
61
|
subject.browser_folders.should == true
|
66
62
|
end
|
67
63
|
|
@@ -106,8 +102,8 @@ describe Gatling::Configuration do
|
|
106
102
|
end
|
107
103
|
|
108
104
|
it "should be settable" do
|
109
|
-
|
110
|
-
subject.sleep_between_tries.should
|
105
|
+
subject.sleep_between_tries = 55
|
106
|
+
subject.sleep_between_tries.should == 55
|
111
107
|
end
|
112
108
|
end
|
113
109
|
|
@@ -116,36 +112,68 @@ describe Gatling::Configuration do
|
|
116
112
|
describe "should accept a block of settings and parse them correctly" do
|
117
113
|
|
118
114
|
it "for reference_image_path" do
|
119
|
-
Gatling.config do |
|
120
|
-
|
115
|
+
Gatling.config do |c|
|
116
|
+
c.reference_image_path = 'custom_path'
|
121
117
|
end
|
122
|
-
subject.reference_image_path.should
|
118
|
+
subject.reference_image_path.should == 'custom_path'
|
123
119
|
end
|
124
120
|
|
125
121
|
it "for max_no_tries" do
|
126
|
-
Gatling.config do |
|
127
|
-
|
122
|
+
Gatling.config do |c|
|
123
|
+
c.max_no_tries = 3
|
128
124
|
end
|
129
|
-
|
125
|
+
|
126
|
+
subject.max_no_tries.should == 3
|
130
127
|
end
|
131
128
|
|
132
129
|
it "sleep_between_tries" do
|
133
|
-
Gatling.config do |
|
134
|
-
|
130
|
+
Gatling.config do |c|
|
131
|
+
c.sleep_between_tries = 0.7
|
135
132
|
end
|
136
|
-
subject.sleep_between_tries.should
|
133
|
+
subject.sleep_between_tries.should == 0.7
|
137
134
|
end
|
138
135
|
|
139
|
-
|
140
|
-
Gatling.config do |
|
141
|
-
|
136
|
+
it "for browser_folders" do
|
137
|
+
Gatling.config do |c|
|
138
|
+
c.browser_folders = true
|
142
139
|
end
|
143
|
-
|
140
|
+
|
141
|
+
subject.browser_folders.should == true
|
144
142
|
end
|
145
143
|
|
146
144
|
end
|
147
145
|
end
|
148
146
|
|
147
|
+
describe "config block" do
|
148
|
+
|
149
|
+
it 'should be able to set a config block' do
|
150
|
+
Gatling.config do |c|
|
151
|
+
c.reference_image_path = 'some/path'
|
152
|
+
c.max_no_tries = 4
|
153
|
+
c.sleep_between_tries = 5
|
154
|
+
c.browser_folders = false
|
155
|
+
end
|
156
|
+
|
157
|
+
subject.reference_image_path.should == 'some/path'
|
158
|
+
subject.max_no_tries.should == 4
|
159
|
+
subject.sleep_between_tries.should == 5
|
160
|
+
subject.browser_folders.should == false
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should raise depreciation alert when calling old block' do
|
164
|
+
expect {
|
165
|
+
Gatling.config do |c|
|
166
|
+
Gatling.reference_image_path = 'some/path'
|
167
|
+
Gatling.max_no_tries = 4
|
168
|
+
Gatling.sleep_between_tries = 5
|
169
|
+
Gatling.browser_folders = false
|
170
|
+
end
|
171
|
+
}.to raise_error "Config block has changed. Example: Gatling.config {|c| c.reference_image_path = 'some/path'}. Please see README"
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
end
|
176
|
+
|
149
177
|
|
150
178
|
|
151
179
|
|
data/spec/gatling_spec.rb
CHANGED
@@ -3,92 +3,85 @@ include Capybara::DSL
|
|
3
3
|
|
4
4
|
describe Gatling do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
@black_box = 'black.png'
|
9
|
-
@red_box = 'red.png'
|
6
|
+
after :all do
|
7
|
+
config_clean_up
|
10
8
|
end
|
11
9
|
|
12
|
-
|
10
|
+
let(:actual_image) { mock("Gatling::Image") }
|
11
|
+
let(:expected_image) { mock("Gatling::Image") }
|
12
|
+
let(:comparison) { mock("Gatling::Comparison") }
|
13
|
+
let(:element) { mock("Gatling::CaptureElement") }
|
13
14
|
|
15
|
+
|
16
|
+
describe 'comparison' do
|
14
17
|
before :each do
|
15
|
-
|
18
|
+
Gatling::ImageFromFile.stub!(:new).and_return(expected_image)
|
19
|
+
Gatling::ImageFromElement.stub!(:new).and_return(actual_image)
|
20
|
+
Gatling::Comparison.stub!(:new).and_return(comparison)
|
21
|
+
expected_image.should_receive(:file_name).and_return('expected_image.png')
|
16
22
|
end
|
17
23
|
|
18
24
|
it 'will return true if the images are identical' do
|
19
|
-
|
20
|
-
@orange = mock("Gatling::Image")
|
21
|
-
@element = mock("Gatling::CaptureElement")
|
22
|
-
@comparison = mock("Gatling::Comparison")
|
23
|
-
Gatling::ImageFromFile.stub!(:new).and_return(@orange)
|
24
|
-
Gatling::ImageFromElement.stub!(:new).and_return(@orange)
|
25
|
-
Gatling::Comparison.stub!(:new).and_return(@comparison)
|
26
|
-
@comparison.stub!(:matches?).and_return(true)
|
25
|
+
comparison.stub!(:matches?).and_return(true)
|
27
26
|
File.stub!(:exists?).and_return(true)
|
28
|
-
|
27
|
+
|
28
|
+
subject.matches?("expected_image.png", @element).should be_true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
describe 'saving images' do
|
34
|
+
before :each do
|
35
|
+
@image_class_mock = mock(Gatling::Image)
|
29
36
|
end
|
30
37
|
|
38
|
+
|
31
39
|
it "#save_image_as_diff" do
|
32
40
|
@image_class_mock.should_receive(:save).with(:diff).and_return(@ref_path)
|
33
41
|
@image_class_mock.should_receive(:file_name).at_least(:once).and_return("some_name")
|
34
|
-
|
42
|
+
|
43
|
+
expect {subject.save_image_as_diff(@image_class_mock)}.to raise_error
|
35
44
|
end
|
36
45
|
|
37
46
|
it "#save_image_as_candidate" do
|
38
47
|
@image_class_mock.should_receive(:save).with(:candidate).and_return(@ref_path)
|
39
48
|
@image_class_mock.should_receive(:file_name).at_least(:once).and_return("some_name")
|
40
49
|
@image_class_mock.should_receive(:path).and_return(@path)
|
41
|
-
expect {subject.save_image_as_candidate(@image_class_mock)}.
|
50
|
+
expect {subject.save_image_as_candidate(@image_class_mock)}.to raise_error
|
42
51
|
end
|
43
52
|
|
44
53
|
describe "#save_image_as_reference" do
|
45
54
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@image_class_mock.should_not_receive(:save)
|
50
|
-
subject.save_image_as_reference(@image_class_mock)
|
51
|
-
end
|
55
|
+
let(:image) {mock('image.png')}
|
56
|
+
let(:reference_image) {Gatling::ImageFromElement.stub(:new).and_return(image)}
|
57
|
+
let(:comparison) {mock("comparison")}
|
52
58
|
|
53
|
-
|
54
|
-
|
55
|
-
@image_class_mock.should_receive(:save).with(:reference).and_return(@ref_path)
|
56
|
-
@image_class_mock.should_receive(:path).and_return(@path)
|
57
|
-
subject.save_image_as_reference(@image_class_mock)
|
59
|
+
before :each do
|
60
|
+
Gatling.stub!(:compare_until_match).and_return(comparison)
|
58
61
|
end
|
59
62
|
|
60
63
|
end
|
64
|
+
end
|
61
65
|
|
66
|
+
describe "#compare_until_match" do
|
62
67
|
|
68
|
+
before :each do
|
69
|
+
Gatling::ImageFromElement.stub!(:new).and_return(actual_image)
|
70
|
+
Gatling::ImageFromFile.stub!(:new).and_return(expected_image)
|
71
|
+
Gatling::Comparison.stub!(:new).and_return(comparison)
|
63
72
|
|
73
|
+
expected_image.should_receive(:file_name).at_least(:once).and_return('expected_image.png')
|
64
74
|
end
|
65
75
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
@actual_image = mock("Gatling::Image")
|
71
|
-
@element = mock("Gatling::CaptureElement")
|
72
|
-
@comparison = mock("Gatling::Comparison")
|
73
|
-
Gatling::ImageFromFile.stub!(:new).and_return(@ref_image)
|
74
|
-
Gatling::ImageFromElement.stub!(:new).and_return(@actual_image)
|
75
|
-
Gatling::Comparison.stub!(:new).and_return(@comparison)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should try match for a specified amount of times" do
|
79
|
-
@comparison.should_receive(:matches?).exactly(3).times
|
80
|
-
Gatling.compare_until_match(@element, "orange.png", 3)
|
81
|
-
end
|
76
|
+
it "should try match for a specified amount of times" do
|
77
|
+
comparison.should_receive(:matches?).exactly(3).times.and_return(false)
|
78
|
+
Gatling.compare_until_match(@element, expected_image, 3, 0.1)
|
79
|
+
end
|
82
80
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
it "should pass after a few tries if match is found" do
|
82
|
+
comparison.should_receive(:matches?).exactly(1).times.and_return(true)
|
83
|
+
Gatling.compare_until_match(@element, expected_image, 3, 0.1)
|
84
|
+
end
|
87
85
|
|
88
|
-
it 'should compare image from the element with image from the file' do
|
89
|
-
@comparison.stub!(:matches?).and_return(true)
|
90
|
-
Gatling::Comparison.should_receive(:new).with(@actual_image, @ref_image).and_return(@comparison)
|
91
|
-
Gatling.compare_until_match(@element, "orange.png", 3)
|
92
|
-
end
|
93
86
|
end
|
94
87
|
end
|
data/spec/image_spec.rb
CHANGED
@@ -2,10 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Gatling::Image do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
let(:example_image) { Magick::Image.new(1,1) }
|
6
|
+
let(:ref_path) { 'spec/reference_images/image.png' }
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
Gatling::Configuration.reference_image_path = 'spec/reference_images'
|
9
10
|
end
|
10
11
|
|
11
12
|
after :each do
|
@@ -13,92 +14,28 @@ describe Gatling::Image do
|
|
13
14
|
end
|
14
15
|
|
15
16
|
describe 'should initialize from' do
|
16
|
-
|
17
|
-
it 'image file type' do
|
17
|
+
it 'ImageFromFile - IO file read' do
|
18
18
|
File.stub(:exists?).and_return(true)
|
19
|
-
|
20
|
-
|
21
|
-
Magick::Image.should_receive(:read).with('./image_tests/image.png').and_return([image_mock])
|
19
|
+
Magick::Image.should_receive(:read).with(ref_path).and_return([example_image])
|
20
|
+
|
22
21
|
subject = Gatling::ImageFromFile.new("image.png")
|
23
|
-
subject.image.should ==
|
24
|
-
subject.file_name.should == 'image.png'
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'web element type' do
|
28
|
-
mock_element = mock(Capybara::Node::Element)
|
29
|
-
mock_capture_element = mock(Gatling::CaptureElement)
|
30
|
-
mock_image = mock(Magick::Image)
|
31
|
-
|
32
|
-
Gatling::CaptureElement.should_receive(:new).and_return mock_capture_element
|
33
|
-
mock_capture_element.should_receive(:capture).and_return mock_image
|
34
|
-
subject = Gatling::ImageFromElement.new(mock_element, "image.png")
|
35
|
-
subject.image.should == mock_image
|
22
|
+
subject.image.should == example_image
|
36
23
|
subject.file_name.should == 'image.png'
|
37
24
|
end
|
38
25
|
|
39
|
-
|
40
|
-
mock_image = mock(Magick::Image)
|
41
|
-
subject = Gatling::Image.new(mock_image, 'image.png')
|
42
|
-
subject.image.should == mock_image
|
43
|
-
subject.file_name.should == 'image.png'
|
44
|
-
end
|
26
|
+
|
45
27
|
end
|
46
28
|
|
47
|
-
describe "
|
48
|
-
|
49
|
-
|
50
|
-
Gatling::Configuration.should_receive(:reference_image_path).any_number_of_times.and_return(@ref_path)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'will save an image to the correct path for the type' do
|
54
|
-
mock_image = mock(Magick::Image)
|
55
|
-
mock_image.should_receive(:write).with('./image_tests/temp/image.png').and_return()
|
56
|
-
subject = Gatling::Image.new(mock_image, 'image.png')
|
57
|
-
subject.image = mock_image
|
58
|
-
subject.file_name = 'image.png'
|
59
|
-
subject.save(:temp)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'will create directory, then save and image if directory doesnt exist' do
|
63
|
-
image_path = 'path/to/image/in/sub/directory/image.png'
|
64
|
-
expected_full_path = File.join(Gatling::Configuration.path(:temp), image_path)
|
65
|
-
expected_image_dir = File.dirname(expected_full_path)
|
29
|
+
describe "save" do
|
30
|
+
it 'will save an image' do
|
31
|
+
example_image.should_receive(:write).with(ref_path).and_return()
|
66
32
|
|
67
|
-
|
68
|
-
mock_image.should_receive(:write).with(expected_full_path).and_return()
|
69
|
-
|
70
|
-
File.should_receive(:exists?).with(expected_full_path).and_return(false)
|
71
|
-
FileUtils.should_receive(:mkdir_p).with(expected_image_dir)
|
72
|
-
subject = Gatling::Image.new(mock_image, image_path)
|
73
|
-
|
74
|
-
subject.save(:temp)
|
75
|
-
subject.path(:temp).should == expected_full_path
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'will save an image if directory exist' do
|
79
|
-
mock_image = stub(Magick::Image)
|
80
|
-
mock_image.should_receive(:write).with(@expected_temp_image_path).and_return()
|
81
|
-
|
82
|
-
File.should_receive(:exists?).with(@expected_temp_image_path).and_return(true)
|
33
|
+
File.should_receive(:exists?).with(ref_path).and_return(true)
|
83
34
|
FileUtils.should_not_receive(:mkdir_p)
|
84
|
-
subject = Gatling::Image.new(
|
85
|
-
|
86
|
-
subject.save(:temp)
|
87
|
-
subject.path(:temp).should == @expected_temp_image_path
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should check if a file exists, with the file name and type' do
|
91
|
-
mock_image = mock(Magick::Image)
|
92
|
-
File.should_receive(:exists?).with './image_tests/image.png'
|
93
|
-
subject = Gatling::Image.new(mock_image, 'image.png')
|
94
|
-
subject.file_name = 'image.png'
|
95
|
-
subject.exists?
|
96
|
-
end
|
35
|
+
subject = Gatling::Image.new(example_image, "image.png")
|
97
36
|
|
98
|
-
|
99
|
-
|
100
|
-
subject = Gatling::Image.new(mock_image, 'image.png')
|
101
|
-
subject.path.should == File.join(@ref_path,'image.png')
|
37
|
+
subject.save
|
38
|
+
subject.path.should == ref_path
|
102
39
|
end
|
103
40
|
end
|
104
41
|
|
@@ -125,4 +62,47 @@ describe Gatling::Image do
|
|
125
62
|
|
126
63
|
end
|
127
64
|
|
65
|
+
describe "ImageFromElement" do
|
66
|
+
|
67
|
+
let(:mock_element) { mock(Capybara::Node::Element) }
|
68
|
+
let(:comparison) { mock('comparison') }
|
69
|
+
|
70
|
+
it 'should initialize from a web element' do
|
71
|
+
Gatling::CaptureElement.should_receive(:capture).with(mock_element).and_return(example_image)
|
72
|
+
|
73
|
+
subject = Gatling::ImageFromElement.new(mock_element, "image.png")
|
74
|
+
subject.image.class.should == example_image.class
|
75
|
+
subject.file_name.should == 'image.png'
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '.save_and_verify' do
|
79
|
+
|
80
|
+
it 'should verify the element and then save' do
|
81
|
+
Gatling::Comparison.should_receive(:new).exactly(2).times.and_return(comparison)
|
82
|
+
comparison.should_receive(:matches?).exactly(2).times.and_return(false,true)
|
83
|
+
|
84
|
+
Gatling::CaptureElement.should_receive(:capture).exactly(3).times.with(mock_element).and_return(example_image)
|
85
|
+
|
86
|
+
subject = Gatling::ImageFromElement.new(mock_element, "image.png")
|
87
|
+
subject.should_receive(:save)
|
88
|
+
|
89
|
+
Gatling::Configuration.max_no_tries = 3
|
90
|
+
|
91
|
+
subject.verify_and_save
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should raise an exception if can\'t create a stable image' do
|
95
|
+
Gatling::Configuration.max_no_tries = 1
|
96
|
+
Gatling::CaptureElement.stub!(:capture).and_return(mock_element)
|
97
|
+
Gatling::Comparison.stub!(:matches?).and_return(false)
|
98
|
+
|
99
|
+
subject = Gatling::ImageFromElement.new(mock_element, "image.png")
|
100
|
+
|
101
|
+
expect {subject.verify_and_save}.to raise_error
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
end
|
107
|
+
|
128
108
|
end
|
@@ -28,7 +28,7 @@ describe 'Gatling' do
|
|
28
28
|
"is now available to be used as a reference. " +
|
29
29
|
"Copy candidate to root reference_image_path to use as reference"
|
30
30
|
|
31
|
-
expect {Gatling.matches?(@black_box, mock_element)}.
|
31
|
+
expect {Gatling.matches?(@black_box, mock_element)}.to raise_error(RuntimeError, expected_error)
|
32
32
|
|
33
33
|
File.exists?(File.join(@ref_path, 'candidate', @black_box)).should be_true
|
34
34
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,6 @@ require 'fileutils'
|
|
8
8
|
require 'pry'
|
9
9
|
|
10
10
|
#todo: spec folders clean up method
|
11
|
-
|
12
11
|
RSpec.configure do |config|
|
13
12
|
config.color_enabled = true
|
14
13
|
config.formatter = 'documentation'
|
@@ -21,6 +20,7 @@ Capybara.run_server = false
|
|
21
20
|
def config_clean_up
|
22
21
|
Gatling::Configuration.reference_image_path = nil
|
23
22
|
Gatling::Configuration.browser_folders = false
|
23
|
+
Gatling::Configuration.max_no_tries = nil
|
24
24
|
end
|
25
25
|
|
26
26
|
def remove_refs(dir)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gatling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rmagick
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,32 +21,31 @@ dependencies:
|
|
21
21
|
version: 2.13.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rspec-core
|
27
|
-
requirement: &70284092347260 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70284092347260
|
29
|
+
version: 2.13.1
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
31
|
name: rspec
|
38
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
34
|
requirements:
|
41
35
|
- - ! '>='
|
42
36
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.
|
37
|
+
version: 2.9.0
|
44
38
|
type: :runtime
|
45
39
|
prerelease: false
|
46
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.9.0
|
47
46
|
- !ruby/object:Gem::Dependency
|
48
47
|
name: capybara
|
49
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
50
49
|
none: false
|
51
50
|
requirements:
|
52
51
|
- - ! '>='
|
@@ -54,10 +53,15 @@ dependencies:
|
|
54
53
|
version: 1.1.2
|
55
54
|
type: :runtime
|
56
55
|
prerelease: false
|
57
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.2
|
58
62
|
- !ruby/object:Gem::Dependency
|
59
63
|
name: rake
|
60
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
61
65
|
none: false
|
62
66
|
requirements:
|
63
67
|
- - ! '>='
|
@@ -65,10 +69,15 @@ dependencies:
|
|
65
69
|
version: 0.9.2
|
66
70
|
type: :development
|
67
71
|
prerelease: false
|
68
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.9.2
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rspec-instafail
|
71
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
72
81
|
none: false
|
73
82
|
requirements:
|
74
83
|
- - ! '>='
|
@@ -76,10 +85,15 @@ dependencies:
|
|
76
85
|
version: 0.1.8
|
77
86
|
type: :development
|
78
87
|
prerelease: false
|
79
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.1.8
|
80
94
|
- !ruby/object:Gem::Dependency
|
81
95
|
name: pry
|
82
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
83
97
|
none: false
|
84
98
|
requirements:
|
85
99
|
- - ! '>='
|
@@ -87,11 +101,25 @@ dependencies:
|
|
87
101
|
version: 0.9.8.2
|
88
102
|
type: :development
|
89
103
|
prerelease: false
|
90
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.9.8.2
|
91
110
|
description: Add visual comparison matchers for rspec
|
92
111
|
email:
|
93
112
|
- grotbart@gmail.com
|
94
|
-
executables:
|
113
|
+
executables:
|
114
|
+
- autospec
|
115
|
+
- coderay
|
116
|
+
- htmldiff
|
117
|
+
- ldiff
|
118
|
+
- nokogiri
|
119
|
+
- pry
|
120
|
+
- rackup
|
121
|
+
- rake
|
122
|
+
- rspec
|
95
123
|
extensions: []
|
96
124
|
extra_rdoc_files: []
|
97
125
|
files:
|
@@ -103,11 +131,20 @@ files:
|
|
103
131
|
- LICENSE.txt
|
104
132
|
- README.rdoc
|
105
133
|
- Rakefile
|
134
|
+
- bin/autospec
|
135
|
+
- bin/coderay
|
136
|
+
- bin/htmldiff
|
137
|
+
- bin/ldiff
|
138
|
+
- bin/nokogiri
|
139
|
+
- bin/pry
|
140
|
+
- bin/rackup
|
141
|
+
- bin/rake
|
142
|
+
- bin/rspec
|
106
143
|
- gatling.gemspec
|
107
144
|
- lib/gatling.rb
|
108
145
|
- lib/gatling/capture_element.rb
|
109
146
|
- lib/gatling/comparison.rb
|
110
|
-
- lib/gatling/
|
147
|
+
- lib/gatling/configuration.rb
|
111
148
|
- lib/gatling/image.rb
|
112
149
|
- lib/gatling/matchers/look_like_matcher.rb
|
113
150
|
- lib/gatling/version.rb
|
@@ -145,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
182
|
version: '0'
|
146
183
|
requirements: []
|
147
184
|
rubyforge_project: gatling
|
148
|
-
rubygems_version: 1.8.
|
185
|
+
rubygems_version: 1.8.24
|
149
186
|
signing_key:
|
150
187
|
specification_version: 3
|
151
188
|
summary: Automated visual testing
|
data/lib/gatling/config.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
|
3
|
-
module Gatling
|
4
|
-
module Configuration
|
5
|
-
|
6
|
-
class << self
|
7
|
-
|
8
|
-
attr_accessor :reference_image_path, :max_no_tries, :sleep_between_tries, :browser_folders
|
9
|
-
|
10
|
-
attr_reader :paths
|
11
|
-
|
12
|
-
def reference_image_path
|
13
|
-
construct_path
|
14
|
-
end
|
15
|
-
|
16
|
-
def max_no_tries
|
17
|
-
Gatling.max_no_tries || @max_no_tries ||= 5
|
18
|
-
end
|
19
|
-
|
20
|
-
def sleep_between_tries
|
21
|
-
Gatling.sleep_between_tries || @sleep_between_tries ||= 0.5
|
22
|
-
end
|
23
|
-
|
24
|
-
def path(type)
|
25
|
-
paths = Hash[:reference => reference_image_path,
|
26
|
-
:candidate => File.join(reference_image_path, 'candidate'),
|
27
|
-
:diff => File.join(reference_image_path, 'diff'),
|
28
|
-
:temp => File.join(reference_image_path, 'temp')]
|
29
|
-
if paths.keys.include? type
|
30
|
-
return paths[type]
|
31
|
-
else
|
32
|
-
raise "Unkown image type '#{type}'"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def construct_path
|
37
|
-
private
|
38
|
-
reference_image_path = user_set_reference_path || default_reference_path
|
39
|
-
reference_image_path = reference_path_with_browser_folders(reference_image_path) if browser_folders
|
40
|
-
reference_image_path
|
41
|
-
end
|
42
|
-
|
43
|
-
def user_set_reference_path
|
44
|
-
Gatling.reference_image_path
|
45
|
-
end
|
46
|
-
|
47
|
-
def default_reference_path
|
48
|
-
begin
|
49
|
-
reference_image_path = File.join(Rails.root, 'spec/reference_images')
|
50
|
-
rescue
|
51
|
-
reference_image_path = 'spec/reference_images'
|
52
|
-
puts "Currently defaulting to #{@reference_image_path}. Overide this by setting Gatling.reference_image_path=[refpath]"
|
53
|
-
end
|
54
|
-
reference_image_path
|
55
|
-
end
|
56
|
-
|
57
|
-
def reference_path_with_browser_folders path
|
58
|
-
begin
|
59
|
-
reference_images_path = File.join(path, browser)
|
60
|
-
rescue
|
61
|
-
reference_images_path = path
|
62
|
-
end
|
63
|
-
reference_images_path
|
64
|
-
end
|
65
|
-
|
66
|
-
def browser_folders
|
67
|
-
Gatling.browser_folders || @browser_folders ||= false
|
68
|
-
end
|
69
|
-
|
70
|
-
def browser
|
71
|
-
begin
|
72
|
-
browser = Capybara.page.driver.browser.browser
|
73
|
-
rescue
|
74
|
-
browser = Selenium.page.driver.browser.browser
|
75
|
-
rescue
|
76
|
-
raise "Currently custom folders are only supported by Capybara. ENV variables are coming."
|
77
|
-
end
|
78
|
-
browser.to_s
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|