gatling 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +34 -0
- data/Rakefile +1 -0
- data/gatling.gemspec +26 -0
- data/lib/gatling.rb +56 -0
- data/lib/gatling/version.rb +3 -0
- metadata +97 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Gabriel Rotbart, Amanda Koh
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
= gatling
|
2
|
+
|
3
|
+
Gatling Comparison allows one to build an Rspec / Capybara custom matcher comparing a :css or :xpath element to a referenced screenshot:
|
4
|
+
Example:
|
5
|
+
-----------
|
6
|
+
RSpec::Matchers.define :look_like do |expected|
|
7
|
+
match do |actual|
|
8
|
+
Gatling::Comparison.new(expected, actual).matches?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
-----------
|
12
|
+
|
13
|
+
Imagemagick must be installed: $sudo apt-get install imagemagick
|
14
|
+
|
15
|
+
To make this gem work with native selenium-webdriver:
|
16
|
+
in gatling.rb replace
|
17
|
+
element = @actual.native with
|
18
|
+
element = @actual
|
19
|
+
|
20
|
+
== Contributing to gatling
|
21
|
+
|
22
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
23
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
24
|
+
* Fork the project
|
25
|
+
* Start a feature/bugfix branch
|
26
|
+
* Commit and push until you are happy with your contribution
|
27
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
28
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
29
|
+
|
30
|
+
== Copyright
|
31
|
+
|
32
|
+
Copyright (c) 2011 Gabriel Rotbart, Amanda Koh. See LICENSE.txt for
|
33
|
+
further details.
|
34
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/gatling.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "gatling/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "gatling"
|
7
|
+
s.version = Gatling::VERSION
|
8
|
+
s.authors = ["Gabriel Rotbart, Amanda Koh"]
|
9
|
+
s.email = ["grotbart@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Automated visual testing}
|
12
|
+
s.description = %q{Add visual comparison matchers for rspec}
|
13
|
+
|
14
|
+
s.rubyforge_project = "gatling"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_dependency "rspec"
|
23
|
+
s.add_dependency "rmagick"
|
24
|
+
s.add_dependency "selenium-client"
|
25
|
+
s.add_dependency "capybara"
|
26
|
+
end
|
data/lib/gatling.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require "gatling/version"
|
2
|
+
require 'RMagick'
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
# The Gatling Comparison class allows you to build an Rspec / Capybara custom matcher comparing a :css or :xpath element to a referenced screenshot:
|
6
|
+
# Example:
|
7
|
+
# -----------
|
8
|
+
# RSpec::Matchers.define :look_like do |expected|
|
9
|
+
# match do |actual|
|
10
|
+
# Gatling::Comparison.new(expected, actual).matches?
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
# -----------
|
14
|
+
|
15
|
+
module Gatling
|
16
|
+
class Comparison
|
17
|
+
|
18
|
+
def initialize expected, actual
|
19
|
+
@expected = expected
|
20
|
+
@actual = actual
|
21
|
+
end
|
22
|
+
|
23
|
+
def capture
|
24
|
+
page.driver.browser.save_screenshot('temp.png')
|
25
|
+
temp_screenshot = Image.read('temp.png').first
|
26
|
+
end
|
27
|
+
|
28
|
+
def crop_element
|
29
|
+
element = @actual.native
|
30
|
+
location = element.location
|
31
|
+
size = element.size
|
32
|
+
capture.crop(location.x, location.y, size.width, size.height)
|
33
|
+
end
|
34
|
+
|
35
|
+
def save_crop_as_reference(cropped_element)
|
36
|
+
filename = "#{@expected}".sub(/\.[a-z]*/,'')
|
37
|
+
cropped_element.write("#{filename}_candidate.png")
|
38
|
+
return filename
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def matches?
|
43
|
+
cropped_element = crop_element
|
44
|
+
if File.exists?(@expected)
|
45
|
+
expected_img = Image.read(@expected).first
|
46
|
+
diff_metric = cropped_element.compare_channel(expected_img, MeanAbsoluteErrorMetric)
|
47
|
+
matches = diff_metric[1] == 0.0
|
48
|
+
diff_metric.first.write('diff.png') unless matches
|
49
|
+
matches
|
50
|
+
else
|
51
|
+
filename = save_crop_as_reference(cropped_element)
|
52
|
+
raise "The design reference #{@expected} does not exist, #{filename}_candidate.png is now available to be used as a reference"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gatling
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gabriel Rotbart, Amanda Koh
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-05 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70134137415320 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70134137415320
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rmagick
|
27
|
+
requirement: &70134137414100 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70134137414100
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: selenium-client
|
38
|
+
requirement: &70134137413560 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70134137413560
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: capybara
|
49
|
+
requirement: &70134137412720 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70134137412720
|
58
|
+
description: Add visual comparison matchers for rspec
|
59
|
+
email:
|
60
|
+
- grotbart@gmail.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.rdoc
|
69
|
+
- Rakefile
|
70
|
+
- gatling.gemspec
|
71
|
+
- lib/gatling.rb
|
72
|
+
- lib/gatling/version.rb
|
73
|
+
homepage: ''
|
74
|
+
licenses: []
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project: gatling
|
93
|
+
rubygems_version: 1.8.10
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Automated visual testing
|
97
|
+
test_files: []
|