gatling 1.0.9 → 1.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.
@@ -49,7 +49,7 @@ GATLING::CONFIGURATION will be depreciated in future versions.
49
49
 
50
50
  Identify an element to match, for example:
51
51
 
52
- @element = page.find(:css, #button)
52
+ @element = page.find(:css, '#button')
53
53
 
54
54
  Use Gatling's custom matcher (conveniently supplied in the gatling gem) and specify the reference image:
55
55
 
@@ -1,11 +1,8 @@
1
1
  require 'fileutils'
2
- require_relative 'image_wrangler'
3
2
 
4
3
  module Gatling
5
4
  class CaptureElement
6
5
 
7
- include ImageWrangler
8
-
9
6
  def initialize element_to_capture, *element_to_exclude
10
7
  @reference_image_path = Gatling::Configuration.reference_image_path
11
8
  @element_to_capture = element_to_capture
@@ -14,9 +11,13 @@ module Gatling
14
11
  end
15
12
 
16
13
  def capture
14
+ # Getting the element position before screenshot because of a side effect
15
+ # of WebDrivers getLocationOnceScrolledIntoView method which scrolls the page
16
+ # regardless of whether the object is in view or not
17
+ element_position = get_element_position @element_to_capture
17
18
  screenshot = self.take_screenshot
18
19
  screenshot = exclude(screenshot, @element_to_exclude) if @element_to_exclude
19
- Gatling::ImageWrangler.crop_element(screenshot, @element_to_capture)
20
+ crop_element(screenshot, @element_to_capture, element_position)
20
21
  end
21
22
 
22
23
  def take_screenshot
@@ -31,6 +32,21 @@ module Gatling
31
32
  raise "Could not save screenshot to #{temp_dir}. Please make sure you have permission"
32
33
  end
33
34
  end
35
+
36
+ def get_element_position element
37
+ element = element.native
38
+ position = Hash.new{}
39
+ position[:x] = element.location.x
40
+ position[:y] = element.location.y
41
+ position[:width] = element.size.width
42
+ position[:height] = element.size.height
43
+ position
44
+ end
45
+
46
+ def crop_element image, element_to_crop, position
47
+ @cropped_element = image.crop(position[:x], position[:y], position[:width], position[:height])
48
+ end
49
+
34
50
  end
35
51
  end
36
52
 
@@ -34,7 +34,6 @@ module Gatling
34
34
 
35
35
  def initialize element, file_name
36
36
  super(image, file_name)
37
-
38
37
  @image = Gatling::CaptureElement.new(element).capture
39
38
  end
40
39
 
@@ -1,3 +1,3 @@
1
1
  module Gatling
2
- VERSION = "1.0.9"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -37,6 +37,41 @@ describe Gatling::CaptureElement do
37
37
 
38
38
  @capture_element.take_screenshot
39
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
61
+
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
+
67
+ position = @capture_element.get_element_position mock_element
68
+
69
+ position[:x].should eql(1)
70
+ position[:y].should eql(2)
71
+ position[:width].should eql(100)
72
+ position[:height].should eql(200)
73
+ end
74
+
40
75
  end
41
76
 
42
77
 
File without changes
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.0.9
4
+ version: 1.1.0
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-05-14 00:00:00.000000000 Z
12
+ date: 2012-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rmagick
16
- requirement: &70099690488660 !ruby/object:Gem::Requirement
16
+ requirement: &70097588530300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.13.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70099690488660
24
+ version_requirements: *70097588530300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec-core
27
- requirement: &70099690488120 !ruby/object:Gem::Requirement
27
+ requirement: &70097588529480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70099690488120
35
+ version_requirements: *70097588529480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70099690536780 !ruby/object:Gem::Requirement
38
+ requirement: &70097588528340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.8.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70099690536780
46
+ version_requirements: *70097588528340
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: capybara
49
- requirement: &70099690536300 !ruby/object:Gem::Requirement
49
+ requirement: &70097588527280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.1.2
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70099690536300
57
+ version_requirements: *70097588527280
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70099690535820 !ruby/object:Gem::Requirement
60
+ requirement: &70097588526600 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.9.2
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70099690535820
68
+ version_requirements: *70097588526600
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-instafail
71
- requirement: &70099690535340 !ruby/object:Gem::Requirement
71
+ requirement: &70097588525520 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.1.8
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70099690535340
79
+ version_requirements: *70097588525520
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: pry
82
- requirement: &70099690534800 !ruby/object:Gem::Requirement
82
+ requirement: &70097588524820 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: 0.9.8.2
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70099690534800
90
+ version_requirements: *70097588524820
91
91
  description: Add visual comparison matchers for rspec
92
92
  email:
93
93
  - grotbart@gmail.com
@@ -109,7 +109,6 @@ files:
109
109
  - lib/gatling/comparison.rb
110
110
  - lib/gatling/config.rb
111
111
  - lib/gatling/image.rb
112
- - lib/gatling/image_wrangler.rb
113
112
  - lib/gatling/matchers/look_like_matcher.rb
114
113
  - lib/gatling/version.rb
115
114
  - pkg/gatling-0.0.1.gem
@@ -121,11 +120,11 @@ files:
121
120
  - spec/configuration_spec.rb
122
121
  - spec/gatling_spec.rb
123
122
  - spec/image_spec.rb
124
- - spec/image_wrangler_spec.rb
125
123
  - spec/integration/gatling_integration_spec.rb
126
124
  - spec/spec.opts
127
125
  - spec/spec_helper.rb
128
126
  - spec/support/assets/fruit_app.html
127
+ - temp-1032.rdb
129
128
  homepage: http://github.com/GabrielRotbart/gatling
130
129
  licenses: []
131
130
  post_install_message:
@@ -158,7 +157,6 @@ test_files:
158
157
  - spec/configuration_spec.rb
159
158
  - spec/gatling_spec.rb
160
159
  - spec/image_spec.rb
161
- - spec/image_wrangler_spec.rb
162
160
  - spec/integration/gatling_integration_spec.rb
163
161
  - spec/spec.opts
164
162
  - spec/spec_helper.rb
@@ -1,23 +0,0 @@
1
- module Gatling
2
- module ImageWrangler
3
-
4
- def self.get_element_position element
5
- element = element.native
6
- position = Hash.new{}
7
- position[:x] = element.location.x
8
- position[:y] = element.location.y
9
- position[:width] = element.size.width
10
- position[:height] = element.size.height
11
- position
12
- end
13
-
14
- def self.crop_element image, element_to_crop
15
- position = get_element_position(element_to_crop)
16
- @cropped_element = image.crop(position[:x], position[:y], position[:width], position[:height])
17
- end
18
-
19
-
20
-
21
-
22
- end
23
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gatling::ImageWrangler do
4
-
5
- class Point
6
- attr_accessor :x, :y
7
- end
8
-
9
- class Size
10
- attr_accessor :width, :height
11
- end
12
-
13
- it 'should get the position of the css element' do
14
-
15
- #Overiding the stupid public method:y of YAML module
16
-
17
- location = Point.new
18
- location.x = 1
19
- location.y = 2
20
-
21
- size = Size.new
22
- size.width = 100
23
- size.height = 200
24
-
25
- mock_element = mock
26
- mock_element.stub(:native).and_return(mock_element)
27
- mock_element.stub(:location).and_return(location)
28
- mock_element.stub(:size).and_return(size)
29
-
30
- position = Gatling::ImageWrangler.get_element_position(mock_element)
31
-
32
- position[:x].should eql(1)
33
- position[:y].should eql(2)
34
- position[:width].should eql(100)
35
- position[:height].should eql(200)
36
- end
37
-
38
-
39
-
40
-
41
- end