page-object 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -0
  4. data/ChangeLog +10 -0
  5. data/README.md +1 -1
  6. data/features/bold.feature +21 -0
  7. data/features/html/indexed_property.html +14 -0
  8. data/features/html/multi_elements.html +1 -1
  9. data/features/html/static_elements.html +1 -2
  10. data/features/indexed_property.feature +15 -0
  11. data/features/multi_elements.feature +6 -0
  12. data/features/step_definitions/async_steps.rb +1 -1
  13. data/features/step_definitions/bold_steps.rb +12 -0
  14. data/features/step_definitions/check_box_steps.rb +2 -2
  15. data/features/step_definitions/indexed_property_steps.rb +47 -1
  16. data/features/step_definitions/label_steps.rb +1 -1
  17. data/features/step_definitions/multi_elements_steps.rb +13 -0
  18. data/features/step_definitions/select_list_steps.rb +1 -1
  19. data/features/step_definitions/table_steps.rb +4 -0
  20. data/features/support/page.rb +9 -0
  21. data/features/table.feature +12 -4
  22. data/lib/page-object.rb +6 -5
  23. data/lib/page-object/accessors.rb +78 -58
  24. data/lib/page-object/elements.rb +1 -0
  25. data/lib/page-object/elements/bold.rb +11 -0
  26. data/lib/page-object/elements/element.rb +12 -1
  27. data/lib/page-object/elements/table.rb +12 -1
  28. data/lib/page-object/indexed_properties.rb +20 -21
  29. data/lib/page-object/javascript/angularjs.rb +14 -0
  30. data/lib/page-object/javascript_framework_facade.rb +4 -2
  31. data/lib/page-object/locator_generator.rb +1 -0
  32. data/lib/page-object/page_populator.rb +0 -1
  33. data/lib/page-object/platforms/selenium_webdriver/button.rb +1 -1
  34. data/lib/page-object/platforms/selenium_webdriver/element.rb +1 -1
  35. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +26 -10
  36. data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +0 -7
  37. data/lib/page-object/platforms/watir_webdriver/element.rb +1 -1
  38. data/lib/page-object/platforms/watir_webdriver/page_object.rb +23 -8
  39. data/lib/page-object/platforms/watir_webdriver/radio_button.rb +0 -7
  40. data/lib/page-object/version.rb +1 -1
  41. data/lib/page-object/widgets.rb +7 -0
  42. data/page-object.gemspec +3 -3
  43. data/spec/page-object/accessors_spec.rb +40 -0
  44. data/spec/page-object/element_locators_spec.rb +340 -305
  45. data/spec/page-object/elements/area_spec.rb +8 -8
  46. data/spec/page-object/elements/bold_spec.rb +29 -0
  47. data/spec/page-object/elements/button_spec.rb +7 -7
  48. data/spec/page-object/elements/canvas_spec.rb +6 -6
  49. data/spec/page-object/elements/check_box_spec.rb +9 -9
  50. data/spec/page-object/elements/div_spec.rb +3 -3
  51. data/spec/page-object/elements/element_spec.rb +21 -21
  52. data/spec/page-object/elements/file_field_spec.rb +4 -4
  53. data/spec/page-object/elements/form_spec.rb +3 -3
  54. data/spec/page-object/elements/heading_spec.rb +8 -8
  55. data/spec/page-object/elements/hidden_field_spec.rb +3 -3
  56. data/spec/page-object/elements/image_spec.rb +14 -14
  57. data/spec/page-object/elements/label_spec.rb +3 -3
  58. data/spec/page-object/elements/link_spec.rb +6 -6
  59. data/spec/page-object/elements/list_item_spec.rb +4 -3
  60. data/spec/page-object/elements/nested_element_spec.rb +47 -47
  61. data/spec/page-object/elements/option_spec.rb +1 -1
  62. data/spec/page-object/elements/ordered_list_spec.rb +33 -33
  63. data/spec/page-object/elements/paragraph_spec.rb +3 -4
  64. data/spec/page-object/elements/select_list_spec.rb +52 -52
  65. data/spec/page-object/elements/selenium/radio_button_spec.rb +7 -13
  66. data/spec/page-object/elements/selenium/text_field_spec.rb +7 -7
  67. data/spec/page-object/elements/selenium_element_spec.rb +53 -53
  68. data/spec/page-object/elements/span_spec.rb +3 -3
  69. data/spec/page-object/elements/table_cell_spec.rb +3 -3
  70. data/spec/page-object/elements/table_row_spec.rb +22 -22
  71. data/spec/page-object/elements/table_spec.rb +28 -28
  72. data/spec/page-object/elements/text_area_spec.rb +5 -5
  73. data/spec/page-object/elements/unordered_list_spec.rb +33 -34
  74. data/spec/page-object/elements/watir_element_spec.rb +47 -48
  75. data/spec/page-object/javascript_framework_facade_spec.rb +6 -6
  76. data/spec/page-object/loads_platform_spec.rb +4 -4
  77. data/spec/page-object/page-object_spec.rb +103 -102
  78. data/spec/page-object/page_factory_spec.rb +43 -61
  79. data/spec/page-object/page_populator_spec.rb +44 -50
  80. data/spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb +15 -15
  81. data/spec/page-object/platforms/selenium_webdriver_spec.rb +6 -6
  82. data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +4 -4
  83. data/spec/page-object/platforms/watir_webdriver_spec.rb +1 -1
  84. data/spec/page-object/selenium_accessors_spec.rb +166 -153
  85. data/spec/page-object/watir_accessors_spec.rb +265 -245
  86. data/spec/page-object/widget_spec.rb +62 -30
  87. data/spec/spec_helper.rb +8 -8
  88. metadata +20 -10
@@ -50,55 +50,55 @@ describe PageObject::PageFactory do
50
50
  class NoPO
51
51
  end
52
52
  @world.on(NoPO)
53
- @world.super_called.should be true
53
+ expect(@world.super_called).to be true
54
54
  end
55
55
 
56
56
  it "should create a new page object and execute a block" do
57
- @world.browser.should_not_receive(:goto)
57
+ expect(@world.browser).not_to receive(:goto)
58
58
  @world.on_page FactoryTestPage do |page|
59
- page.should be_instance_of FactoryTestPage
59
+ expect(page).to be_instance_of FactoryTestPage
60
60
  end
61
61
  @world.on_page "FactoryTestPage" do |page|
62
- page.should be_instance_of FactoryTestPage
62
+ expect(page).to be_instance_of FactoryTestPage
63
63
  end
64
64
  @world.on_page "ContainingModule::PageInsideModule" do |page|
65
- page.should be_instance_of ContainingModule::PageInsideModule
65
+ expect(page).to be_instance_of ContainingModule::PageInsideModule
66
66
  end
67
67
  end
68
68
 
69
69
  it "should create a new page object and execute a block using 'on'" do
70
- @world.browser.should_not_receive(:goto)
70
+ expect(@world.browser).not_to receive(:goto)
71
71
  @world.on FactoryTestPage do |page|
72
- page.should be_instance_of FactoryTestPage
72
+ expect(page).to be_instance_of FactoryTestPage
73
73
  end
74
74
  @world.on "FactoryTestPage" do |page|
75
- page.should be_instance_of FactoryTestPage
75
+ expect(page).to be_instance_of FactoryTestPage
76
76
  end
77
77
  @world.on "ContainingModule::PageInsideModule" do |page|
78
- page.should be_instance_of ContainingModule::PageInsideModule
78
+ expect(page).to be_instance_of ContainingModule::PageInsideModule
79
79
  end
80
80
  end
81
81
 
82
82
  it "should create and visit a new page" do
83
- @world.browser.should_receive(:goto).exactly(3).times
83
+ expect(@world.browser).to receive(:goto).exactly(3).times
84
84
  @world.visit_page FactoryTestPage do |page|
85
- page.should be_instance_of FactoryTestPage
85
+ expect(page).to be_instance_of FactoryTestPage
86
86
  end
87
87
  @world.visit_page "FactoryTestPage" do |page|
88
- page.should be_instance_of FactoryTestPage
88
+ expect(page).to be_instance_of FactoryTestPage
89
89
  end
90
90
  @world.visit_page "ContainingModule::PageInsideModule" do |page|
91
- page.should be_instance_of ContainingModule::PageInsideModule
91
+ expect(page).to be_instance_of ContainingModule::PageInsideModule
92
92
  end
93
93
  end
94
94
 
95
95
  it "should merge params with the class level params if provided when visiting" do
96
- @world.browser.should_receive(:goto)
96
+ expect(@world.browser).to receive(:goto)
97
97
  FactoryTestPage.params = {:initial => :value}
98
98
  @world.visit_page(FactoryTestPage, :using_params => {:new_value => :merged})
99
99
  merged = FactoryTestPage.instance_variable_get("@merged_params")
100
- merged[:initial].should == :value
101
- merged[:new_value].should == :merged
100
+ expect(merged[:initial]).to eql :value
101
+ expect(merged[:new_value]).to eql :merged
102
102
  end
103
103
 
104
104
  it "should use the params in the url when they are provided" do
@@ -106,7 +106,7 @@ describe PageObject::PageFactory do
106
106
  include PageObject
107
107
  page_url "http://google.com/<%=params[:value]%>"
108
108
  end
109
- @world.browser.should_receive(:goto).with("http://google.com/PageObject")
109
+ expect(@world.browser).to receive(:goto).with("http://google.com/PageObject")
110
110
  @world.visit_page(PageUsingParams, :using_params => {:value => 'PageObject'})
111
111
  end
112
112
 
@@ -115,34 +115,34 @@ describe PageObject::PageFactory do
115
115
  include PageObject
116
116
  page_url "http://google.com/#{1+2}/<%=params[:value]%>"
117
117
  end
118
- @world.browser.should_receive(:goto).with("http://google.com/3/PageObject")
118
+ expect(@world.browser).to receive(:goto).with("http://google.com/3/PageObject")
119
119
  @world.visit_page(PageUsingParmsAndInterpolated, :using_params => {:value => 'PageObject'})
120
120
  end
121
121
 
122
122
  it "should create and visit a new page using 'visit'" do
123
- @world.browser.should_receive(:goto).exactly(3).times
123
+ expect(@world.browser).to receive(:goto).exactly(3).times
124
124
  @world.visit FactoryTestPage do |page|
125
- page.should be_instance_of FactoryTestPage
125
+ expect(page).to be_instance_of FactoryTestPage
126
126
  end
127
127
  @world.visit "FactoryTestPage" do |page|
128
- page.should be_instance_of FactoryTestPage
128
+ expect(page).to be_instance_of FactoryTestPage
129
129
  end
130
130
  @world.visit "ContainingModule::PageInsideModule" do |page|
131
- page.should be_instance_of ContainingModule::PageInsideModule
131
+ expect(page).to be_instance_of ContainingModule::PageInsideModule
132
132
  end
133
133
  end
134
134
 
135
135
  it "should create and visit a new page when url is defined as 'direct_url'" do
136
- @world.browser.should_receive(:goto)
136
+ expect(@world.browser).to receive(:goto)
137
137
  @world.visit TestPageWithDirectUrl do |page|
138
- page.should be_instance_of TestPageWithDirectUrl
138
+ expect(page).to be_instance_of TestPageWithDirectUrl
139
139
  end
140
140
  end
141
141
 
142
142
  it "should set an instance variable that can be used outside of the block" do
143
143
  page = @world.on_page FactoryTestPage
144
144
  current_page = @world.instance_variable_get "@current_page"
145
- current_page.should === page
145
+ expect(current_page).to equal page
146
146
  end
147
147
 
148
148
  it "should not execute block if page is not @current_page" do
@@ -161,9 +161,9 @@ describe PageObject::PageFactory do
161
161
  it "should return the @current_page if asking for another page" do
162
162
  expected = TestPageWithDirectUrl.new(@world.browser)
163
163
  @world.instance_variable_set "@current_page", expected
164
- @world.if_page(FactoryTestPage).should == expected
165
- @world.if_page("FactoryTestPage").should == expected
166
- @world.if_page("ContainingModule::PageInsideModule").should == expected
164
+ expect(@world.if_page(FactoryTestPage)).to eql expected
165
+ expect(@world.if_page("FactoryTestPage")).to eql expected
166
+ expect(@world.if_page("ContainingModule::PageInsideModule")).to eql expected
167
167
  end
168
168
 
169
169
  it "should execute the block when we ask if it is the correct page" do
@@ -171,25 +171,25 @@ describe PageObject::PageFactory do
171
171
 
172
172
  done = false
173
173
  @world.if_page(FactoryTestPage) do |page|
174
- page.should be_instance_of FactoryTestPage
174
+ expect(page).to be_instance_of FactoryTestPage
175
175
  done = true
176
176
  end
177
- done.should be true
177
+ expect(done).to be true
178
178
 
179
179
  done = false
180
180
  @world.if_page("FactoryTestPage") do |page|
181
- page.should be_instance_of FactoryTestPage
181
+ expect(page).to be_instance_of FactoryTestPage
182
182
  done = true
183
183
  end
184
- done.should be true
184
+ expect(done).to be true
185
185
 
186
186
  done = false
187
187
  @world.instance_variable_set "@current_page", ContainingModule::PageInsideModule.new(@world.browser)
188
188
  @world.if_page("ContainingModule::PageInsideModule") do |page|
189
- page.should be_instance_of ContainingModule::PageInsideModule
189
+ expect(page).to be_instance_of ContainingModule::PageInsideModule
190
190
  done = true
191
191
  end
192
- done.should be true
192
+ expect(done).to be true
193
193
  end
194
194
 
195
195
  it "should raise an error when you do not provide a default route" do
@@ -199,25 +199,25 @@ describe PageObject::PageFactory do
199
199
  it "should store the routes" do
200
200
  routes = ['a', 'b', 'c']
201
201
  PageObject::PageFactory.routes = {:default => routes}
202
- PageObject::PageFactory.routes[:default].should == routes
202
+ expect(PageObject::PageFactory.routes[:default]).to eql routes
203
203
  end
204
204
 
205
205
  it "should navigate to a page calling the default methods" do
206
206
  pages = [[FactoryTestPage, :a_method], [AnotherPage, :b_method]]
207
207
  PageObject::PageFactory.routes = {:default => pages}
208
208
  fake_page = double('a_page')
209
- FactoryTestPage.should_receive(:new).and_return(fake_page)
210
- fake_page.should_receive(:a_method)
211
- @world.navigate_to(AnotherPage).class.should == AnotherPage
209
+ expect(FactoryTestPage).to receive(:new).and_return(fake_page)
210
+ expect(fake_page).to receive(:a_method)
211
+ expect(@world.navigate_to(AnotherPage).class).to eql AnotherPage
212
212
  end
213
213
 
214
214
  it "should pass parameters to methods when navigating" do
215
215
  pages = [[FactoryTestPage, :a_method, 'blah'], [AnotherPage, :b_method]]
216
216
  PageObject::PageFactory.routes = {:default => pages}
217
217
  fake_page = double('a_page')
218
- FactoryTestPage.should_receive(:new).and_return(fake_page)
219
- fake_page.should_receive(:a_method).with('blah')
220
- @world.navigate_to(AnotherPage).class.should == AnotherPage
218
+ expect(FactoryTestPage).to receive(:new).and_return(fake_page)
219
+ expect(fake_page).to receive(:a_method).with('blah')
220
+ expect(@world.navigate_to(AnotherPage).class).to eql AnotherPage
221
221
  end
222
222
 
223
223
  it "should fail when it does not find a proper route" do
@@ -230,27 +230,9 @@ describe PageObject::PageFactory do
230
230
  :default => [[FactoryTestPage, :a_method], [AnotherPage, :b_method]]
231
231
  }
232
232
  fake_page = double('a_page')
233
- FactoryTestPage.should_receive(:new).and_return(fake_page)
234
- fake_page.should_receive(:respond_to?).with(:a_method).and_return(false)
233
+ expect(FactoryTestPage).to receive(:new).and_return(fake_page)
234
+ expect(fake_page).to receive(:respond_to?).with(:a_method).and_return(false)
235
235
  expect { @world.navigate_to(AnotherPage) }.to raise_error
236
236
  end
237
237
 
238
- it "should know how to continue routing from a location" do
239
- PageObject::PageFactory.routes = {
240
- :default => [[FactoryTestPage, :a_method],
241
- [AnotherPage, :b_method],
242
- [YetAnotherPage, :c_method]]
243
- }
244
-
245
- @world.current_page = FactoryTestPage.new(@world.browser)
246
- f_page = FactoryTestPage.new(@world.browser)
247
- FactoryTestPage.should_receive(:new).and_return(f_page)
248
- f_page.should_receive(:respond_to?).with(:a_method).and_return(true)
249
- f_page.should_receive(:a_method)
250
- a_page = AnotherPage.new(@world.browser)
251
- AnotherPage.should_receive(:new).and_return(a_page)
252
- a_page.should_receive(:respond_to?).with(:b_method).and_return(true)
253
- a_page.should_receive(:b_method)
254
- @world.continue_navigation_to(YetAnotherPage).class.should == YetAnotherPage
255
- end
256
238
  end
@@ -17,112 +17,106 @@ describe PageObject::PagePopulator do
17
17
  let(:page_object) { PageObjectTestPageObject.new(browser) }
18
18
 
19
19
  it "should set a value in a text field" do
20
- page_object.should_receive(:tf=).with('value')
21
- page_object.stub(:is_enabled?).and_return(true)
20
+ expect(page_object).to receive(:tf=).with('value')
21
+ allow(page_object).to receive(:is_enabled?).and_return(true)
22
22
  page_object.populate_page_with('tf' => 'value')
23
23
  end
24
24
 
25
25
  it "should not set a value in a text field if it is not found on the page" do
26
- browser.should_not_receive(:text_field)
26
+ expect(browser).not_to receive(:text_field)
27
27
  page_object.populate_page_with('coffee' => 'value')
28
28
  end
29
29
 
30
30
  it "should not populate a text field when it is disabled" do
31
- page_object.should_not_receive(:tf=)
32
- page_object.should_receive(:tf_element).twice.and_return(browser)
33
- browser.should_receive(:enabled?).and_return(false)
34
- browser.should_receive(:tag_name).and_return('input')
31
+ expect(page_object).not_to receive(:tf=)
32
+ expect(page_object).to receive(:tf_element).twice.and_return(browser)
33
+ expect(browser).to receive(:enabled?).and_return(false)
34
+ expect(browser).to receive(:tag_name).and_return('input')
35
35
  page_object.populate_page_with('tf' => true)
36
36
  end
37
37
 
38
38
  it "should not populate a text field when it is not visible" do
39
- page_object.should_not_receive(:tf=)
40
- page_object.should_receive(:tf_element).twice.and_return(browser)
41
- browser.should_receive(:enabled?).and_return(true)
42
- browser.should_receive(:visible?).and_return(false)
43
- browser.should_receive(:tag_name).and_return('input')
39
+ expect(page_object).not_to receive(:tf=)
40
+ expect(page_object).to receive(:tf_element).twice.and_return(browser)
41
+ expect(browser).to receive(:enabled?).and_return(true)
42
+ expect(browser).to receive(:visible?).and_return(false)
43
+ expect(browser).to receive(:tag_name).and_return('input')
44
44
  page_object.populate_page_with('tf' => true)
45
45
  end
46
46
 
47
47
  it "should set a value in a text area" do
48
- page_object.should_receive(:ta=).with('value')
49
- page_object.should_receive(:ta_element).and_return(browser)
50
- browser.should_receive(:tag_name).and_return('textarea')
48
+ expect(page_object).to receive(:ta=).with('value')
49
+ expect(page_object).to receive(:ta_element).and_return(browser)
50
+ expect(browser).to receive(:tag_name).and_return('textarea')
51
51
  page_object.populate_page_with('ta' => 'value')
52
52
  end
53
53
 
54
54
  it "should set a value in a select list" do
55
- page_object.should_receive(:sl=).with('value')
56
- page_object.stub(:is_enabled?).and_return(true)
55
+ expect(page_object).to receive(:sl=).with('value')
56
+ allow(page_object).to receive(:is_enabled?).and_return(true)
57
57
  page_object.populate_page_with('sl' => 'value')
58
58
  end
59
59
 
60
60
  it "should set a value in a file field" do
61
- page_object.should_receive(:ff=).with('value')
62
- page_object.stub(:is_enabled?).and_return(true)
61
+ expect(page_object).to receive(:ff=).with('value')
62
+ allow(page_object).to receive(:is_enabled?).and_return(true)
63
63
  page_object.populate_page_with('ff' => 'value')
64
64
  end
65
65
 
66
66
  it "should check a checkbox to true is specified" do
67
- page_object.should_receive(:check_cb)
68
- page_object.stub(:is_enabled?).and_return(true)
67
+ expect(page_object).to receive(:check_cb)
68
+ allow(page_object).to receive(:is_enabled?).and_return(true)
69
69
  page_object.populate_page_with('cb' => true)
70
70
  end
71
71
 
72
72
  it "should uncheck a checkbox to false is specified" do
73
- page_object.should_receive(:uncheck_cb)
74
- page_object.stub(:is_enabled?).and_return(true)
73
+ expect(page_object).to receive(:uncheck_cb)
74
+ allow(page_object).to receive(:is_enabled?).and_return(true)
75
75
  page_object.populate_page_with('cb' => false)
76
76
  end
77
77
 
78
78
  it "should select a radio button when true is specified" do
79
- page_object.should_receive(:select_rb)
80
- page_object.stub(:is_enabled?).and_return(true)
79
+ expect(page_object).to receive(:select_rb)
80
+ allow(page_object).to receive(:is_enabled?).and_return(true)
81
81
  page_object.populate_page_with('rb' => true)
82
82
  end
83
83
 
84
- it "should clear a radio button when false is specified" do
85
- page_object.should_receive(:clear_rb)
86
- page_object.stub(:is_enabled?).and_return(true)
87
- page_object.populate_page_with('rb' => false)
88
- end
89
-
90
84
  it "should select the correct element from a radio button group" do
91
- page_object.should_receive(:select_rbg).with('blah')
85
+ expect(page_object).to receive(:select_rbg).with('blah')
92
86
  page_object.populate_page_with('rbg' => 'blah')
93
87
  end
94
88
 
95
89
  it "should not populate a checkbox if it is disabled" do
96
- page_object.should_not_receive(:check_cb)
97
- page_object.should_receive(:cb_element).twice.and_return(browser)
98
- browser.should_receive(:enabled?).and_return(false)
99
- browser.should_receive(:tag_name).and_return('input')
90
+ expect(page_object).not_to receive(:check_cb)
91
+ expect(page_object).to receive(:cb_element).twice.and_return(browser)
92
+ expect(browser).to receive(:enabled?).and_return(false)
93
+ expect(browser).to receive(:tag_name).and_return('input')
100
94
  page_object.populate_page_with('cb' => true)
101
95
  end
102
96
 
103
97
  it "should not populate a checkbox if it is not visible" do
104
- page_object.should_not_receive(:check_cb)
105
- page_object.should_receive(:cb_element).twice.and_return(browser)
106
- browser.should_receive(:enabled?).and_return(true)
107
- browser.should_receive(:visible?).and_return(false)
108
- browser.should_receive(:tag_name).and_return('input')
98
+ expect(page_object).not_to receive(:check_cb)
99
+ expect(page_object).to receive(:cb_element).twice.and_return(browser)
100
+ expect(browser).to receive(:enabled?).and_return(true)
101
+ expect(browser).to receive(:visible?).and_return(false)
102
+ expect(browser).to receive(:tag_name).and_return('input')
109
103
  page_object.populate_page_with('cb' => true)
110
104
  end
111
105
 
112
106
  it "should not populate a radio button when it is disabled" do
113
- page_object.should_not_receive(:select_rb)
114
- page_object.should_receive(:rb_element).twice.and_return(browser)
115
- browser.should_receive(:enabled?).and_return(false)
116
- browser.should_receive(:tag_name).and_return('input')
107
+ expect(page_object).not_to receive(:select_rb)
108
+ expect(page_object).to receive(:rb_element).twice.and_return(browser)
109
+ expect(browser).to receive(:enabled?).and_return(false)
110
+ expect(browser).to receive(:tag_name).and_return('input')
117
111
  page_object.populate_page_with('rb' => true)
118
112
  end
119
113
 
120
114
  it "should not populate a radio button when it is not visible" do
121
- page_object.should_not_receive(:select_rb)
122
- page_object.should_receive(:rb_element).twice.and_return(browser)
123
- browser.should_receive(:enabled?).and_return(true)
124
- browser.should_receive(:visible?).and_return(false)
125
- browser.should_receive(:tag_name).and_return('input')
115
+ expect(page_object).not_to receive(:select_rb)
116
+ expect(page_object).to receive(:rb_element).twice.and_return(browser)
117
+ expect(browser).to receive(:enabled?).and_return(true)
118
+ expect(browser).to receive(:visible?).and_return(false)
119
+ expect(browser).to receive(:tag_name).and_return('input')
126
120
  page_object.populate_page_with('rb' => true)
127
121
  end
128
122
  end
@@ -11,55 +11,55 @@ describe PageObject::Platforms::SeleniumWebDriver::PageObject do
11
11
  let(:selenium_page_object) { SeleniumTestPageObject.new(selenium_browser) }
12
12
 
13
13
  before(:each) do
14
- selenium_browser.stub(:switch_to).and_return(selenium_browser)
15
- selenium_browser.stub(:default_content)
14
+ allow(selenium_browser).to receive(:switch_to).and_return(selenium_browser)
15
+ allow(selenium_browser).to receive(:default_content)
16
16
  end
17
17
 
18
18
  context "when building identifiers hash" do
19
19
  it "should add tag_name when identifying by text for hidden_field" do
20
20
  expected_identifier = {:text => 'foo', :tag_name => 'input', :type => 'hidden'}
21
- PageObject::Elements::HiddenField.should_receive(:selenium_identifier_for).with(expected_identifier)
22
- selenium_browser.should_receive(:find_element)
21
+ expect(PageObject::Elements::HiddenField).to receive(:selenium_identifier_for).with(expected_identifier)
22
+ expect(selenium_browser).to receive(:find_element)
23
23
  selenium_page_object.platform.hidden_field_for(:text => 'foo')
24
24
  end
25
25
 
26
26
  it "should add tag_name when identifying by href for anchor" do
27
27
  expected_identifier = {:href => 'foo', :tag_name => 'a'}
28
- PageObject::Elements::Link.should_receive(:selenium_identifier_for).with(expected_identifier)
29
- selenium_browser.should_receive(:find_element)
28
+ expect(PageObject::Elements::Link).to receive(:selenium_identifier_for).with(expected_identifier)
29
+ expect(selenium_browser).to receive(:find_element)
30
30
  selenium_page_object.platform.link_for(:href => 'foo')
31
31
  end
32
32
 
33
33
  it "should add tag_name when identifying by text for div" do
34
34
  expected_identifier = {:text => 'foo', :tag_name => 'div'}
35
- PageObject::Elements::Div.should_receive(:selenium_identifier_for).with(expected_identifier)
36
- selenium_browser.should_receive(:find_element)
35
+ expect(PageObject::Elements::Div).to receive(:selenium_identifier_for).with(expected_identifier)
36
+ expect(selenium_browser).to receive(:find_element)
37
37
  selenium_page_object.platform.div_for(:text => 'foo')
38
38
  end
39
39
  end
40
40
 
41
41
  context "when trying to find an element that does not exist" do
42
42
  it "should return a surogate selenium object" do
43
- selenium_browser.should_receive(:find_element).and_raise(Selenium::WebDriver::Error::NoSuchElementError)
43
+ expect(selenium_browser).to receive(:find_element).and_raise(Selenium::WebDriver::Error::NoSuchElementError)
44
44
  page = SeleniumTestPageObject.new(selenium_browser)
45
45
  element = page.link_element(:text => 'blah')
46
- element.element.should be_instance_of PageObject::Platforms::SeleniumWebDriver::SurrogateSeleniumElement
46
+ expect(element.element).to be_instance_of PageObject::Platforms::SeleniumWebDriver::SurrogateSeleniumElement
47
47
  end
48
48
 
49
49
  it "should know it is not exist" do
50
- selenium_browser.should_receive(:find_element).twice.and_raise(Selenium::WebDriver::Error::NoSuchElementError)
50
+ expect(selenium_browser).to receive(:find_element).twice.and_raise(Selenium::WebDriver::Error::NoSuchElementError)
51
51
  page = SeleniumTestPageObject.new(selenium_browser)
52
- page.link_element(:text => 'blah').element.exists?.should be false
52
+ expect(page.link_element(:text => 'blah').element.exists?).to be false
53
53
  end
54
54
 
55
55
  it "should know it is not visible" do
56
- selenium_browser.should_receive(:find_element).twice.and_raise(Selenium::WebDriver::Error::NoSuchElementError)
56
+ expect(selenium_browser).to receive(:find_element).twice.and_raise(Selenium::WebDriver::Error::NoSuchElementError)
57
57
  page = SeleniumTestPageObject.new(selenium_browser)
58
- page.link_element(:text => 'blah').element.should_not be_visible
58
+ expect(page.link_element(:text => 'blah').element).not_to be_visible
59
59
  end
60
60
 
61
61
  it "should raise an error when actions are requested" do
62
- selenium_browser.should_receive(:find_element).and_raise(Selenium::WebDriver::Error::NoSuchElementError)
62
+ expect(selenium_browser).to receive(:find_element).and_raise(Selenium::WebDriver::Error::NoSuchElementError)
63
63
  page = SeleniumTestPageObject.new(selenium_browser)
64
64
  element = page.link_element(:text => 'blah')
65
65
  expect { element.text }.to raise_error