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
@@ -4,15 +4,15 @@ Capybara::SpecHelper.spec '#has_link?' do
4
4
  end
5
5
 
6
6
  it "should be true if the given link is on the page" do
7
- @session.should have_link('foo')
8
- @session.should have_link('awesome title')
9
- @session.should have_link('A link', :href => '/with_simple_html')
10
- @session.should have_link(:'A link', :href => :'/with_simple_html')
7
+ expect(@session).to have_link('foo')
8
+ expect(@session).to have_link('awesome title')
9
+ expect(@session).to have_link('A link', :href => '/with_simple_html')
10
+ expect(@session).to have_link(:'A link', :href => :'/with_simple_html')
11
11
  end
12
12
 
13
13
  it "should be false if the given link is not on the page" do
14
- @session.should_not have_link('monkey')
15
- @session.should_not have_link('A link', :href => '/non-existant-href')
14
+ expect(@session).not_to have_link('monkey')
15
+ expect(@session).not_to have_link('A link', :href => '/non-existant-href')
16
16
  end
17
17
  end
18
18
 
@@ -22,13 +22,13 @@ Capybara::SpecHelper.spec '#has_no_link?' do
22
22
  end
23
23
 
24
24
  it "should be false if the given link is on the page" do
25
- @session.should_not have_no_link('foo')
26
- @session.should_not have_no_link('awesome title')
27
- @session.should_not have_no_link('A link', :href => '/with_simple_html')
25
+ expect(@session).not_to have_no_link('foo')
26
+ expect(@session).not_to have_no_link('awesome title')
27
+ expect(@session).not_to have_no_link('A link', :href => '/with_simple_html')
28
28
  end
29
29
 
30
30
  it "should be true if the given link is not on the page" do
31
- @session.should have_no_link('monkey')
32
- @session.should have_no_link('A link', :href => '/non-existant-href')
31
+ expect(@session).to have_no_link('monkey')
32
+ expect(@session).to have_no_link('A link', :href => '/non-existant-href')
33
33
  end
34
34
  end
@@ -2,60 +2,60 @@ Capybara::SpecHelper.spec '#has_select?' 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_select('Locale')
6
- @session.should have_select('form_region')
7
- @session.should have_select('Languages')
8
- @session.should have_select(:'Languages')
5
+ expect(@session).to have_select('Locale')
6
+ expect(@session).to have_select('form_region')
7
+ expect(@session).to have_select('Languages')
8
+ expect(@session).to have_select(:'Languages')
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_select('Monkey')
12
+ expect(@session).not_to have_select('Monkey')
13
13
  end
14
14
 
15
15
  context 'with selected value' do
16
16
  it "should be true if a field with the given value is on the page" do
17
- @session.should have_select('form_locale', :selected => 'English')
18
- @session.should have_select('Region', :selected => 'Norway')
19
- @session.should have_select('Underwear', :selected => [
17
+ expect(@session).to have_select('form_locale', :selected => 'English')
18
+ expect(@session).to have_select('Region', :selected => 'Norway')
19
+ expect(@session).to have_select('Underwear', :selected => [
20
20
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
21
21
  ])
22
22
  end
23
23
 
24
24
  it "should be false if the given field is not on the page" do
25
- @session.should_not have_select('Locale', :selected => 'Swedish')
26
- @session.should_not have_select('Does not exist', :selected => 'John')
27
- @session.should_not have_select('City', :selected => 'Not there')
28
- @session.should_not have_select('Underwear', :selected => [
25
+ expect(@session).not_to have_select('Locale', :selected => 'Swedish')
26
+ expect(@session).not_to have_select('Does not exist', :selected => 'John')
27
+ expect(@session).not_to have_select('City', :selected => 'Not there')
28
+ expect(@session).not_to have_select('Underwear', :selected => [
29
29
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
30
30
  ])
31
- @session.should_not have_select('Underwear', :selected => [
31
+ expect(@session).not_to have_select('Underwear', :selected => [
32
32
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
33
33
  ])
34
- @session.should_not have_select('Underwear', :selected => [
34
+ expect(@session).not_to have_select('Underwear', :selected => [
35
35
  'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
36
36
  ])
37
37
  end
38
38
 
39
39
  it "should be true after the given value is selected" do
40
40
  @session.select('Swedish', :from => 'Locale')
41
- @session.should have_select('Locale', :selected => 'Swedish')
41
+ expect(@session).to have_select('Locale', :selected => 'Swedish')
42
42
  end
43
43
 
44
44
  it "should be false after a different value is selected" do
45
45
  @session.select('Swedish', :from => 'Locale')
46
- @session.should_not have_select('Locale', :selected => 'English')
46
+ expect(@session).not_to have_select('Locale', :selected => 'English')
47
47
  end
48
48
 
49
49
  it "should be true after the given values are selected" do
50
50
  @session.select('Boxers', :from => 'Underwear')
51
- @session.should have_select('Underwear', :selected => [
51
+ expect(@session).to have_select('Underwear', :selected => [
52
52
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
53
53
  ])
54
54
  end
55
55
 
56
56
  it "should be false after one of the values is unselected" do
57
57
  @session.unselect('Briefs', :from => 'Underwear')
58
- @session.should_not have_select('Underwear', :selected => [
58
+ expect(@session).not_to have_select('Underwear', :selected => [
59
59
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
60
60
  ])
61
61
  end
@@ -63,29 +63,29 @@ Capybara::SpecHelper.spec '#has_select?' do
63
63
 
64
64
  context 'with exact options' do
65
65
  it "should be true if a field with the given options is on the page" do
66
- @session.should have_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
67
- @session.should have_select('Tendency', :options => [])
66
+ expect(@session).to have_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
67
+ expect(@session).to have_select('Tendency', :options => [])
68
68
  end
69
69
 
70
70
  it "should be false if the given field is not on the page" do
71
- @session.should_not have_select('Locale', :options => ['Swedish'])
72
- @session.should_not have_select('Does not exist', :options => ['John'])
73
- @session.should_not have_select('City', :options => ['London', 'Made up city'])
74
- @session.should_not have_select('Region', :options => ['Norway', 'Sweden'])
75
- @session.should_not have_select('Region', :options => ['Norway', 'Norway', 'Norway'])
71
+ expect(@session).not_to have_select('Locale', :options => ['Swedish'])
72
+ expect(@session).not_to have_select('Does not exist', :options => ['John'])
73
+ expect(@session).not_to have_select('City', :options => ['London', 'Made up city'])
74
+ expect(@session).not_to have_select('Region', :options => ['Norway', 'Sweden'])
75
+ expect(@session).not_to have_select('Region', :options => ['Norway', 'Norway', 'Norway'])
76
76
  end
77
77
  end
78
78
 
79
79
  context 'with partial options' do
80
80
  it "should be true if a field with the given partial options is on the page" do
81
- @session.should have_select('Region', :with_options => ['Norway', 'Sweden'])
82
- @session.should have_select('City', :with_options => ['London'])
81
+ expect(@session).to have_select('Region', :with_options => ['Norway', 'Sweden'])
82
+ expect(@session).to have_select('City', :with_options => ['London'])
83
83
  end
84
84
 
85
85
  it "should be false if a field with the given partial options is not on the page" do
86
- @session.should_not have_select('Locale', :with_options => ['Uruguayan'])
87
- @session.should_not have_select('Does not exist', :with_options => ['John'])
88
- @session.should_not have_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
86
+ expect(@session).not_to have_select('Locale', :with_options => ['Uruguayan'])
87
+ expect(@session).not_to have_select('Does not exist', :with_options => ['John'])
88
+ expect(@session).not_to have_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
89
89
  end
90
90
  end
91
91
  end
@@ -94,59 +94,59 @@ Capybara::SpecHelper.spec '#has_no_select?' do
94
94
  before { @session.visit('/form') }
95
95
 
96
96
  it "should be false if the field is on the page" do
97
- @session.should_not have_no_select('Locale')
98
- @session.should_not have_no_select('form_region')
99
- @session.should_not have_no_select('Languages')
97
+ expect(@session).not_to have_no_select('Locale')
98
+ expect(@session).not_to have_no_select('form_region')
99
+ expect(@session).not_to have_no_select('Languages')
100
100
  end
101
101
 
102
102
  it "should be true if the field is not on the page" do
103
- @session.should have_no_select('Monkey')
103
+ expect(@session).to have_no_select('Monkey')
104
104
  end
105
105
 
106
106
  context 'with selected value' do
107
107
  it "should be false if a field with the given value is on the page" do
108
- @session.should_not have_no_select('form_locale', :selected => 'English')
109
- @session.should_not have_no_select('Region', :selected => 'Norway')
110
- @session.should_not have_no_select('Underwear', :selected => [
108
+ expect(@session).not_to have_no_select('form_locale', :selected => 'English')
109
+ expect(@session).not_to have_no_select('Region', :selected => 'Norway')
110
+ expect(@session).not_to have_no_select('Underwear', :selected => [
111
111
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
112
112
  ])
113
113
  end
114
114
 
115
115
  it "should be true if the given field is not on the page" do
116
- @session.should have_no_select('Locale', :selected => 'Swedish')
117
- @session.should have_no_select('Does not exist', :selected => 'John')
118
- @session.should have_no_select('City', :selected => 'Not there')
119
- @session.should have_no_select('Underwear', :selected => [
116
+ expect(@session).to have_no_select('Locale', :selected => 'Swedish')
117
+ expect(@session).to have_no_select('Does not exist', :selected => 'John')
118
+ expect(@session).to have_no_select('City', :selected => 'Not there')
119
+ expect(@session).to have_no_select('Underwear', :selected => [
120
120
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
121
121
  ])
122
- @session.should have_no_select('Underwear', :selected => [
122
+ expect(@session).to have_no_select('Underwear', :selected => [
123
123
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
124
124
  ])
125
- @session.should have_no_select('Underwear', :selected => [
125
+ expect(@session).to have_no_select('Underwear', :selected => [
126
126
  'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
127
127
  ])
128
128
  end
129
129
 
130
130
  it "should be false after the given value is selected" do
131
131
  @session.select('Swedish', :from => 'Locale')
132
- @session.should_not have_no_select('Locale', :selected => 'Swedish')
132
+ expect(@session).not_to have_no_select('Locale', :selected => 'Swedish')
133
133
  end
134
134
 
135
135
  it "should be true after a different value is selected" do
136
136
  @session.select('Swedish', :from => 'Locale')
137
- @session.should have_no_select('Locale', :selected => 'English')
137
+ expect(@session).to have_no_select('Locale', :selected => 'English')
138
138
  end
139
139
 
140
140
  it "should be false after the given values are selected" do
141
141
  @session.select('Boxers', :from => 'Underwear')
142
- @session.should_not have_no_select('Underwear', :selected => [
142
+ expect(@session).not_to have_no_select('Underwear', :selected => [
143
143
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
144
144
  ])
145
145
  end
146
146
 
147
147
  it "should be true after one of the values is unselected" do
148
148
  @session.unselect('Briefs', :from => 'Underwear')
149
- @session.should have_no_select('Underwear', :selected => [
149
+ expect(@session).to have_no_select('Underwear', :selected => [
150
150
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
151
151
  ])
152
152
  end
@@ -154,28 +154,28 @@ Capybara::SpecHelper.spec '#has_no_select?' do
154
154
 
155
155
  context 'with exact options' do
156
156
  it "should be false if a field with the given options is on the page" do
157
- @session.should_not have_no_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
157
+ expect(@session).not_to have_no_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
158
158
  end
159
159
 
160
160
  it "should be true if the given field is not on the page" do
161
- @session.should have_no_select('Locale', :options => ['Swedish'])
162
- @session.should have_no_select('Does not exist', :options => ['John'])
163
- @session.should have_no_select('City', :options => ['London', 'Made up city'])
164
- @session.should have_no_select('Region', :options => ['Norway', 'Sweden'])
165
- @session.should have_no_select('Region', :options => ['Norway', 'Norway', 'Norway'])
161
+ expect(@session).to have_no_select('Locale', :options => ['Swedish'])
162
+ expect(@session).to have_no_select('Does not exist', :options => ['John'])
163
+ expect(@session).to have_no_select('City', :options => ['London', 'Made up city'])
164
+ expect(@session).to have_no_select('Region', :options => ['Norway', 'Sweden'])
165
+ expect(@session).to have_no_select('Region', :options => ['Norway', 'Norway', 'Norway'])
166
166
  end
167
167
  end
168
168
 
169
169
  context 'with partial options' do
170
170
  it "should be false if a field with the given partial options is on the page" do
171
- @session.should_not have_no_select('Region', :with_options => ['Norway', 'Sweden'])
172
- @session.should_not have_no_select('City', :with_options => ['London'])
171
+ expect(@session).not_to have_no_select('Region', :with_options => ['Norway', 'Sweden'])
172
+ expect(@session).not_to have_no_select('City', :with_options => ['London'])
173
173
  end
174
174
 
175
175
  it "should be true if a field with the given partial options is not on the page" do
176
- @session.should have_no_select('Locale', :with_options => ['Uruguayan'])
177
- @session.should have_no_select('Does not exist', :with_options => ['John'])
178
- @session.should have_no_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
176
+ expect(@session).to have_no_select('Locale', :with_options => ['Uruguayan'])
177
+ expect(@session).to have_no_select('Does not exist', :with_options => ['John'])
178
+ expect(@session).to have_no_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
179
179
  end
180
180
  end
181
181
  end
@@ -4,67 +4,67 @@ Capybara::SpecHelper.spec '#has_selector?' 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_selector(:xpath, "//p")
8
- @session.should have_selector(:css, "p a#foo")
9
- @session.should have_selector("//p[contains(.,'est')]")
7
+ expect(@session).to have_selector(:xpath, "//p")
8
+ expect(@session).to have_selector(:css, "p a#foo")
9
+ expect(@session).to have_selector("//p[contains(.,'est')]")
10
10
  end
11
11
 
12
12
  it "should be false if the given selector is not on the page" do
13
- @session.should_not have_selector(:xpath, "//abbr")
14
- @session.should_not have_selector(:css, "p a#doesnotexist")
15
- @session.should_not have_selector("//p[contains(.,'thisstringisnotonpage')]")
13
+ expect(@session).not_to have_selector(:xpath, "//abbr")
14
+ expect(@session).not_to have_selector(:css, "p a#doesnotexist")
15
+ expect(@session).not_to have_selector("//p[contains(.,'thisstringisnotonpage')]")
16
16
  end
17
17
 
18
18
  it "should use default selector" do
19
19
  Capybara.default_selector = :css
20
- @session.should_not have_selector("p a#doesnotexist")
21
- @session.should have_selector("p a#foo")
20
+ expect(@session).not_to have_selector("p a#doesnotexist")
21
+ expect(@session).to have_selector("p a#foo")
22
22
  end
23
23
 
24
24
  it "should respect scopes" do
25
25
  @session.within "//p[@id='first']" do
26
- @session.should have_selector(".//a[@id='foo']")
27
- @session.should_not have_selector(".//a[@id='red']")
26
+ expect(@session).to have_selector(".//a[@id='foo']")
27
+ expect(@session).not_to have_selector(".//a[@id='red']")
28
28
  end
29
29
  end
30
30
 
31
31
  context "with count" do
32
32
  it "should be true if the content is on the page the given number of times" do
33
- @session.should have_selector("//p", :count => 3)
34
- @session.should have_selector("//p//a[@id='foo']", :count => 1)
35
- @session.should have_selector("//p[contains(.,'est')]", :count => 1)
33
+ expect(@session).to have_selector("//p", :count => 3)
34
+ expect(@session).to have_selector("//p//a[@id='foo']", :count => 1)
35
+ expect(@session).to have_selector("//p[contains(.,'est')]", :count => 1)
36
36
  end
37
37
 
38
38
  it "should be false if the content is on the page the given number of times" do
39
- @session.should_not have_selector("//p", :count => 6)
40
- @session.should_not have_selector("//p//a[@id='foo']", :count => 2)
41
- @session.should_not have_selector("//p[contains(.,'est')]", :count => 5)
39
+ expect(@session).not_to have_selector("//p", :count => 6)
40
+ expect(@session).not_to have_selector("//p//a[@id='foo']", :count => 2)
41
+ expect(@session).not_to have_selector("//p[contains(.,'est')]", :count => 5)
42
42
  end
43
43
 
44
44
  it "should be false if the content isn't on the page at all" do
45
- @session.should_not have_selector("//abbr", :count => 2)
46
- @session.should_not have_selector("//p//a[@id='doesnotexist']", :count => 1)
45
+ expect(@session).not_to have_selector("//abbr", :count => 2)
46
+ expect(@session).not_to have_selector("//p//a[@id='doesnotexist']", :count => 1)
47
47
  end
48
48
  end
49
49
 
50
50
  context "with text" do
51
51
  it "should discard all matches where the given string is not contained" do
52
- @session.should have_selector("//p//a", :text => "Redirect", :count => 1)
53
- @session.should_not have_selector("//p", :text => "Doesnotexist")
52
+ expect(@session).to have_selector("//p//a", :text => "Redirect", :count => 1)
53
+ expect(@session).not_to have_selector("//p", :text => "Doesnotexist")
54
54
  end
55
55
 
56
56
  it "should respect visibility setting" do
57
- @session.should have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
58
- @session.should_not have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
57
+ expect(@session).to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
58
+ expect(@session).not_to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
59
59
  Capybara.ignore_hidden_elements = false
60
- @session.should have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
60
+ expect(@session).to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
61
61
  Capybara.visible_text_only = true
62
- @session.should_not have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
62
+ expect(@session).not_to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
63
63
  end
64
64
 
65
65
  it "should discard all matches where the given regexp is not matched" do
66
- @session.should have_selector("//p//a", :text => /re[dab]i/i, :count => 1)
67
- @session.should_not have_selector("//p//a", :text => /Red$/)
66
+ expect(@session).to have_selector("//p//a", :text => /re[dab]i/i, :count => 1)
67
+ expect(@session).not_to have_selector("//p//a", :text => /Red$/)
68
68
  end
69
69
  end
70
70
  end
@@ -75,58 +75,58 @@ Capybara::SpecHelper.spec '#has_no_selector?' do
75
75
  end
76
76
 
77
77
  it "should be false if the given selector is on the page" do
78
- @session.should_not have_no_selector(:xpath, "//p")
79
- @session.should_not have_no_selector(:css, "p a#foo")
80
- @session.should_not have_no_selector("//p[contains(.,'est')]")
78
+ expect(@session).not_to have_no_selector(:xpath, "//p")
79
+ expect(@session).not_to have_no_selector(:css, "p a#foo")
80
+ expect(@session).not_to have_no_selector("//p[contains(.,'est')]")
81
81
  end
82
82
 
83
83
  it "should be true if the given selector is not on the page" do
84
- @session.should have_no_selector(:xpath, "//abbr")
85
- @session.should have_no_selector(:css, "p a#doesnotexist")
86
- @session.should have_no_selector("//p[contains(.,'thisstringisnotonpage')]")
84
+ expect(@session).to have_no_selector(:xpath, "//abbr")
85
+ expect(@session).to have_no_selector(:css, "p a#doesnotexist")
86
+ expect(@session).to have_no_selector("//p[contains(.,'thisstringisnotonpage')]")
87
87
  end
88
88
 
89
89
  it "should use default selector" do
90
90
  Capybara.default_selector = :css
91
- @session.should have_no_selector("p a#doesnotexist")
92
- @session.should_not have_no_selector("p a#foo")
91
+ expect(@session).to have_no_selector("p a#doesnotexist")
92
+ expect(@session).not_to have_no_selector("p a#foo")
93
93
  end
94
94
 
95
95
  it "should respect scopes" do
96
96
  @session.within "//p[@id='first']" do
97
- @session.should_not have_no_selector(".//a[@id='foo']")
98
- @session.should have_no_selector(".//a[@id='red']")
97
+ expect(@session).not_to have_no_selector(".//a[@id='foo']")
98
+ expect(@session).to have_no_selector(".//a[@id='red']")
99
99
  end
100
100
  end
101
101
 
102
102
  context "with count" do
103
103
  it "should be false if the content is on the page the given number of times" do
104
- @session.should_not have_no_selector("//p", :count => 3)
105
- @session.should_not have_no_selector("//p//a[@id='foo']", :count => 1)
106
- @session.should_not have_no_selector("//p[contains(.,'est')]", :count => 1)
104
+ expect(@session).not_to have_no_selector("//p", :count => 3)
105
+ expect(@session).not_to have_no_selector("//p//a[@id='foo']", :count => 1)
106
+ expect(@session).not_to have_no_selector("//p[contains(.,'est')]", :count => 1)
107
107
  end
108
108
 
109
109
  it "should be true if the content is on the page the wrong number of times" do
110
- @session.should have_no_selector("//p", :count => 6)
111
- @session.should have_no_selector("//p//a[@id='foo']", :count => 2)
112
- @session.should have_no_selector("//p[contains(.,'est')]", :count => 5)
110
+ expect(@session).to have_no_selector("//p", :count => 6)
111
+ expect(@session).to have_no_selector("//p//a[@id='foo']", :count => 2)
112
+ expect(@session).to have_no_selector("//p[contains(.,'est')]", :count => 5)
113
113
  end
114
114
 
115
115
  it "should be true if the content isn't on the page at all" do
116
- @session.should have_no_selector("//abbr", :count => 2)
117
- @session.should have_no_selector("//p//a[@id='doesnotexist']", :count => 1)
116
+ expect(@session).to have_no_selector("//abbr", :count => 2)
117
+ expect(@session).to have_no_selector("//p//a[@id='doesnotexist']", :count => 1)
118
118
  end
119
119
  end
120
120
 
121
121
  context "with text" do
122
122
  it "should discard all matches where the given string is contained" do
123
- @session.should_not have_no_selector("//p//a", :text => "Redirect", :count => 1)
124
- @session.should have_no_selector("//p", :text => "Doesnotexist")
123
+ expect(@session).not_to have_no_selector("//p//a", :text => "Redirect", :count => 1)
124
+ expect(@session).to have_no_selector("//p", :text => "Doesnotexist")
125
125
  end
126
126
 
127
127
  it "should discard all matches where the given regexp is matched" do
128
- @session.should_not have_no_selector("//p//a", :text => /re[dab]i/i, :count => 1)
129
- @session.should have_no_selector("//p//a", :text => /Red$/)
128
+ expect(@session).not_to have_no_selector("//p//a", :text => /re[dab]i/i, :count => 1)
129
+ expect(@session).to have_no_selector("//p//a", :text => /Red$/)
130
130
  end
131
131
  end
132
132
  end