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
@@ -1,10 +1,10 @@
1
1
  Capybara::SpecHelper.spec '#go_back', :requires => [:js] do
2
2
  it "should fetch a response from the driver from the previous page" do
3
3
  @session.visit('/')
4
- @session.should have_content('Hello world!')
4
+ expect(@session).to have_content('Hello world!')
5
5
  @session.visit('/foo')
6
- @session.should have_content('Another World')
6
+ expect(@session).to have_content('Another World')
7
7
  @session.go_back
8
- @session.should have_content('Hello world!')
8
+ expect(@session).to have_content('Hello world!')
9
9
  end
10
10
  end
@@ -1,12 +1,12 @@
1
1
  Capybara::SpecHelper.spec '#go_forward', :requires => [:js] do
2
2
  it "should fetch a response from the driver from the previous page" do
3
3
  @session.visit('/')
4
- @session.should have_content('Hello world!')
4
+ expect(@session).to have_content('Hello world!')
5
5
  @session.visit('/foo')
6
- @session.should have_content('Another World')
6
+ expect(@session).to have_content('Another World')
7
7
  @session.go_back
8
- @session.should have_content('Hello world!')
8
+ expect(@session).to have_content('Hello world!')
9
9
  @session.go_forward
10
- @session.should have_content('Another World')
10
+ expect(@session).to have_content('Another World')
11
11
  end
12
12
  end
@@ -4,25 +4,25 @@ Capybara::SpecHelper.spec '#has_button?' do
4
4
  end
5
5
 
6
6
  it "should be true if the given button is on the page" do
7
- @session.should have_button('med')
8
- @session.should have_button('crap321')
9
- @session.should have_button(:'crap321')
7
+ expect(@session).to have_button('med')
8
+ expect(@session).to have_button('crap321')
9
+ expect(@session).to have_button(:'crap321')
10
10
  end
11
11
 
12
12
  it "should be true for disabled buttons if :disabled => true" do
13
- @session.should have_button('Disabled button', :disabled => true)
13
+ expect(@session).to have_button('Disabled button', :disabled => true)
14
14
  end
15
15
 
16
16
  it "should be false if the given button is not on the page" do
17
- @session.should_not have_button('monkey')
17
+ expect(@session).not_to have_button('monkey')
18
18
  end
19
19
 
20
20
  it "should be false for disabled buttons by default" do
21
- @session.should_not have_button('Disabled button')
21
+ expect(@session).not_to have_button('Disabled button')
22
22
  end
23
23
 
24
24
  it "should be false for disabled buttons if :disabled => false" do
25
- @session.should_not have_button('Disabled button', :disabled => false)
25
+ expect(@session).not_to have_button('Disabled button', :disabled => false)
26
26
  end
27
27
  end
28
28
 
@@ -32,23 +32,23 @@ Capybara::SpecHelper.spec '#has_no_button?' do
32
32
  end
33
33
 
34
34
  it "should be true if the given button is on the page" do
35
- @session.should_not have_no_button('med')
36
- @session.should_not have_no_button('crap321')
35
+ expect(@session).not_to have_no_button('med')
36
+ expect(@session).not_to have_no_button('crap321')
37
37
  end
38
38
 
39
39
  it "should be true for disabled buttons if :disabled => true" do
40
- @session.should_not have_no_button('Disabled button', :disabled => true)
40
+ expect(@session).not_to have_no_button('Disabled button', :disabled => true)
41
41
  end
42
42
 
43
43
  it "should be false if the given button is not on the page" do
44
- @session.should have_no_button('monkey')
44
+ expect(@session).to have_no_button('monkey')
45
45
  end
46
46
 
47
47
  it "should be false for disabled buttons by default" do
48
- @session.should have_no_button('Disabled button')
48
+ expect(@session).to have_no_button('Disabled button')
49
49
  end
50
50
 
51
51
  it "should be false for disabled buttons if :disabled => false" do
52
- @session.should have_no_button('Disabled button', :disabled => false)
52
+ expect(@session).to have_no_button('Disabled button', :disabled => false)
53
53
  end
54
54
  end
@@ -4,111 +4,111 @@ Capybara::SpecHelper.spec '#has_css?' do
4
4
  end
5
5
 
6
6
  it "should be true if the given selector is on the page" do
7
- @session.should have_css("p")
8
- @session.should have_css("p a#foo")
7
+ expect(@session).to have_css("p")
8
+ expect(@session).to have_css("p a#foo")
9
9
  end
10
10
 
11
11
  it "should be false if the given selector is not on the page" do
12
- @session.should_not have_css("abbr")
13
- @session.should_not have_css("p a#doesnotexist")
14
- @session.should_not have_css("p.nosuchclass")
12
+ expect(@session).not_to have_css("abbr")
13
+ expect(@session).not_to have_css("p a#doesnotexist")
14
+ expect(@session).not_to have_css("p.nosuchclass")
15
15
  end
16
16
 
17
17
  it "should respect scopes" do
18
18
  @session.within "//p[@id='first']" do
19
- @session.should have_css("a#foo")
20
- @session.should_not have_css("a#red")
19
+ expect(@session).to have_css("a#foo")
20
+ expect(@session).not_to have_css("a#red")
21
21
  end
22
22
  end
23
23
 
24
24
  it "should wait for content to appear", :requires => [:js] do
25
25
  @session.visit('/with_js')
26
26
  @session.click_link('Click me')
27
- @session.should have_css("input[type='submit'][value='New Here']")
27
+ expect(@session).to have_css("input[type='submit'][value='New Here']")
28
28
  end
29
29
 
30
30
  context "with between" do
31
31
  it "should be true if the content occurs within the range given" do
32
- @session.should have_css("p", :between => 1..4)
33
- @session.should have_css("p a#foo", :between => 1..3)
34
- @session.should have_css("p a.doesnotexist", :between => 0..8)
32
+ expect(@session).to have_css("p", :between => 1..4)
33
+ expect(@session).to have_css("p a#foo", :between => 1..3)
34
+ expect(@session).to have_css("p a.doesnotexist", :between => 0..8)
35
35
  end
36
36
 
37
37
  it "should be false if the content occurs more or fewer times than range" do
38
- @session.should_not have_css("p", :between => 6..11 )
39
- @session.should_not have_css("p a#foo", :between => 4..7)
40
- @session.should_not have_css("p a.doesnotexist", :between => 3..8)
38
+ expect(@session).not_to have_css("p", :between => 6..11 )
39
+ expect(@session).not_to have_css("p a#foo", :between => 4..7)
40
+ expect(@session).not_to have_css("p a.doesnotexist", :between => 3..8)
41
41
  end
42
42
  end
43
43
 
44
44
  context "with count" do
45
45
  it "should be true if the content occurs the given number of times" do
46
- @session.should have_css("p", :count => 3)
47
- @session.should have_css("p a#foo", :count => 1)
48
- @session.should have_css("p a.doesnotexist", :count => 0)
46
+ expect(@session).to have_css("p", :count => 3)
47
+ expect(@session).to have_css("p a#foo", :count => 1)
48
+ expect(@session).to have_css("p a.doesnotexist", :count => 0)
49
49
  end
50
50
 
51
51
  it "should be false if the content occurs a different number of times than the given" do
52
- @session.should_not have_css("p", :count => 6)
53
- @session.should_not have_css("p a#foo", :count => 2)
54
- @session.should_not have_css("p a.doesnotexist", :count => 1)
52
+ expect(@session).not_to have_css("p", :count => 6)
53
+ expect(@session).not_to have_css("p a#foo", :count => 2)
54
+ expect(@session).not_to have_css("p a.doesnotexist", :count => 1)
55
55
  end
56
56
 
57
57
  it "should coerce count to an integer" do
58
- @session.should have_css("p", :count => "3")
59
- @session.should have_css("p a#foo", :count => "1")
58
+ expect(@session).to have_css("p", :count => "3")
59
+ expect(@session).to have_css("p a#foo", :count => "1")
60
60
  end
61
61
  end
62
62
 
63
63
  context "with maximum" do
64
64
  it "should be true when content occurs same or fewer times than given" do
65
- @session.should have_css("h2.head", :maximum => 5) # edge case
66
- @session.should have_css("h2", :maximum => 10)
67
- @session.should have_css("p a.doesnotexist", :maximum => 1)
68
- @session.should have_css("p a.doesnotexist", :maximum => 0)
65
+ expect(@session).to have_css("h2.head", :maximum => 5) # edge case
66
+ expect(@session).to have_css("h2", :maximum => 10)
67
+ expect(@session).to have_css("p a.doesnotexist", :maximum => 1)
68
+ expect(@session).to have_css("p a.doesnotexist", :maximum => 0)
69
69
  end
70
70
 
71
71
  it "should be false when content occurs more times than given" do
72
- @session.should_not have_css("h2.head", :maximum => 4) # edge case
73
- @session.should_not have_css("h2", :maximum => 3)
74
- @session.should_not have_css("p", :maximum => 1)
72
+ expect(@session).not_to have_css("h2.head", :maximum => 4) # edge case
73
+ expect(@session).not_to have_css("h2", :maximum => 3)
74
+ expect(@session).not_to have_css("p", :maximum => 1)
75
75
  end
76
76
 
77
77
  it "should coerce maximum to an integer" do
78
- @session.should have_css("h2.head", :maximum => "5") # edge case
79
- @session.should have_css("h2", :maximum => "10")
78
+ expect(@session).to have_css("h2.head", :maximum => "5") # edge case
79
+ expect(@session).to have_css("h2", :maximum => "10")
80
80
  end
81
81
  end
82
82
 
83
83
  context "with minimum" do
84
84
  it "should be true when content occurs same or more times than given" do
85
- @session.should have_css("h2.head", :minimum => 5) # edge case
86
- @session.should have_css("h2", :minimum => 3)
87
- @session.should have_css("p a.doesnotexist", :minimum => 0)
85
+ expect(@session).to have_css("h2.head", :minimum => 5) # edge case
86
+ expect(@session).to have_css("h2", :minimum => 3)
87
+ expect(@session).to have_css("p a.doesnotexist", :minimum => 0)
88
88
  end
89
89
 
90
90
  it "should be false when content occurs fewer times than given" do
91
- @session.should_not have_css("h2.head", :minimum => 6) # edge case
92
- @session.should_not have_css("h2", :minimum => 8)
93
- @session.should_not have_css("p", :minimum => 10)
94
- @session.should_not have_css("p a.doesnotexist", :minimum => 1)
91
+ expect(@session).not_to have_css("h2.head", :minimum => 6) # edge case
92
+ expect(@session).not_to have_css("h2", :minimum => 8)
93
+ expect(@session).not_to have_css("p", :minimum => 10)
94
+ expect(@session).not_to have_css("p a.doesnotexist", :minimum => 1)
95
95
  end
96
96
 
97
97
  it "should coerce minimum to an integer" do
98
- @session.should have_css("h2.head", :minimum => "5") # edge case
99
- @session.should have_css("h2", :minimum => "3")
98
+ expect(@session).to have_css("h2.head", :minimum => "5") # edge case
99
+ expect(@session).to have_css("h2", :minimum => "3")
100
100
  end
101
101
  end
102
102
 
103
103
  context "with text" do
104
104
  it "should discard all matches where the given string is not contained" do
105
- @session.should have_css("p a", :text => "Redirect", :count => 1)
106
- @session.should_not have_css("p a", :text => "Doesnotexist")
105
+ expect(@session).to have_css("p a", :text => "Redirect", :count => 1)
106
+ expect(@session).not_to have_css("p a", :text => "Doesnotexist")
107
107
  end
108
108
 
109
109
  it "should discard all matches where the given regexp is not matched" do
110
- @session.should have_css("p a", :text => /re[dab]i/i, :count => 1)
111
- @session.should_not have_css("p a", :text => /Red$/)
110
+ expect(@session).to have_css("p a", :text => /re[dab]i/i, :count => 1)
111
+ expect(@session).not_to have_css("p a", :text => /Red$/)
112
112
  end
113
113
  end
114
114
  end
@@ -119,110 +119,110 @@ Capybara::SpecHelper.spec '#has_no_css?' do
119
119
  end
120
120
 
121
121
  it "should be false if the given selector is on the page" do
122
- @session.should_not have_no_css("p")
123
- @session.should_not have_no_css("p a#foo")
122
+ expect(@session).not_to have_no_css("p")
123
+ expect(@session).not_to have_no_css("p a#foo")
124
124
  end
125
125
 
126
126
  it "should be true if the given selector is not on the page" do
127
- @session.should have_no_css("abbr")
128
- @session.should have_no_css("p a#doesnotexist")
129
- @session.should have_no_css("p.nosuchclass")
127
+ expect(@session).to have_no_css("abbr")
128
+ expect(@session).to have_no_css("p a#doesnotexist")
129
+ expect(@session).to have_no_css("p.nosuchclass")
130
130
  end
131
131
 
132
132
  it "should respect scopes" do
133
133
  @session.within "//p[@id='first']" do
134
- @session.should_not have_no_css("a#foo")
135
- @session.should have_no_css("a#red")
134
+ expect(@session).not_to have_no_css("a#foo")
135
+ expect(@session).to have_no_css("a#red")
136
136
  end
137
137
  end
138
138
 
139
139
  it "should wait for content to disappear", :requires => [:js] do
140
140
  @session.visit('/with_js')
141
141
  @session.click_link('Click me')
142
- @session.should have_no_css("p#change")
142
+ expect(@session).to have_no_css("p#change")
143
143
  end
144
144
 
145
145
  context "with between" do
146
146
  it "should be false if the content occurs within the range given" do
147
- @session.should_not have_no_css("p", :between => 1..4)
148
- @session.should_not have_no_css("p a#foo", :between => 1..3)
149
- @session.should_not have_no_css("p a.doesnotexist", :between => 0..2)
147
+ expect(@session).not_to have_no_css("p", :between => 1..4)
148
+ expect(@session).not_to have_no_css("p a#foo", :between => 1..3)
149
+ expect(@session).not_to have_no_css("p a.doesnotexist", :between => 0..2)
150
150
  end
151
151
 
152
152
  it "should be true if the content occurs more or fewer times than range" do
153
- @session.should have_no_css("p", :between => 6..11 )
154
- @session.should have_no_css("p a#foo", :between => 4..7)
155
- @session.should have_no_css("p a.doesnotexist", :between => 3..8)
153
+ expect(@session).to have_no_css("p", :between => 6..11 )
154
+ expect(@session).to have_no_css("p a#foo", :between => 4..7)
155
+ expect(@session).to have_no_css("p a.doesnotexist", :between => 3..8)
156
156
  end
157
157
  end
158
158
 
159
159
  context "with count" do
160
160
  it "should be false if the content is on the page the given number of times" do
161
- @session.should_not have_no_css("p", :count => 3)
162
- @session.should_not have_no_css("p a#foo", :count => 1)
163
- @session.should_not have_no_css("p a.doesnotexist", :count => 0)
161
+ expect(@session).not_to have_no_css("p", :count => 3)
162
+ expect(@session).not_to have_no_css("p a#foo", :count => 1)
163
+ expect(@session).not_to have_no_css("p a.doesnotexist", :count => 0)
164
164
  end
165
165
 
166
166
  it "should be true if the content is on the page the given number of times" do
167
- @session.should have_no_css("p", :count => 6)
168
- @session.should have_no_css("p a#foo", :count => 2)
169
- @session.should have_no_css("p a.doesnotexist", :count => 1)
167
+ expect(@session).to have_no_css("p", :count => 6)
168
+ expect(@session).to have_no_css("p a#foo", :count => 2)
169
+ expect(@session).to have_no_css("p a.doesnotexist", :count => 1)
170
170
  end
171
171
 
172
172
  it "should coerce count to an integer" do
173
- @session.should_not have_no_css("p", :count => "3")
174
- @session.should_not have_no_css("p a#foo", :count => "1")
173
+ expect(@session).not_to have_no_css("p", :count => "3")
174
+ expect(@session).not_to have_no_css("p a#foo", :count => "1")
175
175
  end
176
176
  end
177
177
 
178
178
  context "with maximum" do
179
179
  it "should be false when content occurs same or fewer times than given" do
180
- @session.should_not have_no_css("h2.head", :maximum => 5) # edge case
181
- @session.should_not have_no_css("h2", :maximum => 10)
182
- @session.should_not have_no_css("p a.doesnotexist", :maximum => 0)
180
+ expect(@session).not_to have_no_css("h2.head", :maximum => 5) # edge case
181
+ expect(@session).not_to have_no_css("h2", :maximum => 10)
182
+ expect(@session).not_to have_no_css("p a.doesnotexist", :maximum => 0)
183
183
  end
184
184
 
185
185
  it "should be true when content occurs more times than given" do
186
- @session.should have_no_css("h2.head", :maximum => 4) # edge case
187
- @session.should have_no_css("h2", :maximum => 3)
188
- @session.should have_no_css("p", :maximum => 1)
186
+ expect(@session).to have_no_css("h2.head", :maximum => 4) # edge case
187
+ expect(@session).to have_no_css("h2", :maximum => 3)
188
+ expect(@session).to have_no_css("p", :maximum => 1)
189
189
  end
190
190
 
191
191
  it "should coerce maximum to an integer" do
192
- @session.should_not have_no_css("h2.head", :maximum => "5") # edge case
193
- @session.should_not have_no_css("h2", :maximum => "10")
192
+ expect(@session).not_to have_no_css("h2.head", :maximum => "5") # edge case
193
+ expect(@session).not_to have_no_css("h2", :maximum => "10")
194
194
  end
195
195
  end
196
196
 
197
197
  context "with minimum" do
198
198
  it "should be false when content occurs same or more times than given" do
199
- @session.should_not have_no_css("h2.head", :minimum => 5) # edge case
200
- @session.should_not have_no_css("h2", :minimum => 3)
201
- @session.should_not have_no_css("p a.doesnotexist", :minimum => 0)
199
+ expect(@session).not_to have_no_css("h2.head", :minimum => 5) # edge case
200
+ expect(@session).not_to have_no_css("h2", :minimum => 3)
201
+ expect(@session).not_to have_no_css("p a.doesnotexist", :minimum => 0)
202
202
  end
203
203
 
204
204
  it "should be true when content occurs fewer times than given" do
205
- @session.should have_no_css("h2.head", :minimum => 6) # edge case
206
- @session.should have_no_css("h2", :minimum => 8)
207
- @session.should have_no_css("p", :minimum => 15)
208
- @session.should have_no_css("p a.doesnotexist", :minimum => 1)
205
+ expect(@session).to have_no_css("h2.head", :minimum => 6) # edge case
206
+ expect(@session).to have_no_css("h2", :minimum => 8)
207
+ expect(@session).to have_no_css("p", :minimum => 15)
208
+ expect(@session).to have_no_css("p a.doesnotexist", :minimum => 1)
209
209
  end
210
210
 
211
211
  it "should coerce minimum to an integer" do
212
- @session.should_not have_no_css("h2.head", :minimum => "4") # edge case
213
- @session.should_not have_no_css("h2", :minimum => "3")
212
+ expect(@session).not_to have_no_css("h2.head", :minimum => "4") # edge case
213
+ expect(@session).not_to have_no_css("h2", :minimum => "3")
214
214
  end
215
215
  end
216
216
 
217
217
  context "with text" do
218
218
  it "should discard all matches where the given string is not contained" do
219
- @session.should_not have_no_css("p a", :text => "Redirect", :count => 1)
220
- @session.should have_no_css("p a", :text => "Doesnotexist")
219
+ expect(@session).not_to have_no_css("p a", :text => "Redirect", :count => 1)
220
+ expect(@session).to have_no_css("p a", :text => "Doesnotexist")
221
221
  end
222
222
 
223
223
  it "should discard all matches where the given regexp is not matched" do
224
- @session.should_not have_no_css("p a", :text => /re[dab]i/i, :count => 1)
225
- @session.should have_no_css("p a", :text => /Red$/)
224
+ expect(@session).not_to have_no_css("p a", :text => /re[dab]i/i, :count => 1)
225
+ expect(@session).to have_no_css("p a", :text => /Red$/)
226
226
  end
227
227
  end
228
228
  end
@@ -2,56 +2,56 @@ Capybara::SpecHelper.spec '#has_field' do
2
2
  before { @session.visit('/form') }
3
3
 
4
4
  it "should be true if the field is on the page" do
5
- @session.should have_field('Dog')
6
- @session.should have_field('form_description')
7
- @session.should have_field('Region')
8
- @session.should have_field(:'Region')
5
+ expect(@session).to have_field('Dog')
6
+ expect(@session).to have_field('form_description')
7
+ expect(@session).to have_field('Region')
8
+ expect(@session).to have_field(:'Region')
9
9
  end
10
10
 
11
11
  it "should be false if the field is not on the page" do
12
- @session.should_not have_field('Monkey')
12
+ expect(@session).not_to have_field('Monkey')
13
13
  end
14
14
 
15
15
  context 'with value' do
16
16
  it "should be true if a field with the given value is on the page" do
17
- @session.should have_field('First Name', :with => 'John')
18
- @session.should have_field('Phone', :with => '+1 555 7021')
19
- @session.should have_field('Street', :with => 'Sesame street 66')
20
- @session.should have_field('Description', :with => 'Descriptive text goes here')
17
+ expect(@session).to have_field('First Name', :with => 'John')
18
+ expect(@session).to have_field('Phone', :with => '+1 555 7021')
19
+ expect(@session).to have_field('Street', :with => 'Sesame street 66')
20
+ expect(@session).to have_field('Description', :with => 'Descriptive text goes here')
21
21
  end
22
22
 
23
23
  it "should be false if the given field is not on the page" do
24
- @session.should_not have_field('First Name', :with => 'Peter')
25
- @session.should_not have_field('Wrong Name', :with => 'John')
26
- @session.should_not have_field('Description', :with => 'Monkey')
24
+ expect(@session).not_to have_field('First Name', :with => 'Peter')
25
+ expect(@session).not_to have_field('Wrong Name', :with => 'John')
26
+ expect(@session).not_to have_field('Description', :with => 'Monkey')
27
27
  end
28
28
 
29
29
  it "should be true after the field has been filled in with the given value" do
30
30
  @session.fill_in('First Name', :with => 'Jonas')
31
- @session.should have_field('First Name', :with => 'Jonas')
31
+ expect(@session).to have_field('First Name', :with => 'Jonas')
32
32
  end
33
33
 
34
34
  it "should be false after the field has been filled in with a different value" do
35
35
  @session.fill_in('First Name', :with => 'Jonas')
36
- @session.should_not have_field('First Name', :with => 'John')
36
+ expect(@session).not_to have_field('First Name', :with => 'John')
37
37
  end
38
38
  end
39
39
 
40
40
  context 'with type' do
41
41
  it "should be true if a field with the given type is on the page" do
42
- @session.should have_field('First Name', :type => 'text')
43
- @session.should have_field('Html5 Email', :type => 'email')
44
- @session.should have_field('Html5 Tel', :type => 'tel')
45
- @session.should have_field('Description', :type => 'textarea')
46
- @session.should have_field('Languages', :type => 'select')
42
+ expect(@session).to have_field('First Name', :type => 'text')
43
+ expect(@session).to have_field('Html5 Email', :type => 'email')
44
+ expect(@session).to have_field('Html5 Tel', :type => 'tel')
45
+ expect(@session).to have_field('Description', :type => 'textarea')
46
+ expect(@session).to have_field('Languages', :type => 'select')
47
47
  end
48
48
 
49
49
  it "should be false if the given field is not on the page" do
50
- @session.should_not have_field('First Name', :type => 'textarea')
51
- @session.should_not have_field('Html5 Email', :type => 'tel')
52
- @session.should_not have_field('Description', :type => '')
53
- @session.should_not have_field('Description', :type => 'email')
54
- @session.should_not have_field('Languages', :type => 'textarea')
50
+ expect(@session).not_to have_field('First Name', :type => 'textarea')
51
+ expect(@session).not_to have_field('Html5 Email', :type => 'tel')
52
+ expect(@session).not_to have_field('Description', :type => '')
53
+ expect(@session).not_to have_field('Description', :type => 'email')
54
+ expect(@session).not_to have_field('Languages', :type => 'textarea')
55
55
  end
56
56
  end
57
57
  end
@@ -60,55 +60,55 @@ Capybara::SpecHelper.spec '#has_no_field' do
60
60
  before { @session.visit('/form') }
61
61
 
62
62
  it "should be false if the field is on the page" do
63
- @session.should_not have_no_field('Dog')
64
- @session.should_not have_no_field('form_description')
65
- @session.should_not have_no_field('Region')
63
+ expect(@session).not_to have_no_field('Dog')
64
+ expect(@session).not_to have_no_field('form_description')
65
+ expect(@session).not_to have_no_field('Region')
66
66
  end
67
67
 
68
68
  it "should be true if the field is not on the page" do
69
- @session.should have_no_field('Monkey')
69
+ expect(@session).to have_no_field('Monkey')
70
70
  end
71
71
 
72
72
  context 'with value' do
73
73
  it "should be false if a field with the given value is on the page" do
74
- @session.should_not have_no_field('First Name', :with => 'John')
75
- @session.should_not have_no_field('Phone', :with => '+1 555 7021')
76
- @session.should_not have_no_field('Street', :with => 'Sesame street 66')
77
- @session.should_not have_no_field('Description', :with => 'Descriptive text goes here')
74
+ expect(@session).not_to have_no_field('First Name', :with => 'John')
75
+ expect(@session).not_to have_no_field('Phone', :with => '+1 555 7021')
76
+ expect(@session).not_to have_no_field('Street', :with => 'Sesame street 66')
77
+ expect(@session).not_to have_no_field('Description', :with => 'Descriptive text goes here')
78
78
  end
79
79
 
80
80
  it "should be true if the given field is not on the page" do
81
- @session.should have_no_field('First Name', :with => 'Peter')
82
- @session.should have_no_field('Wrong Name', :with => 'John')
83
- @session.should have_no_field('Description', :with => 'Monkey')
81
+ expect(@session).to have_no_field('First Name', :with => 'Peter')
82
+ expect(@session).to have_no_field('Wrong Name', :with => 'John')
83
+ expect(@session).to have_no_field('Description', :with => 'Monkey')
84
84
  end
85
85
 
86
86
  it "should be false after the field has been filled in with the given value" do
87
87
  @session.fill_in('First Name', :with => 'Jonas')
88
- @session.should_not have_no_field('First Name', :with => 'Jonas')
88
+ expect(@session).not_to have_no_field('First Name', :with => 'Jonas')
89
89
  end
90
90
 
91
91
  it "should be true after the field has been filled in with a different value" do
92
92
  @session.fill_in('First Name', :with => 'Jonas')
93
- @session.should have_no_field('First Name', :with => 'John')
93
+ expect(@session).to have_no_field('First Name', :with => 'John')
94
94
  end
95
95
  end
96
96
 
97
97
  context 'with type' do
98
98
  it "should be false if a field with the given type is on the page" do
99
- @session.should_not have_no_field('First Name', :type => 'text')
100
- @session.should_not have_no_field('Html5 Email', :type => 'email')
101
- @session.should_not have_no_field('Html5 Tel', :type => 'tel')
102
- @session.should_not have_no_field('Description', :type => 'textarea')
103
- @session.should_not have_no_field('Languages', :type => 'select')
99
+ expect(@session).not_to have_no_field('First Name', :type => 'text')
100
+ expect(@session).not_to have_no_field('Html5 Email', :type => 'email')
101
+ expect(@session).not_to have_no_field('Html5 Tel', :type => 'tel')
102
+ expect(@session).not_to have_no_field('Description', :type => 'textarea')
103
+ expect(@session).not_to have_no_field('Languages', :type => 'select')
104
104
  end
105
105
 
106
106
  it "should be true if the given field is not on the page" do
107
- @session.should have_no_field('First Name', :type => 'textarea')
108
- @session.should have_no_field('Html5 Email', :type => 'tel')
109
- @session.should have_no_field('Description', :type => '')
110
- @session.should have_no_field('Description', :type => 'email')
111
- @session.should have_no_field('Languages', :type => 'textarea')
107
+ expect(@session).to have_no_field('First Name', :type => 'textarea')
108
+ expect(@session).to have_no_field('Html5 Email', :type => 'tel')
109
+ expect(@session).to have_no_field('Description', :type => '')
110
+ expect(@session).to have_no_field('Description', :type => 'email')
111
+ expect(@session).to have_no_field('Languages', :type => 'textarea')
112
112
  end
113
113
  end
114
114
  end
@@ -117,49 +117,49 @@ Capybara::SpecHelper.spec '#has_checked_field?' do
117
117
  before { @session.visit('/form') }
118
118
 
119
119
  it "should be true if a checked field is on the page" do
120
- @session.should have_checked_field('gender_female')
121
- @session.should have_checked_field('Hamster')
120
+ expect(@session).to have_checked_field('gender_female')
121
+ expect(@session).to have_checked_field('Hamster')
122
122
  end
123
123
 
124
124
  it "should be true for disabled checkboxes if :disabled => true" do
125
- @session.should have_checked_field('Disabled Checkbox', :disabled => true)
125
+ expect(@session).to have_checked_field('Disabled Checkbox', :disabled => true)
126
126
  end
127
127
 
128
128
  it "should be false if an unchecked field is on the page" do
129
- @session.should_not have_checked_field('form_pets_cat')
130
- @session.should_not have_checked_field('Male')
129
+ expect(@session).not_to have_checked_field('form_pets_cat')
130
+ expect(@session).not_to have_checked_field('Male')
131
131
  end
132
132
 
133
133
  it "should be false if no field is on the page" do
134
- @session.should_not have_checked_field('Does Not Exist')
134
+ expect(@session).not_to have_checked_field('Does Not Exist')
135
135
  end
136
136
 
137
137
  it "should be false for disabled checkboxes by default" do
138
- @session.should_not have_checked_field('Disabled Checkbox')
138
+ expect(@session).not_to have_checked_field('Disabled Checkbox')
139
139
  end
140
140
 
141
141
  it "should be false for disabled checkboxes if :disabled => false" do
142
- @session.should_not have_checked_field('Disabled Checkbox', :disabled => false)
142
+ expect(@session).not_to have_checked_field('Disabled Checkbox', :disabled => false)
143
143
  end
144
144
 
145
145
  it "should be true after an unchecked checkbox is checked" do
146
146
  @session.check('form_pets_cat')
147
- @session.should have_checked_field('form_pets_cat')
147
+ expect(@session).to have_checked_field('form_pets_cat')
148
148
  end
149
149
 
150
150
  it "should be false after a checked checkbox is unchecked" do
151
151
  @session.uncheck('form_pets_dog')
152
- @session.should_not have_checked_field('form_pets_dog')
152
+ expect(@session).not_to have_checked_field('form_pets_dog')
153
153
  end
154
154
 
155
155
  it "should be true after an unchecked radio button is chosen" do
156
156
  @session.choose('gender_male')
157
- @session.should have_checked_field('gender_male')
157
+ expect(@session).to have_checked_field('gender_male')
158
158
  end
159
159
 
160
160
  it "should be false after another radio button in the group is chosen" do
161
161
  @session.choose('gender_male')
162
- @session.should_not have_checked_field('gender_female')
162
+ expect(@session).not_to have_checked_field('gender_female')
163
163
  end
164
164
  end
165
165
 
@@ -167,29 +167,29 @@ Capybara::SpecHelper.spec '#has_no_checked_field?' do
167
167
  before { @session.visit('/form') }
168
168
 
169
169
  it "should be false if a checked field is on the page" do
170
- @session.should_not have_no_checked_field('gender_female')
171
- @session.should_not have_no_checked_field('Hamster')
170
+ expect(@session).not_to have_no_checked_field('gender_female')
171
+ expect(@session).not_to have_no_checked_field('Hamster')
172
172
  end
173
173
 
174
174
  it "should be false for disabled checkboxes if :disabled => true" do
175
- @session.should_not have_no_checked_field('Disabled Checkbox', :disabled => true)
175
+ expect(@session).not_to have_no_checked_field('Disabled Checkbox', :disabled => true)
176
176
  end
177
177
 
178
178
  it "should be true if an unchecked field is on the page" do
179
- @session.should have_no_checked_field('form_pets_cat')
180
- @session.should have_no_checked_field('Male')
179
+ expect(@session).to have_no_checked_field('form_pets_cat')
180
+ expect(@session).to have_no_checked_field('Male')
181
181
  end
182
182
 
183
183
  it "should be true if no field is on the page" do
184
- @session.should have_no_checked_field('Does Not Exist')
184
+ expect(@session).to have_no_checked_field('Does Not Exist')
185
185
  end
186
186
 
187
187
  it "should be true for disabled checkboxes by default" do
188
- @session.should have_no_checked_field('Disabled Checkbox')
188
+ expect(@session).to have_no_checked_field('Disabled Checkbox')
189
189
  end
190
190
 
191
191
  it "should be true for disabled checkboxes if :disabled => false" do
192
- @session.should have_no_checked_field('Disabled Checkbox', :disabled => false)
192
+ expect(@session).to have_no_checked_field('Disabled Checkbox', :disabled => false)
193
193
  end
194
194
  end
195
195
 
@@ -197,49 +197,49 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
197
197
  before { @session.visit('/form') }
198
198
 
199
199
  it "should be false if a checked field is on the page" do
200
- @session.should_not have_unchecked_field('gender_female')
201
- @session.should_not have_unchecked_field('Hamster')
200
+ expect(@session).not_to have_unchecked_field('gender_female')
201
+ expect(@session).not_to have_unchecked_field('Hamster')
202
202
  end
203
203
 
204
204
  it "should be true if an unchecked field is on the page" do
205
- @session.should have_unchecked_field('form_pets_cat')
206
- @session.should have_unchecked_field('Male')
205
+ expect(@session).to have_unchecked_field('form_pets_cat')
206
+ expect(@session).to have_unchecked_field('Male')
207
207
  end
208
208
 
209
209
  it "should be true for disabled unchecked fields if :disabled => true" do
210
- @session.should have_unchecked_field('Disabled Unchecked Checkbox', :disabled => true)
210
+ expect(@session).to have_unchecked_field('Disabled Unchecked Checkbox', :disabled => true)
211
211
  end
212
212
 
213
213
  it "should be false if no field is on the page" do
214
- @session.should_not have_unchecked_field('Does Not Exist')
214
+ expect(@session).not_to have_unchecked_field('Does Not Exist')
215
215
  end
216
216
 
217
217
  it "should be false for disabled unchecked fields by default" do
218
- @session.should_not have_unchecked_field('Disabled Unchecked Checkbox')
218
+ expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox')
219
219
  end
220
220
 
221
221
  it "should be false for disabled unchecked fields if :disabled => false" do
222
- @session.should_not have_unchecked_field('Disabled Unchecked Checkbox', :disabled => false)
222
+ expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox', :disabled => false)
223
223
  end
224
224
 
225
225
  it "should be false after an unchecked checkbox is checked" do
226
226
  @session.check('form_pets_cat')
227
- @session.should_not have_unchecked_field('form_pets_cat')
227
+ expect(@session).not_to have_unchecked_field('form_pets_cat')
228
228
  end
229
229
 
230
230
  it "should be true after a checked checkbox is unchecked" do
231
231
  @session.uncheck('form_pets_dog')
232
- @session.should have_unchecked_field('form_pets_dog')
232
+ expect(@session).to have_unchecked_field('form_pets_dog')
233
233
  end
234
234
 
235
235
  it "should be false after an unchecked radio button is chosen" do
236
236
  @session.choose('gender_male')
237
- @session.should_not have_unchecked_field('gender_male')
237
+ expect(@session).not_to have_unchecked_field('gender_male')
238
238
  end
239
239
 
240
240
  it "should be true after another radio button in the group is chosen" do
241
241
  @session.choose('gender_male')
242
- @session.should have_unchecked_field('gender_female')
242
+ expect(@session).to have_unchecked_field('gender_female')
243
243
  end
244
244
  end
245
245
 
@@ -247,28 +247,28 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
247
247
  before { @session.visit('/form') }
248
248
 
249
249
  it "should be true if a checked field is on the page" do
250
- @session.should have_no_unchecked_field('gender_female')
251
- @session.should have_no_unchecked_field('Hamster')
250
+ expect(@session).to have_no_unchecked_field('gender_female')
251
+ expect(@session).to have_no_unchecked_field('Hamster')
252
252
  end
253
253
 
254
254
  it "should be false if an unchecked field is on the page" do
255
- @session.should_not have_no_unchecked_field('form_pets_cat')
256
- @session.should_not have_no_unchecked_field('Male')
255
+ expect(@session).not_to have_no_unchecked_field('form_pets_cat')
256
+ expect(@session).not_to have_no_unchecked_field('Male')
257
257
  end
258
258
 
259
259
  it "should be false for disabled unchecked fields if :disabled => true" do
260
- @session.should_not have_no_unchecked_field('Disabled Unchecked Checkbox', :disabled => true)
260
+ expect(@session).not_to have_no_unchecked_field('Disabled Unchecked Checkbox', :disabled => true)
261
261
  end
262
262
 
263
263
  it "should be true if no field is on the page" do
264
- @session.should have_no_unchecked_field('Does Not Exist')
264
+ expect(@session).to have_no_unchecked_field('Does Not Exist')
265
265
  end
266
266
 
267
267
  it "should be true for disabled unchecked fields by default" do
268
- @session.should have_no_unchecked_field('Disabled Unchecked Checkbox')
268
+ expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox')
269
269
  end
270
270
 
271
271
  it "should be true for disabled unchecked fields if :disabled => false" do
272
- @session.should have_no_unchecked_field('Disabled Unchecked Checkbox', :disabled => false)
272
+ expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox', :disabled => false)
273
273
  end
274
274
  end