capybara 2.2.1 → 2.3.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.
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
@@ -2,25 +2,25 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
2
2
  it "should click on a link" do
3
3
  @session.visit('/with_html')
4
4
  @session.click_link_or_button('labore')
5
- @session.should have_content('Bar')
5
+ expect(@session).to have_content('Bar')
6
6
  end
7
7
 
8
8
  it "should click on a button" do
9
9
  @session.visit('/form')
10
10
  @session.click_link_or_button('awe123')
11
- extract_results(@session)['first_name'].should == 'John'
11
+ expect(extract_results(@session)['first_name']).to eq('John')
12
12
  end
13
13
 
14
14
  it "should click on a button with no type attribute" do
15
15
  @session.visit('/form')
16
16
  @session.click_link_or_button('no_type')
17
- extract_results(@session)['first_name'].should == 'John'
17
+ expect(extract_results(@session)['first_name']).to eq('John')
18
18
  end
19
19
 
20
20
  it "should be aliased as click_on" do
21
21
  @session.visit('/form')
22
22
  @session.click_on('awe123')
23
- extract_results(@session)['first_name'].should == 'John'
23
+ expect(extract_results(@session)['first_name']).to eq('John')
24
24
  end
25
25
 
26
26
  it "should wait for asynchronous load", :requires => [:js] do
@@ -32,7 +32,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
32
32
  it "casts to string" do
33
33
  @session.visit('/form')
34
34
  @session.click_link_or_button(:'awe123')
35
- extract_results(@session)['first_name'].should == 'John'
35
+ expect(extract_results(@session)['first_name']).to eq('John')
36
36
  end
37
37
 
38
38
  context "with :exact option" do
@@ -40,13 +40,13 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
40
40
  it "clicks on approximately matching link" do
41
41
  @session.visit('/with_html')
42
42
  @session.click_link_or_button('abore', :exact => false)
43
- @session.should have_content('Bar')
43
+ expect(@session).to have_content('Bar')
44
44
  end
45
45
 
46
46
  it "clicks on approximately matching button" do
47
47
  @session.visit('/form')
48
48
  @session.click_link_or_button('awe')
49
- extract_results(@session)['first_name'].should == 'John'
49
+ expect(extract_results(@session)['first_name']).to eq('John')
50
50
  end
51
51
  end
52
52
 
@@ -98,7 +98,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
98
98
  it "happily clicks on links which incorrectly have the disabled attribute" do
99
99
  @session.visit('/with_html')
100
100
  @session.click_link_or_button('Disabled link')
101
- @session.should have_content("Bar")
101
+ expect(@session).to have_content("Bar")
102
102
  end
103
103
 
104
104
  it "does nothing when button is disabled" do
@@ -11,49 +11,56 @@ Capybara::SpecHelper.spec '#click_link' do
11
11
 
12
12
  it "casts to string" do
13
13
  @session.click_link(:'foo')
14
- @session.should have_content('Another World')
14
+ expect(@session).to have_content('Another World')
15
+ end
16
+
17
+ it "raises any errors caught inside the server", :requires => [:server] do
18
+ quietly { @session.visit("/error") }
19
+ expect do
20
+ @session.click_link('foo')
21
+ end.to raise_error(TestApp::TestAppError)
15
22
  end
16
23
 
17
24
  context "with id given" do
18
25
  it "should take user to the linked page" do
19
26
  @session.click_link('foo')
20
- @session.should have_content('Another World')
27
+ expect(@session).to have_content('Another World')
21
28
  end
22
29
  end
23
30
 
24
31
  context "with text given" do
25
32
  it "should take user to the linked page" do
26
33
  @session.click_link('labore')
27
- @session.should have_content('Bar')
34
+ expect(@session).to have_content('Bar')
28
35
  end
29
36
 
30
37
  it "should accept partial matches" do
31
38
  @session.click_link('abo')
32
- @session.should have_content('Bar')
39
+ expect(@session).to have_content('Bar')
33
40
  end
34
41
  end
35
42
 
36
43
  context "with title given" do
37
44
  it "should take user to the linked page" do
38
45
  @session.click_link('awesome title')
39
- @session.should have_content('Bar')
46
+ expect(@session).to have_content('Bar')
40
47
  end
41
48
 
42
49
  it "should accept partial matches" do
43
50
  @session.click_link('some titl')
44
- @session.should have_content('Bar')
51
+ expect(@session).to have_content('Bar')
45
52
  end
46
53
  end
47
54
 
48
55
  context "with alternative text given to a contained image" do
49
56
  it "should take user to the linked page" do
50
57
  @session.click_link('awesome image')
51
- @session.should have_content('Bar')
58
+ expect(@session).to have_content('Bar')
52
59
  end
53
60
 
54
61
  it "should accept partial matches" do
55
62
  @session.click_link('some imag')
56
- @session.should have_content('Bar')
63
+ expect(@session).to have_content('Bar')
57
64
  end
58
65
  end
59
66
 
@@ -69,7 +76,7 @@ Capybara::SpecHelper.spec '#click_link' do
69
76
  context "with :href option given" do
70
77
  it "should find links with valid href" do
71
78
  @session.click_link('labore', :href => '/with_simple_html')
72
- @session.should have_content('Bar')
79
+ expect(@session).to have_content('Bar')
73
80
  end
74
81
 
75
82
  it "should raise error if link wasn't found" do
@@ -80,46 +87,46 @@ Capybara::SpecHelper.spec '#click_link' do
80
87
  it "should follow relative links" do
81
88
  @session.visit('/')
82
89
  @session.click_link('Relative')
83
- @session.should have_content('This is a test')
90
+ expect(@session).to have_content('This is a test')
84
91
  end
85
92
 
86
93
  it "should follow protocol relative links" do
87
94
  @session.click_link('Protocol')
88
- @session.should have_content('Another World')
95
+ expect(@session).to have_content('Another World')
89
96
  end
90
97
 
91
98
  it "should follow redirects" do
92
99
  @session.click_link('Redirect')
93
- @session.should have_content('You landed')
100
+ expect(@session).to have_content('You landed')
94
101
  end
95
102
 
96
103
  it "should follow redirects" do
97
104
  @session.click_link('BackToMyself')
98
- @session.should have_content('This is a test')
105
+ expect(@session).to have_content('This is a test')
99
106
  end
100
107
 
101
108
  it "should add query string to current URL with naked query string" do
102
109
  @session.click_link('Naked Query String')
103
- @session.should have_content('Query String sent')
110
+ expect(@session).to have_content('Query String sent')
104
111
  end
105
112
 
106
113
  it "should do nothing on anchor links" do
107
114
  @session.fill_in("test_field", :with => 'blah')
108
115
  @session.click_link('Normal Anchor')
109
- @session.find_field("test_field").value.should == 'blah'
116
+ expect(@session.find_field("test_field").value).to eq('blah')
110
117
  @session.click_link('Blank Anchor')
111
- @session.find_field("test_field").value.should == 'blah'
118
+ expect(@session.find_field("test_field").value).to eq('blah')
112
119
  end
113
120
 
114
121
  it "should do nothing on URL+anchor links for the same page" do
115
122
  @session.fill_in("test_field", :with => 'blah')
116
123
  @session.click_link('Anchor on same page')
117
- @session.find_field("test_field").value.should == 'blah'
124
+ expect(@session.find_field("test_field").value).to eq('blah')
118
125
  end
119
126
 
120
127
  it "should follow link on URL+anchor links for a different page" do
121
128
  @session.click_link('Anchor on different page')
122
- @session.should have_content('Bar')
129
+ expect(@session).to have_content('Bar')
123
130
  end
124
131
 
125
132
  it "raise an error with links with no href" do
@@ -131,7 +138,7 @@ Capybara::SpecHelper.spec '#click_link' do
131
138
  context "with :exact option" do
132
139
  it "should accept partial matches when false" do
133
140
  @session.click_link('abo', :exact => false)
134
- @session.should have_content('Bar')
141
+ expect(@session).to have_content('Bar')
135
142
  end
136
143
 
137
144
  it "should not accept partial matches when true" do
@@ -5,14 +5,14 @@ Capybara::SpecHelper.spec '#current_scope' do
5
5
 
6
6
  context "when not in a #within block" do
7
7
  it "should return the document" do
8
- @session.current_scope.should be_kind_of Capybara::Node::Document
8
+ expect(@session.current_scope).to be_kind_of Capybara::Node::Document
9
9
  end
10
10
  end
11
11
 
12
12
  context "when in a #within block" do
13
13
  it "should return the element in scope" do
14
14
  @session.within(:css, "#simple_first_name") do
15
- @session.current_scope[:name].should eq 'first_name'
15
+ expect(@session.current_scope[:name]).to eq 'first_name'
16
16
  end
17
17
  end
18
18
  end
@@ -21,7 +21,7 @@ Capybara::SpecHelper.spec '#current_scope' do
21
21
  it "should return the element in scope" do
22
22
  @session.within("//div[@id='for_bar']") do
23
23
  @session.within(".//input[@value='Peter']") do
24
- @session.current_scope[:name].should eq 'form[first_name]'
24
+ expect(@session.current_scope[:name]).to eq 'form[first_name]'
25
25
  end
26
26
  end
27
27
  end
@@ -2,8 +2,8 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
2
2
  before :all do
3
3
  @servers = 2.times.map { Capybara::Server.new(TestApp.clone).boot }
4
4
  # sanity check
5
- @servers[0].port.should_not == @servers[1].port
6
- @servers.map { |s| s.port }.should_not include 80
5
+ expect(@servers[0].port).not_to eq(@servers[1].port)
6
+ expect(@servers.map { |s| s.port }).not_to include 80
7
7
  end
8
8
 
9
9
  def bases
@@ -13,12 +13,12 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
13
13
  def should_be_on server_index, path="/host", scheme="http"
14
14
  # Check that we are on /host on the given server
15
15
  s = @servers[server_index]
16
- @session.current_url.chomp('?').should == "#{scheme}://#{s.host}:#{s.port}#{path}"
17
- @session.current_host.should == "#{scheme}://#{s.host}" # no port
18
- @session.current_path.should == path
16
+ expect(@session.current_url.chomp('?')).to eq("#{scheme}://#{s.host}:#{s.port}#{path}")
17
+ expect(@session.current_host).to eq("#{scheme}://#{s.host}") # no port
18
+ expect(@session.current_path).to eq(path)
19
19
  if path == '/host'
20
20
  # Server should agree with us
21
- @session.should have_content("Current host is #{scheme}://#{s.host}:#{s.port}")
21
+ expect(@session).to have_content("Current host is #{scheme}://#{s.host}:#{s.port}")
22
22
  end
23
23
  end
24
24
 
@@ -82,12 +82,12 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
82
82
  it "is affected by pushState", :requires => [:js] do
83
83
  @session.visit("/with_js")
84
84
  @session.execute_script("window.history.pushState({}, '', '/pushed')")
85
- @session.current_path.should == "/pushed"
85
+ expect(@session.current_path).to eq("/pushed")
86
86
  end
87
87
 
88
88
  it "is affected by replaceState", :requires => [:js] do
89
89
  @session.visit("/with_js")
90
90
  @session.execute_script("window.history.replaceState({}, '', '/replaced')")
91
- @session.current_path.should == "/replaced"
91
+ expect(@session.current_path).to eq("/replaced")
92
92
  end
93
93
  end
@@ -1,6 +1,6 @@
1
1
  Capybara::SpecHelper.spec "#evaluate_script", :requires => [:js] do
2
2
  it "should evaluate the given script and return whatever it produces" do
3
3
  @session.visit('/with_js')
4
- @session.evaluate_script("1+3").should == 4
4
+ expect(@session.evaluate_script("1+3")).to eq(4)
5
5
  end
6
6
  end
@@ -1,7 +1,7 @@
1
1
  Capybara::SpecHelper.spec "#execute_script", :requires => [:js] do
2
2
  it "should execute the given script and return nothing" do
3
3
  @session.visit('/with_js')
4
- @session.execute_script("$('#change').text('Funky Doodle')").should be_nil
5
- @session.should have_css('#change', :text => 'Funky Doodle')
4
+ expect(@session.execute_script("$('#change').text('Funky Doodle')")).to be_nil
5
+ expect(@session).to have_css('#change', :text => 'Funky Doodle')
6
6
  end
7
7
  end
@@ -6,101 +6,101 @@ Capybara::SpecHelper.spec "#fill_in" do
6
6
  it "should fill in a text field by id" do
7
7
  @session.fill_in('form_first_name', :with => 'Harry')
8
8
  @session.click_button('awesome')
9
- extract_results(@session)['first_name'].should == 'Harry'
9
+ expect(extract_results(@session)['first_name']).to eq('Harry')
10
10
  end
11
11
 
12
12
  it "should fill in a text field by name" do
13
13
  @session.fill_in('form[last_name]', :with => 'Green')
14
14
  @session.click_button('awesome')
15
- extract_results(@session)['last_name'].should == 'Green'
15
+ expect(extract_results(@session)['last_name']).to eq('Green')
16
16
  end
17
17
 
18
18
  it "should fill in a text field by label without for" do
19
19
  @session.fill_in('First Name', :with => 'Harry')
20
20
  @session.click_button('awesome')
21
- extract_results(@session)['first_name'].should == 'Harry'
21
+ expect(extract_results(@session)['first_name']).to eq('Harry')
22
22
  end
23
23
 
24
24
  it "should fill in a url field by label without for" do
25
25
  @session.fill_in('Html5 Url', :with => 'http://www.avenueq.com')
26
26
  @session.click_button('html5_submit')
27
- extract_results(@session)['html5_url'].should == 'http://www.avenueq.com'
27
+ expect(extract_results(@session)['html5_url']).to eq('http://www.avenueq.com')
28
28
  end
29
29
 
30
30
  it "should fill in a textarea by id" do
31
31
  @session.fill_in('form_description', :with => 'Texty text')
32
32
  @session.click_button('awesome')
33
- extract_results(@session)['description'].should == 'Texty text'
33
+ expect(extract_results(@session)['description']).to eq('Texty text')
34
34
  end
35
35
 
36
36
  it "should fill in a textarea by label" do
37
37
  @session.fill_in('Description', :with => 'Texty text')
38
38
  @session.click_button('awesome')
39
- extract_results(@session)['description'].should == 'Texty text'
39
+ expect(extract_results(@session)['description']).to eq('Texty text')
40
40
  end
41
41
 
42
42
  it "should fill in a textarea by name" do
43
43
  @session.fill_in('form[description]', :with => 'Texty text')
44
44
  @session.click_button('awesome')
45
- extract_results(@session)['description'].should == 'Texty text'
45
+ expect(extract_results(@session)['description']).to eq('Texty text')
46
46
  end
47
47
 
48
48
  it "should fill in a password field by id" do
49
49
  @session.fill_in('form_password', :with => 'supasikrit')
50
50
  @session.click_button('awesome')
51
- extract_results(@session)['password'].should == 'supasikrit'
51
+ expect(extract_results(@session)['password']).to eq('supasikrit')
52
52
  end
53
53
 
54
54
  it "should handle HTML in a textarea" do
55
55
  @session.fill_in('form_description', :with => 'is <strong>very</strong> secret!')
56
56
  @session.click_button('awesome')
57
- extract_results(@session)['description'].should == 'is <strong>very</strong> secret!'
57
+ expect(extract_results(@session)['description']).to eq('is <strong>very</strong> secret!')
58
58
  end
59
59
 
60
60
  it "should handle newlines in a textarea" do
61
61
  @session.fill_in('form_description', :with => "\nSome text\n")
62
62
  @session.click_button('awesome')
63
- extract_results(@session)['description'].should == "\r\nSome text\r\n"
63
+ expect(extract_results(@session)['description']).to eq("\r\nSome text\r\n")
64
64
  end
65
65
 
66
66
  it "should fill in a field with a custom type" do
67
67
  @session.fill_in('Schmooo', :with => 'Schmooo is the game')
68
68
  @session.click_button('awesome')
69
- extract_results(@session)['schmooo'].should == 'Schmooo is the game'
69
+ expect(extract_results(@session)['schmooo']).to eq('Schmooo is the game')
70
70
  end
71
71
 
72
72
  it "should fill in a field without a type" do
73
73
  @session.fill_in('Phone', :with => '+1 555 7022')
74
74
  @session.click_button('awesome')
75
- extract_results(@session)['phone'].should == '+1 555 7022'
75
+ expect(extract_results(@session)['phone']).to eq('+1 555 7022')
76
76
  end
77
77
 
78
78
  it "should fill in a text field respecting its maxlength attribute" do
79
79
  @session.fill_in('Zipcode', :with => '52071350')
80
80
  @session.click_button('awesome')
81
- extract_results(@session)['zipcode'].should == '52071'
81
+ expect(extract_results(@session)['zipcode']).to eq('52071')
82
82
  end
83
83
 
84
84
  it "should fill in a password field by name" do
85
85
  @session.fill_in('form[password]', :with => 'supasikrit')
86
86
  @session.click_button('awesome')
87
- extract_results(@session)['password'].should == 'supasikrit'
87
+ expect(extract_results(@session)['password']).to eq('supasikrit')
88
88
  end
89
89
 
90
90
  it "should fill in a password field by label" do
91
91
  @session.fill_in('Password', :with => 'supasikrit')
92
92
  @session.click_button('awesome')
93
- extract_results(@session)['password'].should == 'supasikrit'
93
+ expect(extract_results(@session)['password']).to eq('supasikrit')
94
94
  end
95
95
 
96
96
  it "should fill in a password field by name" do
97
97
  @session.fill_in('form[password]', :with => 'supasikrit')
98
98
  @session.click_button('awesome')
99
- extract_results(@session)['password'].should == 'supasikrit'
99
+ expect(extract_results(@session)['password']).to eq('supasikrit')
100
100
  end
101
101
 
102
102
  it "should throw an exception if a hash containing 'with' is not provided" do
103
- lambda{@session.fill_in 'Name', 'ignu'}.should raise_error
103
+ expect {@session.fill_in 'Name', 'ignu'}.to raise_error
104
104
  end
105
105
 
106
106
  it "should wait for asynchronous load", :requires => [:js] do
@@ -112,13 +112,13 @@ Capybara::SpecHelper.spec "#fill_in" do
112
112
  it "casts to string" do
113
113
  @session.fill_in(:'form_first_name', :with => :'Harry')
114
114
  @session.click_button('awesome')
115
- extract_results(@session)['first_name'].should == 'Harry'
115
+ expect(extract_results(@session)['first_name']).to eq('Harry')
116
116
  end
117
117
 
118
118
  it "casts to string if field has maxlength" do
119
119
  @session.fill_in(:'form_zipcode', :with => 1234567)
120
120
  @session.click_button('awesome')
121
- extract_results(@session)['zipcode'].should == '12345'
121
+ expect(extract_results(@session)['zipcode']).to eq('12345')
122
122
  end
123
123
 
124
124
  context 'on a pre-populated textfield with a reformatting onchange', :requires => [:js] do
@@ -127,7 +127,7 @@ Capybara::SpecHelper.spec "#fill_in" do
127
127
  @session.fill_in('with_change_event', :with => 'some value')
128
128
  # click outside the field to trigger the change event
129
129
  @session.find(:css, 'body').click
130
- @session.find(:css, '.change_event_triggered', :match => :one).should have_text 'some value'
130
+ expect(@session.find(:css, '.change_event_triggered', :match => :one)).to have_text 'some value'
131
131
  end
132
132
 
133
133
  it 'should trigger change when clearing field' do
@@ -135,7 +135,7 @@ Capybara::SpecHelper.spec "#fill_in" do
135
135
  @session.fill_in('with_change_event', :with => '')
136
136
  # click outside the field to trigger the change event
137
137
  @session.find(:css, 'body').click
138
- @session.should have_selector(:css, '.change_event_triggered', :match => :one)
138
+ expect(@session).to have_selector(:css, '.change_event_triggered', :match => :one)
139
139
  end
140
140
  end
141
141
 
@@ -171,7 +171,7 @@ Capybara::SpecHelper.spec "#fill_in" do
171
171
  it "should accept partial matches when false" do
172
172
  @session.fill_in("Explanation", :with => "Dude", :exact => false)
173
173
  @session.click_button("awesome")
174
- extract_results(@session)["name_explanation"].should == "Dude"
174
+ expect(extract_results(@session)["name_explanation"]).to eq("Dude")
175
175
  end
176
176
 
177
177
  it "should not accept partial matches when true" do
@@ -4,12 +4,12 @@ Capybara::SpecHelper.spec '#find_button' do
4
4
  end
5
5
 
6
6
  it "should find any button" do
7
- @session.find_button('med')[:id].should == "mediocre"
8
- @session.find_button('crap321').value.should == "crappy"
7
+ expect(@session.find_button('med')[:id]).to eq("mediocre")
8
+ expect(@session.find_button('crap321').value).to eq("crappy")
9
9
  end
10
10
 
11
11
  it "casts to string" do
12
- @session.find_button(:'med')[:id].should == "mediocre"
12
+ expect(@session.find_button(:'med')[:id]).to eq("mediocre")
13
13
  end
14
14
 
15
15
  it "should raise error if the button doesn't exist" do
@@ -20,7 +20,7 @@ Capybara::SpecHelper.spec '#find_button' do
20
20
 
21
21
  context "with :exact option" do
22
22
  it "should accept partial matches when false" do
23
- @session.find_button('What an Awesome', :exact => false)[:value].should == "awesome"
23
+ expect(@session.find_button('What an Awesome', :exact => false)[:value]).to eq("awesome")
24
24
  end
25
25
 
26
26
  it "should not accept partial matches when true" do