swamp 1.1.1 → 1.1.2

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: bcb2c79e5db079a0287653e389ac0a7c2e75bad4
4
- data.tar.gz: fb16c36d0a0a474f0d7f9a2831e6a2ba9ec59a53
3
+ metadata.gz: b6ab9f667564af8b8a224893d26848f2eed6e4c7
4
+ data.tar.gz: 47ba68f51f80b0a25b8fd1344c6e1faa2f30adb9
5
5
  SHA512:
6
- metadata.gz: 72243992df25d1720de156ad2d02bcf032247d921336d7dae6dbdb4290b47f368f2c2312757da74bf6b4e4d4ab3f86d7bde7912956127f4739e0efc7563a12ad
7
- data.tar.gz: 4faf0ab8d0ef50304eb9e21511a1eada1b8e0d8e5640681b65861257a5f8f7d17d7ca5bf0f3b2603d9214fd9f3d57724902d1c09f9f4ba7281e4e90c17ac8145
6
+ metadata.gz: 95d1df06d75df7a27a5a48f96e97caf2364f07f8dddfe241906e5eb7b126b04f15487ea990d2bd148288b075c83edfe02324bdb80d7c5b17b9770bc434c9b2a6
7
+ data.tar.gz: 725f4c672d632660446e777a8688dfdb8a03183f45b4ceba59f5fff02e117edd972d5d99d2029181657f7e975f85519b29f1c7fd7362aabb21ff6200bd61c30a
@@ -2,7 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - jruby-19mode # JRuby in 1.9 mode
5
- - rbx-19mode
6
5
  before_script:
7
6
  - "export DISPLAY=:99.0"
8
7
  - "sh -e /etc/init.d/xvfb start"
@@ -28,3 +28,14 @@ Feature: user scans select box elements in a page
28
28
  source.select(option, :from => "Region")
29
29
  end
30
30
  """
31
+
32
+ Scenario: A select box that doesn't has either id or name
33
+ Given I enter the url for this page: "select_without_id_and_name.html"
34
+ When swamp scans that page
35
+ Then swamp should highlight this element: "select.provider-select"
36
+ And it should output the following code snippet
37
+ """
38
+ def provider_select(option)
39
+ source.find(:css, "select.provider-select option[value='#{option}']").click
40
+ end
41
+ """
@@ -0,0 +1 @@
1
+ <select class="provider-select" data-bound-key="region"><optgroup label="Next Generation Cloud Servers"><option value="compute,cloudServersOpenStack,ORD">Chicago (ORD)</option><option value="compute,cloudServersOpenStack,IAD">Northern Virginia (IAD)</option><option value="compute,cloudServersOpenStack,DFW">Dallas (DFW)</option><option value="compute,cloudServersOpenStack,HKG">Hong Kong (HKG)</option><option value="compute,cloudServersOpenStack,SYD">Sydney (SYD)</option></optgroup><optgroup label="First Generation Cloud Servers"><option value="compute,cloudServers">Dallas (DFW)</option></optgroup></select>
@@ -15,6 +15,7 @@ require 'swamp/input_buttons'
15
15
  require 'swamp/input_button'
16
16
  require 'swamp/select_boxes'
17
17
  require 'swamp/select_box'
18
+ require 'swamp/complex_select_box'
18
19
  require 'swamp/links'
19
20
  require 'swamp/link'
20
21
 
@@ -0,0 +1,11 @@
1
+ module Swamp
2
+ class ComplexSelectBox < Element
3
+ def method_signature
4
+ "#{format(@name)}(option)"
5
+ end
6
+
7
+ def accessor
8
+ %/find(:css, \"select.#{@selector} option[value='\#{option}']\").click/
9
+ end
10
+ end
11
+ end
@@ -10,6 +10,9 @@ module Swamp
10
10
  elsif has_name?(element)
11
11
  shine %/select[name='#{element["name"]}']/
12
12
  elements << Swamp::SelectBox.new(element["name"], element["name"])
13
+ else
14
+ shine %/select.#{element["class"]}/
15
+ elements << Swamp::ComplexSelectBox.new(element["class"], element["class"])
13
16
  end
14
17
  end
15
18
  end
@@ -1,3 +1,3 @@
1
1
  module Swamp
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -63,6 +63,32 @@ module Swamp
63
63
  select_boxes.get.first.selector.should == "birthday_month"
64
64
  end
65
65
  end
66
+
67
+ context "when the select element doesn't has either id or name" do
68
+ let(:element) { {'class' => "provider-select"} }
69
+
70
+ before(:each) do
71
+ element.stub(:visible?).and_return(true)
72
+ select_boxes.page.stub(:all).with('select').and_return([element])
73
+ end
74
+
75
+ it "highlights the element" do
76
+ select_boxes.page.should_receive(:execute_script).twice
77
+ select_boxes.get
78
+ end
79
+
80
+ it "returns the element in the array using the class as the name" do
81
+ select_boxes.page.stub(:execute_script).and_return(nil)
82
+ select_boxes.get.should have(1).select_box
83
+ select_boxes.get.first.name.should == "provider-select"
84
+ end
85
+
86
+ it "returns the element in the array using the class as the selector" do
87
+ select_boxes.page.stub(:execute_script).and_return(nil)
88
+ select_boxes.get.should have(1).select_box
89
+ select_boxes.get.first.selector.should == "provider-select"
90
+ end
91
+ end
66
92
  end
67
93
  end
68
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juraci de Lima Vieira Neto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2014-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -179,12 +179,14 @@ files:
179
179
  - features/support/page_examples/radio.html
180
180
  - features/support/page_examples/select_box_with_id.html
181
181
  - features/support/page_examples/select_box_with_name_only.html
182
+ - features/support/page_examples/select_without_id_and_name.html
182
183
  - features/support/setup.rb
183
184
  - lib/swamp.rb
184
185
  - lib/swamp/base.rb
185
186
  - lib/swamp/builder.rb
186
187
  - lib/swamp/button.rb
187
188
  - lib/swamp/buttons.rb
189
+ - lib/swamp/complex_select_box.rb
188
190
  - lib/swamp/element.rb
189
191
  - lib/swamp/elements.rb
190
192
  - lib/swamp/evaluator.rb
@@ -265,6 +267,7 @@ test_files:
265
267
  - features/support/page_examples/radio.html
266
268
  - features/support/page_examples/select_box_with_id.html
267
269
  - features/support/page_examples/select_box_with_name_only.html
270
+ - features/support/page_examples/select_without_id_and_name.html
268
271
  - features/support/setup.rb
269
272
  - spec/spec_helper.rb
270
273
  - spec/swamp/builder_spec.rb