capybara 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +26 -0
  3. data/README.md +36 -14
  4. data/lib/capybara.rb +6 -3
  5. data/lib/capybara/driver/base.rb +37 -1
  6. data/lib/capybara/driver/node.rb +10 -2
  7. data/lib/capybara/helpers.rb +21 -13
  8. data/lib/capybara/node/base.rb +12 -7
  9. data/lib/capybara/node/element.rb +17 -1
  10. data/lib/capybara/node/finders.rb +22 -1
  11. data/lib/capybara/node/matchers.rb +26 -5
  12. data/lib/capybara/node/simple.rb +9 -2
  13. data/lib/capybara/rack_test/css_handlers.rb +3 -1
  14. data/lib/capybara/rack_test/form.rb +3 -2
  15. data/lib/capybara/rack_test/node.rb +3 -3
  16. data/lib/capybara/rspec.rb +1 -0
  17. data/lib/capybara/rspec/features.rb +2 -1
  18. data/lib/capybara/rspec/matchers.rb +50 -5
  19. data/lib/capybara/selenium/driver.rb +76 -12
  20. data/lib/capybara/selenium/node.rb +8 -0
  21. data/lib/capybara/server.rb +1 -1
  22. data/lib/capybara/session.rb +234 -29
  23. data/lib/capybara/spec/public/jquery.js +1 -1
  24. data/lib/capybara/spec/public/test.js +7 -0
  25. data/lib/capybara/spec/session/all_spec.rb +88 -17
  26. data/lib/capybara/spec/session/assert_selector.rb +6 -0
  27. data/lib/capybara/spec/session/attach_file_spec.rb +15 -15
  28. data/lib/capybara/spec/session/body_spec.rb +4 -4
  29. data/lib/capybara/spec/session/check_spec.rb +16 -16
  30. data/lib/capybara/spec/session/choose_spec.rb +5 -5
  31. data/lib/capybara/spec/session/click_button_spec.rb +93 -84
  32. data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -8
  33. data/lib/capybara/spec/session/click_link_spec.rb +26 -19
  34. data/lib/capybara/spec/session/current_scope_spec.rb +3 -3
  35. data/lib/capybara/spec/session/current_url_spec.rb +8 -8
  36. data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
  37. data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
  38. data/lib/capybara/spec/session/fill_in_spec.rb +22 -22
  39. data/lib/capybara/spec/session/find_button_spec.rb +4 -4
  40. data/lib/capybara/spec/session/find_by_id_spec.rb +3 -3
  41. data/lib/capybara/spec/session/find_field_spec.rb +7 -7
  42. data/lib/capybara/spec/session/find_link_spec.rb +4 -4
  43. data/lib/capybara/spec/session/find_spec.rb +46 -46
  44. data/lib/capybara/spec/session/first_spec.rb +23 -23
  45. data/lib/capybara/spec/session/go_back_spec.rb +3 -3
  46. data/lib/capybara/spec/session/go_forward_spec.rb +4 -4
  47. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  48. data/lib/capybara/spec/session/has_css_spec.rb +87 -87
  49. data/lib/capybara/spec/session/has_field_spec.rb +87 -87
  50. data/lib/capybara/spec/session/has_link_spec.rb +11 -11
  51. data/lib/capybara/spec/session/has_select_spec.rb +58 -58
  52. data/lib/capybara/spec/session/has_selector_spec.rb +48 -48
  53. data/lib/capybara/spec/session/has_table_spec.rb +7 -7
  54. data/lib/capybara/spec/session/has_text_spec.rb +73 -73
  55. data/lib/capybara/spec/session/has_title_spec.rb +10 -10
  56. data/lib/capybara/spec/session/has_xpath_spec.rb +44 -44
  57. data/lib/capybara/spec/session/headers.rb +1 -1
  58. data/lib/capybara/spec/session/html_spec.rb +9 -9
  59. data/lib/capybara/spec/session/node_spec.rb +81 -65
  60. data/lib/capybara/spec/session/reset_session_spec.rb +15 -15
  61. data/lib/capybara/spec/session/response_code.rb +1 -1
  62. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +46 -0
  63. data/lib/capybara/spec/session/save_page_spec.rb +9 -9
  64. data/lib/capybara/spec/session/{screenshot.rb → screenshot_spec.rb} +4 -2
  65. data/lib/capybara/spec/session/select_spec.rb +22 -22
  66. data/lib/capybara/spec/session/text_spec.rb +15 -10
  67. data/lib/capybara/spec/session/title_spec.rb +2 -2
  68. data/lib/capybara/spec/session/uncheck_spec.rb +7 -7
  69. data/lib/capybara/spec/session/unselect_spec.rb +14 -14
  70. data/lib/capybara/spec/session/visit_spec.rb +24 -17
  71. data/lib/capybara/spec/session/window/become_closed_spec.rb +84 -0
  72. data/lib/capybara/spec/session/window/current_window_spec.rb +25 -0
  73. data/lib/capybara/spec/session/window/open_new_window_spec.rb +28 -0
  74. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +114 -0
  75. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +83 -0
  76. data/lib/capybara/spec/session/window/window_spec.rb +141 -0
  77. data/lib/capybara/spec/session/window/windows_spec.rb +31 -0
  78. data/lib/capybara/spec/session/window/within_window_spec.rb +188 -0
  79. data/lib/capybara/spec/session/within_frame_spec.rb +9 -9
  80. data/lib/capybara/spec/session/within_spec.rb +16 -16
  81. data/lib/capybara/spec/spec_helper.rb +14 -4
  82. data/lib/capybara/spec/views/form.erb +7 -0
  83. data/lib/capybara/spec/views/popup_one.erb +1 -1
  84. data/lib/capybara/spec/views/popup_two.erb +1 -1
  85. data/lib/capybara/spec/views/with_js.erb +2 -0
  86. data/lib/capybara/spec/views/with_windows.erb +38 -0
  87. data/lib/capybara/version.rb +1 -1
  88. data/lib/capybara/window.rb +123 -0
  89. data/spec/basic_node_spec.rb +32 -32
  90. data/spec/capybara_spec.rb +6 -7
  91. data/spec/dsl_spec.rb +48 -48
  92. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
  93. data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
  94. data/spec/rack_test_spec.rb +33 -19
  95. data/spec/result_spec.rb +13 -13
  96. data/spec/rspec/features_spec.rb +20 -15
  97. data/spec/rspec/matchers_spec.rb +109 -109
  98. data/spec/rspec_spec.rb +10 -10
  99. data/spec/selenium_spec.rb +31 -6
  100. data/spec/selenium_spec_chrome.rb +2 -2
  101. data/spec/server_spec.rb +13 -13
  102. metadata +51 -62
  103. checksums.yaml.gz.sig +0 -0
  104. data.tar.gz.sig +0 -0
  105. data/lib/capybara/spec/session/within_window_spec.rb +0 -45
  106. data/lib/capybara/spec/views/within_popups.erb +0 -25
  107. metadata.gz.sig +0 -0
@@ -8,21 +8,21 @@ Capybara::SpecHelper.spec '#within' do
8
8
  @session.within(:css, "#for_bar li", text: 'With Simple HTML') do
9
9
  @session.click_link('Go')
10
10
  end
11
- @session.should have_content('Bar')
11
+ expect(@session).to have_content('Bar')
12
12
  end
13
13
 
14
14
  it "should assert content in the given scope" do
15
15
  @session.within(:css, "#for_foo") do
16
- @session.should_not have_content('First Name')
16
+ expect(@session).not_to have_content('First Name')
17
17
  end
18
- @session.should have_content('First Name')
18
+ expect(@session).to have_content('First Name')
19
19
  end
20
20
 
21
21
  it "should accept additional options" do
22
22
  @session.within(:css, "#for_bar li", :text => 'With Simple HTML') do
23
23
  @session.click_link('Go')
24
24
  end
25
- @session.should have_content('Bar')
25
+ expect(@session).to have_content('Bar')
26
26
  end
27
27
  end
28
28
 
@@ -31,7 +31,7 @@ Capybara::SpecHelper.spec '#within' do
31
31
  @session.within(:xpath, "//div[@id='for_bar']//li[contains(.,'With Simple HTML')]") do
32
32
  @session.click_link('Go')
33
33
  end
34
- @session.should have_content('Bar')
34
+ expect(@session).to have_content('Bar')
35
35
  end
36
36
  end
37
37
 
@@ -40,7 +40,7 @@ Capybara::SpecHelper.spec '#within' do
40
40
  @session.within("//div[@id='for_bar']//li[contains(.,'With Simple HTML')]") do
41
41
  @session.click_link('Go')
42
42
  end
43
- @session.should have_content('Bar')
43
+ expect(@session).to have_content('Bar')
44
44
  end
45
45
  end
46
46
 
@@ -51,7 +51,7 @@ Capybara::SpecHelper.spec '#within' do
51
51
  @session.within(node_of_interest) do
52
52
  @session.click_link('Go')
53
53
  end
54
- @session.should have_content('Bar')
54
+ expect(@session).to have_content('Bar')
55
55
  end
56
56
  end
57
57
 
@@ -61,7 +61,7 @@ Capybara::SpecHelper.spec '#within' do
61
61
  @session.within("#for_bar li", text: 'With Simple HTML') do
62
62
  @session.click_link('Go')
63
63
  end
64
- @session.should have_content('Bar')
64
+ expect(@session).to have_content('Bar')
65
65
  end
66
66
  after { Capybara.default_selector = :xpath }
67
67
  end
@@ -73,7 +73,7 @@ Capybara::SpecHelper.spec '#within' do
73
73
  @session.click_link('Go')
74
74
  end
75
75
  end
76
- @session.should have_content('Another World')
76
+ expect(@session).to have_content('Another World')
77
77
  end
78
78
 
79
79
  it "should respect the outer scope" do
@@ -82,7 +82,7 @@ Capybara::SpecHelper.spec '#within' do
82
82
  @session.click_link('Go')
83
83
  end
84
84
  end
85
- @session.should have_content('Hello world')
85
+ expect(@session).to have_content('Hello world')
86
86
  end
87
87
  end
88
88
 
@@ -110,13 +110,13 @@ Capybara::SpecHelper.spec '#within' do
110
110
  @session.within("//li[contains(.,'Bar')]") do
111
111
  @session.click_button('Go')
112
112
  end
113
- extract_results(@session)['first_name'].should == 'Peter'
113
+ expect(extract_results(@session)['first_name']).to eq('Peter')
114
114
  @session.visit('/with_scope')
115
115
  @session.within("//li[contains(.,'Bar')]") do
116
116
  @session.fill_in('First Name', :with => 'Dagobert')
117
117
  @session.click_button('Go')
118
118
  end
119
- extract_results(@session)['first_name'].should == 'Dagobert'
119
+ expect(extract_results(@session)['first_name']).to eq('Dagobert')
120
120
  end
121
121
  end
122
122
 
@@ -130,7 +130,7 @@ Capybara::SpecHelper.spec '#within_fieldset' do
130
130
  @session.fill_in("Name", :with => 'Goldfinger')
131
131
  @session.click_button("Create")
132
132
  end
133
- extract_results(@session)['villain_name'].should == 'Goldfinger'
133
+ expect(extract_results(@session)['villain_name']).to eq('Goldfinger')
134
134
  end
135
135
 
136
136
  it "should restrict scope to a fieldset given by legend" do
@@ -138,7 +138,7 @@ Capybara::SpecHelper.spec '#within_fieldset' do
138
138
  @session.fill_in("Name", :with => 'Goldfinger')
139
139
  @session.click_button("Create")
140
140
  end
141
- extract_results(@session)['villain_name'].should == 'Goldfinger'
141
+ expect(extract_results(@session)['villain_name']).to eq('Goldfinger')
142
142
  end
143
143
  end
144
144
 
@@ -152,7 +152,7 @@ Capybara::SpecHelper.spec '#within_table' do
152
152
  @session.fill_in("Name", :with => 'Christmas')
153
153
  @session.click_button("Create")
154
154
  end
155
- extract_results(@session)['girl_name'].should == 'Christmas'
155
+ expect(extract_results(@session)['girl_name']).to eq('Christmas')
156
156
  end
157
157
 
158
158
  it "should restrict scope to a fieldset given by legend" do
@@ -160,6 +160,6 @@ Capybara::SpecHelper.spec '#within_table' do
160
160
  @session.fill_in("Name", :with => 'Quantum')
161
161
  @session.click_button("Create")
162
162
  end
163
- extract_results(@session)['villain_name'].should == 'Quantum'
163
+ expect(extract_results(@session)['villain_name']).to eq('Quantum')
164
164
  end
165
165
  end
@@ -4,6 +4,15 @@ require "capybara/rspec" # Required here instead of in rspec_spec to avoid RSpec
4
4
  require "capybara/spec/test_app"
5
5
  require "nokogiri"
6
6
 
7
+ # Alias be_truthy/be_falsey if not already defined to be able to use in RSpec 2 and 3
8
+ unless RSpec::Matchers.method_defined?(:be_truthy)
9
+ RSpec::Matchers.module_eval do
10
+ alias be_truthy be_true
11
+ alias be_falsey be_false
12
+ alias be_falsy be_false
13
+ end
14
+ end
15
+
7
16
  module Capybara
8
17
  module SpecHelper
9
18
  class << self
@@ -27,9 +36,9 @@ module Capybara
27
36
  end
28
37
 
29
38
  def filter(requires, metadata)
30
- if requires and metadata[:skip]
39
+ if requires and metadata[:capybara_skip]
31
40
  requires.any? do |require|
32
- metadata[:skip].include?(require)
41
+ metadata[:capybara_skip].include?(require)
33
42
  end
34
43
  else
35
44
  false
@@ -43,8 +52,9 @@ module Capybara
43
52
 
44
53
  def run_specs(session, name, options={})
45
54
  specs = @specs
46
- describe Capybara::Session, name, options do
55
+ RSpec.describe Capybara::Session, name, options do
47
56
  include Capybara::SpecHelper
57
+ include Capybara::RSpecMatchers
48
58
  before do
49
59
  @session = session
50
60
  end
@@ -83,4 +93,4 @@ module Capybara
83
93
  end
84
94
  end
85
95
 
86
- Dir[File.dirname(__FILE__)+'/session/*'].each { |group| require group }
96
+ Dir[File.dirname(__FILE__) + "/session/**/*.rb"].each { |file| require_relative file }
@@ -429,6 +429,13 @@ New line after and before textarea tag
429
429
  </p>
430
430
  </form>
431
431
 
432
+ <form action="/other_form" method="post">
433
+ <p>
434
+ <input type="text" name="form[which_form]" value="formaction form"/>
435
+ </p>
436
+ <input type="submit" name="form[button]" formaction="/form" value="Formaction button"/>
437
+ </form>
438
+
432
439
  <form action="relative" method="post">
433
440
  <p>
434
441
  <input type="submit" name="form[relative]" value="Relative Action" />
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <head>
3
- <title>This is the title of the first popup</title>
3
+ <title>Title of the first popup</title>
4
4
  </head>
5
5
  <body>
6
6
  <div id="divInPopupOne">This is the text of divInPopupOne</div>
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <head>
3
- <title>This is the title of popup two</title>
3
+ <title>Title of popup two</title>
4
4
  </head>
5
5
  <body>
6
6
  <div id="divInPopupTwo">This is the text of divInPopupTwo</div>
@@ -69,6 +69,8 @@
69
69
  <p>
70
70
  <a href="#" id="change-title">Change title</a>
71
71
  </p>
72
+
73
+ <p id="click-test">Click me</p>
72
74
 
73
75
  <script type="text/javascript">
74
76
  // a javascript comment
@@ -0,0 +1,38 @@
1
+ <html>
2
+ <head>
3
+ <title>With Windows</title>
4
+ <script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
5
+ <script language="javascript" type="text/javascript">
6
+ $(document).ready(function(){
7
+ $('#openWindow').click(function(){
8
+ window.open('/popup_one', 'firstPopup');
9
+ return false;
10
+ });
11
+
12
+ $('#openWindowWithTimeout').click(function(){
13
+ setTimeout(function(){
14
+ window.open('/popup_one', 'firstPopup');
15
+ }, 600);
16
+ return false;
17
+ });
18
+
19
+ $('#openTwoWindows').click(function() {
20
+ window.open('/popup_one', 'firstPopup');
21
+ window.open('/popup_two', 'secondPopup');
22
+ return false;
23
+ });
24
+ });
25
+ </script>
26
+ </head>
27
+ <body>
28
+ <button id="openWindow">Open new window</button>
29
+
30
+ <button id="openWindowWithTimeout">Open new window with timeout</button>
31
+
32
+ <button id="openTwoWindows">Open two windows</button>
33
+
34
+ <button id="doesNotOpenWindows">Does not open windows</button>
35
+
36
+ <iframe src="/frame_one" id="frameOne"></iframe>
37
+ </body>
38
+ </html>
@@ -1,3 +1,3 @@
1
1
  module Capybara
2
- VERSION = '2.2.1'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -0,0 +1,123 @@
1
+ module Capybara
2
+ ##
3
+ # The Window class represents a browser window.
4
+ #
5
+ # You can get an instance of the class by calling either of:
6
+ #
7
+ # * {Capybara::Session#windows}
8
+ # * {Capybara::Session#current_window}
9
+ # * {Capybara::Session#window_opened_by}
10
+ # * {Capybara::Session#switch_to_window}
11
+ #
12
+ # Note that some drivers (e.g. Selenium) support getting size of/resizing/closing only
13
+ # current window. So if you invoke such method for:
14
+ #
15
+ # * window that is current, Capybara will make 2 Selenium method invocations
16
+ # (get handle of current window + get size/resize/close).
17
+ # * window that is not current, Capybara will make 4 Selenium method invocations
18
+ # (get handle of current window + switch to given handle + get size/resize/close + switch to original handle)
19
+ #
20
+ class Window
21
+ # @return [String] a string that uniquely identifies window within session
22
+ attr_reader :handle
23
+
24
+ # @return [Capybara::Session] session that this window belongs to
25
+ attr_reader :session
26
+
27
+ # @api private
28
+ def initialize(session, handle)
29
+ @session = session
30
+ @driver = session.driver
31
+ @handle = handle
32
+ end
33
+
34
+ ##
35
+ # @return [Boolean] whether the window is not closed
36
+ def exists?
37
+ @driver.window_handles.include?(@handle)
38
+ end
39
+
40
+ ##
41
+ # @return [Boolean] whether the window is closed
42
+ def closed?
43
+ !exists?
44
+ end
45
+
46
+ ##
47
+ # @return [Boolean] whether this window is the window in which commands are being executed
48
+ def current?
49
+ @driver.current_window_handle == @handle
50
+ rescue @driver.no_such_window_error
51
+ false
52
+ end
53
+
54
+ ##
55
+ # Close window.
56
+ #
57
+ # If this method was called for window that is current, then after calling this method
58
+ # future invocations of other Capybara methods should raise
59
+ # `session.driver.no_such_window_error` until another window will be switched to.
60
+ #
61
+ # @!macro about_current
62
+ # If this method was called for window that is not current, then after calling this method
63
+ # current window shouldn remain the same as it was before calling this method.
64
+ #
65
+ def close
66
+ @driver.close_window(handle)
67
+ end
68
+
69
+ ##
70
+ # Get window size.
71
+ #
72
+ # @macro about_current
73
+ # @return [Array<(Fixnum, Fixnum)>] an array with width and height
74
+ #
75
+ def size
76
+ @driver.window_size(handle)
77
+ end
78
+
79
+ ##
80
+ # Resize window.
81
+ #
82
+ # @macro about_current
83
+ # @param width [String] the new window width in pixels
84
+ # @param height [String] the new window height in pixels
85
+ #
86
+ def resize_to(width, height)
87
+ @driver.resize_window_to(handle, width, height)
88
+ end
89
+
90
+ ##
91
+ # Maximize window.
92
+ #
93
+ # If a particular driver (e.g. headless driver) doesn't have concept of maximizing it
94
+ # may not support this method.
95
+ #
96
+ # @macro about_current
97
+ #
98
+ def maximize
99
+ @driver.maximize_window(handle)
100
+ end
101
+
102
+ def eql?(other)
103
+ other.kind_of?(self.class) && @session == other.session && @handle == other.handle
104
+ end
105
+ alias_method :==, :eql?
106
+
107
+ def hash
108
+ @session.hash ^ @handle.hash
109
+ end
110
+
111
+ def inspect
112
+ "#<Window @handle=#{@handle.inspect}>"
113
+ end
114
+
115
+ private
116
+
117
+ def raise_unless_current(what)
118
+ unless current?
119
+ raise Capybara::WindowError, "#{what} not current window is not possible."
120
+ end
121
+ end
122
+ end
123
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Capybara do
3
+ RSpec.describe Capybara do
4
4
  describe '.string' do
5
5
  let :string do
6
6
  Capybara.string <<-STRING
@@ -44,96 +44,96 @@ describe Capybara do
44
44
  end
45
45
 
46
46
  it "allows using matchers" do
47
- string.should have_css('#page')
48
- string.should_not have_css('#does-not-exist')
47
+ expect(string).to have_css('#page')
48
+ expect(string).not_to have_css('#does-not-exist')
49
49
  end
50
50
 
51
51
  it "allows using custom matchers" do
52
52
  Capybara.add_selector :lifeform do
53
53
  xpath { |name| "//option[contains(.,'#{name}')]" }
54
54
  end
55
- string.should have_selector(:id, "page")
56
- string.should_not have_selector(:id, 'does-not-exist')
57
- string.should have_selector(:lifeform, "Monkey")
58
- string.should_not have_selector(:lifeform, "Gorilla")
55
+ expect(string).to have_selector(:id, "page")
56
+ expect(string).not_to have_selector(:id, 'does-not-exist')
57
+ expect(string).to have_selector(:lifeform, "Monkey")
58
+ expect(string).not_to have_selector(:lifeform, "Gorilla")
59
59
  end
60
60
 
61
61
  it 'allows custom matcher using css' do
62
62
  Capybara.add_selector :section do
63
63
  css { |css_class| "section .#{css_class}" }
64
64
  end
65
- string.should have_selector(:section, 'subsection')
66
- string.should_not have_selector(:section, 'section_8')
65
+ expect(string).to have_selector(:section, 'subsection')
66
+ expect(string).not_to have_selector(:section, 'section_8')
67
67
  end
68
68
 
69
69
  it "allows using matchers with text option" do
70
- string.should have_css('h1', :text => 'Totally awesome')
71
- string.should_not have_css('h1', :text => 'Not so awesome')
70
+ expect(string).to have_css('h1', :text => 'Totally awesome')
71
+ expect(string).not_to have_css('h1', :text => 'Not so awesome')
72
72
  end
73
73
 
74
74
  it "allows finding only visible nodes" do
75
- string.all(:css, '#secret', :visible => true).should be_empty
76
- string.all(:css, '#secret', :visible => false).should have(1).element
75
+ expect(string.all(:css, '#secret', :visible => true)).to be_empty
76
+ expect(string.all(:css, '#secret', :visible => false).size).to eq(1)
77
77
  end
78
78
 
79
79
  it "allows finding elements and extracting text from them" do
80
- string.find('//h1').text.should == 'Totally awesome'
80
+ expect(string.find('//h1').text).to eq('Totally awesome')
81
81
  end
82
82
 
83
83
  it "allows finding elements and extracting attributes from them" do
84
- string.find('//h1')[:data].should == 'fantastic'
84
+ expect(string.find('//h1')[:data]).to eq('fantastic')
85
85
  end
86
86
 
87
87
  it "allows finding elements and extracting the tag name from them" do
88
- string.find('//h1').tag_name.should == 'h1'
88
+ expect(string.find('//h1').tag_name).to eq('h1')
89
89
  end
90
90
 
91
91
  it "allows finding elements and extracting the path" do
92
- string.find('//h1').path.should == '/html/body/div/div[1]/h1'
92
+ expect(string.find('//h1').path).to eq('/html/body/div/div[1]/h1')
93
93
  end
94
94
 
95
95
  it "allows finding elements and extracting the path" do
96
- string.find('//div/input').value.should == 'bar'
97
- string.find('//select').value.should == 'Capybara'
96
+ expect(string.find('//div/input').value).to eq('bar')
97
+ expect(string.find('//select').value).to eq('Capybara')
98
98
  end
99
99
 
100
100
  it "allows finding elements and checking if they are visible" do
101
- string.find('//h1').should be_visible
102
- string.find(:css, "#secret", :visible => false).should_not be_visible
101
+ expect(string.find('//h1')).to be_visible
102
+ expect(string.find(:css, "#secret", :visible => false)).not_to be_visible
103
103
  end
104
104
 
105
105
  it "allows finding elements and checking if they are disabled" do
106
- string.find('//form/input[@name="bleh"]').should be_disabled
107
- string.find('//form/input[@name="meh"]').should_not be_disabled
106
+ expect(string.find('//form/input[@name="bleh"]')).to be_disabled
107
+ expect(string.find('//form/input[@name="meh"]')).not_to be_disabled
108
108
  end
109
109
 
110
110
  describe "#title" do
111
111
  it "returns the page title" do
112
- string.title.should == "simple_node"
112
+ expect(string.title).to eq("simple_node")
113
113
  end
114
114
  end
115
115
 
116
116
  describe "#has_title?" do
117
117
  it "returns whether the page has the given title" do
118
- string.has_title?('simple_node').should be_true
119
- string.has_title?('monkey').should be_false
118
+ expect(string.has_title?('simple_node')).to be_truthy
119
+ expect(string.has_title?('monkey')).to be_falsey
120
120
  end
121
121
 
122
122
  it "allows regexp matches" do
123
- string.has_title?(/s[a-z]+_node/).should be_true
124
- string.has_title?(/monkey/).should be_false
123
+ expect(string.has_title?(/s[a-z]+_node/)).to be_truthy
124
+ expect(string.has_title?(/monkey/)).to be_falsey
125
125
  end
126
126
  end
127
127
 
128
128
  describe '#has_no_title?' do
129
129
  it "returns whether the page does not have the given title" do
130
- string.has_no_title?('simple_node').should be_false
131
- string.has_no_title?('monkey').should be_true
130
+ expect(string.has_no_title?('simple_node')).to be_falsey
131
+ expect(string.has_no_title?('monkey')).to be_truthy
132
132
  end
133
133
 
134
134
  it "allows regexp matches" do
135
- string.has_no_title?(/s[a-z]+_node/).should be_false
136
- string.has_no_title?(/monkey/).should be_true
135
+ expect(string.has_no_title?(/s[a-z]+_node/)).to be_falsey
136
+ expect(string.has_no_title?(/monkey/)).to be_truthy
137
137
  end
138
138
  end
139
139
  end