capybara 2.0.3 → 2.1.0.beta1

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 (81) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.md +73 -0
  3. data/README.md +52 -5
  4. data/lib/capybara.rb +44 -62
  5. data/lib/capybara/cucumber.rb +4 -1
  6. data/lib/capybara/driver/base.rb +13 -9
  7. data/lib/capybara/driver/node.rb +18 -6
  8. data/lib/capybara/helpers.rb +111 -22
  9. data/lib/capybara/node/actions.rb +24 -19
  10. data/lib/capybara/node/base.rb +25 -32
  11. data/lib/capybara/node/document.rb +6 -2
  12. data/lib/capybara/node/element.rb +45 -7
  13. data/lib/capybara/node/finders.rb +48 -21
  14. data/lib/capybara/node/matchers.rb +38 -21
  15. data/lib/capybara/node/simple.rb +29 -7
  16. data/lib/capybara/query.rb +72 -26
  17. data/lib/capybara/rack_test/browser.rb +11 -3
  18. data/lib/capybara/rack_test/css_handlers.rb +8 -0
  19. data/lib/capybara/rack_test/driver.rb +11 -3
  20. data/lib/capybara/rack_test/form.rb +8 -1
  21. data/lib/capybara/rack_test/node.rb +92 -36
  22. data/lib/capybara/rails.rb +1 -2
  23. data/lib/capybara/result.rb +21 -37
  24. data/lib/capybara/rspec/matchers.rb +60 -31
  25. data/lib/capybara/selector.rb +46 -13
  26. data/lib/capybara/selenium/driver.rb +42 -6
  27. data/lib/capybara/selenium/node.rb +23 -5
  28. data/lib/capybara/session.rb +46 -11
  29. data/lib/capybara/spec/public/test.js +12 -0
  30. data/lib/capybara/spec/session/all_spec.rb +9 -8
  31. data/lib/capybara/spec/session/attach_file_spec.rb +14 -0
  32. data/lib/capybara/spec/session/check_spec.rb +14 -0
  33. data/lib/capybara/spec/session/choose_spec.rb +14 -0
  34. data/lib/capybara/spec/session/click_button_spec.rb +77 -1
  35. data/lib/capybara/spec/session/click_link_or_button_spec.rb +65 -0
  36. data/lib/capybara/spec/session/click_link_spec.rb +24 -0
  37. data/lib/capybara/spec/session/current_scope_spec.rb +29 -0
  38. data/lib/capybara/spec/session/fill_in_spec.rb +14 -0
  39. data/lib/capybara/spec/session/find_button_spec.rb +12 -0
  40. data/lib/capybara/spec/session/find_by_id_spec.rb +12 -1
  41. data/lib/capybara/spec/session/find_field_spec.rb +30 -0
  42. data/lib/capybara/spec/session/find_link_spec.rb +12 -0
  43. data/lib/capybara/spec/session/find_spec.rb +258 -16
  44. data/lib/capybara/spec/session/first_spec.rb +25 -8
  45. data/lib/capybara/spec/session/has_css_spec.rb +2 -2
  46. data/lib/capybara/spec/session/has_field_spec.rb +10 -2
  47. data/lib/capybara/spec/session/has_selector_spec.rb +9 -0
  48. data/lib/capybara/spec/session/has_text_spec.rb +96 -0
  49. data/lib/capybara/spec/session/has_title_spec.rb +47 -0
  50. data/lib/capybara/spec/session/node_spec.rb +43 -0
  51. data/lib/capybara/spec/session/reset_session_spec.rb +10 -2
  52. data/lib/capybara/spec/session/save_page_spec.rb +30 -0
  53. data/lib/capybara/spec/session/select_spec.rb +65 -0
  54. data/lib/capybara/spec/session/text_spec.rb +31 -0
  55. data/lib/capybara/spec/session/title_spec.rb +16 -0
  56. data/lib/capybara/spec/session/uncheck_spec.rb +14 -0
  57. data/lib/capybara/spec/session/unselect_spec.rb +42 -0
  58. data/lib/capybara/spec/session/visit_spec.rb +3 -3
  59. data/lib/capybara/spec/session/within_frame_spec.rb +14 -0
  60. data/lib/capybara/spec/session/within_spec.rb +3 -3
  61. data/lib/capybara/spec/spec_helper.rb +6 -1
  62. data/lib/capybara/spec/views/form.erb +39 -2
  63. data/lib/capybara/spec/views/frame_child.erb +9 -0
  64. data/lib/capybara/spec/views/frame_parent.erb +8 -0
  65. data/lib/capybara/spec/views/with_base_tag.erb +10 -0
  66. data/lib/capybara/spec/views/with_count.erb +7 -0
  67. data/lib/capybara/spec/views/with_hover.erb +17 -0
  68. data/lib/capybara/spec/views/with_html.erb +21 -2
  69. data/lib/capybara/spec/views/with_js.erb +5 -0
  70. data/lib/capybara/spec/views/with_scope.erb +6 -1
  71. data/lib/capybara/spec/views/with_title.erb +1 -0
  72. data/lib/capybara/spec/views/within_frames.erb +1 -0
  73. data/lib/capybara/version.rb +1 -1
  74. data/spec/basic_node_spec.rb +75 -24
  75. data/spec/dsl_spec.rb +2 -1
  76. data/spec/rack_test_spec.rb +4 -3
  77. data/spec/rspec/matchers_spec.rb +105 -17
  78. data/spec/server_spec.rb +8 -8
  79. data/spec/spec_helper.rb +2 -1
  80. metadata +83 -23
  81. metadata.gz.sig +0 -0
@@ -38,22 +38,39 @@ Capybara::SpecHelper.spec '#first' do
38
38
  @session.first('h1').text.should == 'This is a test'
39
39
  @session.first("input[id='test_field']")[:value].should == 'monkey'
40
40
  end
41
- after { Capybara.default_selector = :xpath }
42
41
  end
43
42
 
44
43
  context "with visible filter" do
45
- after { Capybara.ignore_hidden_elements = false }
46
- it "should only find visible nodes if true given" do
47
- @session.first(:css, "a#invisible").should_not be_nil
44
+ it "should only find visible nodes when true" do
48
45
  @session.first(:css, "a#invisible", :visible => true).should be_nil
49
- Capybara.ignore_hidden_elements = true
50
- @session.first(:css, "a#invisible").should be_nil
51
46
  end
52
47
 
53
- it "should include invisible nodes if false given" do
54
- Capybara.ignore_hidden_elements = true
48
+ it "should find nodes regardless of whether they are invisible when false" do
55
49
  @session.first(:css, "a#invisible", :visible => false).should_not be_nil
50
+ @session.first(:css, "a#visible", :visible => false).should_not be_nil
51
+ end
52
+
53
+ it "should find nodes regardless of whether they are invisible when :all" do
54
+ @session.first(:css, "a#invisible", :visible => :all).should_not be_nil
55
+ @session.first(:css, "a#visible", :visible => :all).should_not be_nil
56
+ end
57
+
58
+ it "should find only hidden nodes when :hidden" do
59
+ @session.first(:css, "a#invisible", :visible => :hidden).should_not be_nil
60
+ @session.first(:css, "a#visible", :visible => :hidden).should be_nil
61
+ end
62
+
63
+ it "should find only visible nodes when :visible" do
64
+ @session.first(:css, "a#invisible", :visible => :visible).should be_nil
65
+ @session.first(:css, "a#visible", :visible => :visible).should_not be_nil
66
+ end
67
+
68
+ it "should default to Capybara.ignore_hidden_elements" do
69
+ Capybara.ignore_hidden_elements = true
56
70
  @session.first(:css, "a#invisible").should be_nil
71
+ Capybara.ignore_hidden_elements = false
72
+ @session.first(:css, "a#invisible").should_not be_nil
73
+ @session.first(:css, "a").should_not be_nil
57
74
  end
58
75
  end
59
76
 
@@ -70,7 +70,7 @@ Capybara::SpecHelper.spec '#has_css?' do
70
70
 
71
71
  it "should be false when content occurs more times than given" do
72
72
  @session.should_not have_css("h2.head", :maximum => 4) # edge case
73
- @session.should_not have_css("h2", :maximum => 6)
73
+ @session.should_not have_css("h2", :maximum => 3)
74
74
  @session.should_not have_css("p", :maximum => 1)
75
75
  end
76
76
 
@@ -184,7 +184,7 @@ Capybara::SpecHelper.spec '#has_no_css?' do
184
184
 
185
185
  it "should be true when content occurs more times than given" do
186
186
  @session.should have_no_css("h2.head", :maximum => 4) # edge case
187
- @session.should have_no_css("h2", :maximum => 6)
187
+ @session.should have_no_css("h2", :maximum => 3)
188
188
  @session.should have_no_css("p", :maximum => 1)
189
189
  end
190
190
 
@@ -42,12 +42,16 @@ Capybara::SpecHelper.spec '#has_field' do
42
42
  @session.should have_field('First Name', :type => 'text')
43
43
  @session.should have_field('Html5 Email', :type => 'email')
44
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')
45
47
  end
46
48
 
47
49
  it "should be false if the given field is not on the page" do
48
- @session.should_not have_field('First Name', :type => 'email')
50
+ @session.should_not have_field('First Name', :type => 'textarea')
49
51
  @session.should_not have_field('Html5 Email', :type => 'tel')
50
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')
51
55
  end
52
56
  end
53
57
  end
@@ -95,12 +99,16 @@ Capybara::SpecHelper.spec '#has_no_field' do
95
99
  @session.should_not have_no_field('First Name', :type => 'text')
96
100
  @session.should_not have_no_field('Html5 Email', :type => 'email')
97
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')
98
104
  end
99
105
 
100
106
  it "should be true if the given field is not on the page" do
101
- @session.should have_no_field('First Name', :type => 'email')
107
+ @session.should have_no_field('First Name', :type => 'textarea')
102
108
  @session.should have_no_field('Html5 Email', :type => 'tel')
103
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')
104
112
  end
105
113
  end
106
114
  end
@@ -53,6 +53,15 @@ Capybara::SpecHelper.spec '#has_selector?' do
53
53
  @session.should_not have_selector("//p", :text => "Doesnotexist")
54
54
  end
55
55
 
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)
59
+ Capybara.ignore_hidden_elements = false
60
+ @session.should have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
61
+ Capybara.visible_text_only = true
62
+ @session.should_not have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
63
+ end
64
+
56
65
  it "should discard all matches where the given regexp is not matched" do
57
66
  @session.should have_selector("//p//a", :text => /re[dab]i/i, :count => 1)
58
67
  @session.should_not have_selector("//p//a", :text => /Red$/)
@@ -74,6 +74,17 @@ Capybara::SpecHelper.spec '#has_text?' do
74
74
  @session.should_not have_text('Inside element with hidden ancestor')
75
75
  end
76
76
 
77
+ it "should be true if :all given and text is invisible." do
78
+ @session.visit('/with_html')
79
+ @session.should have_text(:all, 'Some of this text is hidden!')
80
+ end
81
+
82
+ it "should be true if `Capybara.ignore_hidden_elements = true` and text is invisible." do
83
+ Capybara.ignore_hidden_elements = false
84
+ @session.visit('/with_html')
85
+ @session.should have_text('Some of this text is hidden!')
86
+ end
87
+
77
88
  it "should be true if the text in the page matches given regexp" do
78
89
  @session.visit('/with_html')
79
90
  @session.should have_text(/Lorem/)
@@ -105,6 +116,80 @@ Capybara::SpecHelper.spec '#has_text?' do
105
116
  @session.click_link('Click me')
106
117
  @session.should have_text("Has been clicked")
107
118
  end
119
+
120
+ context "with between" do
121
+ it "should be true if the text occurs within the range given" do
122
+ @session.visit('/with_count')
123
+ @session.should have_text('count', between: 1..3)
124
+ @session.should have_text(/count/, between: 2..2)
125
+ end
126
+
127
+ it "should be false if the text occurs more or fewer times than range" do
128
+ @session.visit('/with_count')
129
+ @session.should_not have_text('count', between: 0..1)
130
+ @session.should_not have_text('count', between: 3..10)
131
+ @session.should_not have_text(/count/, between: 2...2)
132
+ end
133
+ end
134
+
135
+ context "with count" do
136
+ it "should be true if the text occurs the given number of times" do
137
+ @session.visit('/with_count')
138
+ @session.should have_text('count', count: 2)
139
+ end
140
+
141
+ it "should be false if the text occurs a different number of times than the given" do
142
+ @session.visit('/with_count')
143
+ @session.should_not have_text('count', count: 0)
144
+ @session.should_not have_text('count', count: 1)
145
+ @session.should_not have_text(/count/, count: 3)
146
+ end
147
+
148
+ it "should coerce count to an integer" do
149
+ @session.visit('/with_count')
150
+ @session.should have_text('count', count: '2')
151
+ @session.should_not have_text('count', count: '3')
152
+ end
153
+ end
154
+
155
+ context "with maximum" do
156
+ it "should be true when text occurs same or fewer times than given" do
157
+ @session.visit('/with_count')
158
+ @session.should have_text('count', maximum: 2)
159
+ @session.should have_text(/count/, maximum: 3)
160
+ end
161
+
162
+ it "should be false when text occurs more times than given" do
163
+ @session.visit('/with_count')
164
+ @session.should_not have_text('count', maximum: 1)
165
+ @session.should_not have_text('count', maximum: 0)
166
+ end
167
+
168
+ it "should coerce maximum to an integer" do
169
+ @session.visit('/with_count')
170
+ @session.should have_text('count', maximum: '2')
171
+ @session.should_not have_text('count', maximum: '1')
172
+ end
173
+ end
174
+
175
+ context "with minimum" do
176
+ it "should be true when text occurs same or more times than given" do
177
+ @session.visit('/with_count')
178
+ @session.should have_text('count', minimum: 2)
179
+ @session.should have_text(/count/, minimum: 0)
180
+ end
181
+
182
+ it "should be false when text occurs fewer times than given" do
183
+ @session.visit('/with_count')
184
+ @session.should_not have_text('count', minimum: 3)
185
+ end
186
+
187
+ it "should coerce minimum to an integer" do
188
+ @session.visit('/with_count')
189
+ @session.should have_text('count', minimum: '2')
190
+ @session.should_not have_text('count', minimum: '3')
191
+ end
192
+ end
108
193
  end
109
194
 
110
195
  Capybara::SpecHelper.spec '#has_no_text?' do
@@ -172,6 +257,17 @@ Capybara::SpecHelper.spec '#has_no_text?' do
172
257
  @session.should have_no_text('Inside element with hidden ancestor')
173
258
  end
174
259
 
260
+ it "should be false if :all given and text is invisible." do
261
+ @session.visit('/with_html')
262
+ @session.should_not have_no_text(:all, 'Some of this text is hidden!')
263
+ end
264
+
265
+ it "should be false if `Capybara.ignore_hidden_elements = true` and text is invisible." do
266
+ Capybara.ignore_hidden_elements = false
267
+ @session.visit('/with_html')
268
+ @session.should_not have_no_text('Some of this text is hidden!')
269
+ end
270
+
175
271
  it "should be true if the text in the page doesn't match given regexp" do
176
272
  @session.visit('/with_html')
177
273
  @session.should have_no_text(/xxxxyzzz/)
@@ -0,0 +1,47 @@
1
+ Capybara::SpecHelper.spec '#has_title?' do
2
+ before do
3
+ @session.visit('/with_js')
4
+ end
5
+
6
+ it "should be true if the page has the given title" do
7
+ @session.should have_title('with_js')
8
+ end
9
+
10
+ it "should allow regexp matches" do
11
+ @session.should have_title(/w[a-z]{3}_js/)
12
+ @session.should_not have_title(/monkey/)
13
+ end
14
+
15
+ it "should wait for title", :requires => [:js] do
16
+ @session.click_link("Change title")
17
+ @session.should have_title("changed title")
18
+ end
19
+
20
+ it "should be false if the page has not the given title" do
21
+ @session.should_not have_title('monkey')
22
+ end
23
+ end
24
+
25
+ Capybara::SpecHelper.spec '#has_no_title?' do
26
+ before do
27
+ @session.visit('/with_js')
28
+ end
29
+
30
+ it "should be false if the page has the given title" do
31
+ @session.should_not have_no_title('with_js')
32
+ end
33
+
34
+ it "should allow regexp matches" do
35
+ @session.should_not have_no_title(/w[a-z]{3}_js/)
36
+ @session.should have_no_title(/monkey/)
37
+ end
38
+
39
+ it "should wait for title to disappear", :requires => [:js] do
40
+ @session.click_link("Change title")
41
+ @session.should have_no_title('with_js')
42
+ end
43
+
44
+ it "should be true if the page has not the given title" do
45
+ @session.should have_no_title('monkey')
46
+ end
47
+ end
@@ -71,6 +71,18 @@ Capybara::SpecHelper.spec "node" do
71
71
  @session.first('//input').set('')
72
72
  @session.first('//input').value.should == ''
73
73
  end
74
+
75
+ it "should not set if the text field is readonly" do
76
+ @session.first('//input[@readonly]').value.should == 'should not change'
77
+ @session.first('//input[@readonly]').set('changed')
78
+ @session.first('//input[@readonly]').value.should == 'should not change'
79
+ end
80
+
81
+ it "should not set if the textarea is readonly" do
82
+ @session.first('//textarea[@readonly]').value.should == 'textarea should not change'
83
+ @session.first('//textarea[@readonly]').set('changed')
84
+ @session.first('//textarea[@readonly]').value.should == 'textarea should not change'
85
+ end
74
86
  end
75
87
 
76
88
  describe "#tag_name" do
@@ -81,8 +93,29 @@ Capybara::SpecHelper.spec "node" do
81
93
  end
82
94
  end
83
95
 
96
+ describe "#disabled?" do
97
+ it "should extract disabled node" do
98
+ @session.visit('/form')
99
+ @session.find('//input[@id="customer_name"]').should be_disabled
100
+ @session.find('//input[@id="customer_email"]').should_not be_disabled
101
+ end
102
+
103
+ it "should see disabled options as disabled" do
104
+ @session.visit('/form')
105
+ @session.find('//select[@id="form_title"]/option[1]').should_not be_disabled
106
+ @session.find('//select[@id="form_title"]/option[@disabled]').should be_disabled
107
+ end
108
+
109
+ it "should see enabled options in disabled select as disabled" do
110
+ @session.visit('/form')
111
+ @session.find('//select[@id="form_disabled_select"]/option').should be_disabled
112
+ @session.find('//select[@id="form_title"]/option[1]').should_not be_disabled
113
+ end
114
+ end
115
+
84
116
  describe "#visible?" do
85
117
  it "should extract node visibility" do
118
+ Capybara.ignore_hidden_elements = false
86
119
  @session.first('//a').should be_visible
87
120
 
88
121
  @session.find('//div[@id="hidden"]').should_not be_visible
@@ -137,6 +170,16 @@ Capybara::SpecHelper.spec "node" do
137
170
  @session.find('//div[contains(., "Dropped!")]').should_not be_nil
138
171
  end
139
172
  end
173
+
174
+ describe '#hover', :requires => [:hover] do
175
+ it "should allow hovering on an element" do
176
+ pending "Selenium with firefox doesn't currently work with this (selenium with chrome does)" if @session.respond_to?(:mode) && @session.mode == :selenium && @session.driver.browser.browser == :firefox
177
+ @session.visit('/with_hover')
178
+ @session.find(:css,'.hidden_until_hover', :visible => false).should_not be_visible
179
+ @session.find(:css,'.wrapper').hover
180
+ @session.find(:css, '.hidden_until_hover', :visible => false).should be_visible
181
+ end
182
+ end
140
183
 
141
184
  describe '#reload', :requires => [:js] do
142
185
  context "without automatic reload" do
@@ -31,12 +31,20 @@ Capybara::SpecHelper.spec '#reset_session!' do
31
31
  @session.should have_no_selector('.//h1')
32
32
  end
33
33
 
34
- it "raises any errors caught inside the server" do
34
+ it "raises any errors caught inside the server", :requires => [:server] do
35
+ quietly { @session.visit("/error") }
35
36
  expect do
36
- quietly { @session.visit("/error") }
37
37
  @session.reset_session!
38
38
  end.to raise_error(TestApp::TestAppError)
39
39
  @session.visit("/")
40
40
  @session.current_path.should == "/"
41
41
  end
42
+
43
+ it "ignores server errors when `Capybara.raise_server_errors = false`", :requires => [:server] do
44
+ Capybara.raise_server_errors = false
45
+ quietly { @session.visit("/error") }
46
+ @session.reset_session!
47
+ @session.visit("/")
48
+ @session.current_path.should == "/"
49
+ end
42
50
  end
@@ -43,4 +43,34 @@ Capybara::SpecHelper.spec '#save_page' do
43
43
  filename = path.split("/").last
44
44
  result.should == filename
45
45
  end
46
+
47
+ context "asset_host contains a string" do
48
+ before { Capybara.asset_host = "http://example.com" }
49
+ after { Capybara.asset_host = nil }
50
+
51
+ it "prepends base tag with value from asset_host to the head" do
52
+ @session.visit("/with_js")
53
+ path = @session.save_page
54
+
55
+ result = File.read(path)
56
+ result.should include("<head><base href='http://example.com' />")
57
+ end
58
+
59
+ it "doesn't prepend base tag to pages when asset_host is nil" do
60
+ Capybara.asset_host = nil
61
+ @session.visit("/with_js")
62
+ path = @session.save_page
63
+
64
+ result = File.read(path)
65
+ result.should_not include("http://example.com")
66
+ end
67
+
68
+ it "doesn't prepend base tag to pages which already have it" do
69
+ @session.visit("/with_base_tag")
70
+ path = @session.save_page
71
+
72
+ result = File.read(path)
73
+ result.should_not include("http://example.com")
74
+ end
75
+ end
46
76
  end
@@ -12,6 +12,29 @@ Capybara::SpecHelper.spec "#select" do
12
12
  @session.find_field('Title').value.should == 'Miss'
13
13
  end
14
14
 
15
+ it "should allow selecting options where there are inexact matches" do
16
+ @session.select("Mr", :from => 'Title')
17
+ @session.find_field('Title').value.should == 'Mr'
18
+ end
19
+
20
+ it "should allow selecting options where they are the only inexact match" do
21
+ @session.select("Mis", :from => 'Title')
22
+ @session.find_field('Title').value.should == 'Miss'
23
+ end
24
+
25
+ it "should not allow selecting options where they are the only inexact match if `Capybara.exact_options = true`" do
26
+ Capybara.exact_options = true
27
+ expect do
28
+ @session.select("Mis", :from => 'Title')
29
+ end.to raise_error(Capybara::ElementNotFound)
30
+ end
31
+
32
+ it "should not allow selecting an option if the match is ambiguous" do
33
+ expect do
34
+ @session.select("M", :from => 'Title')
35
+ end.to raise_error(Capybara::Ambiguous)
36
+ end
37
+
15
38
  it "should return the value attribute rather than content if present" do
16
39
  @session.find_field('Locale').value.should == 'en'
17
40
  end
@@ -121,4 +144,46 @@ Capybara::SpecHelper.spec "#select" do
121
144
  @session.find_field('Underwear').value.should include('thermal')
122
145
  end
123
146
  end
147
+
148
+ context "with :exact option" do
149
+ context "when `false`" do
150
+ it "can match select box approximately" do
151
+ @session.select("Finish", :from => "Loc", :exact => false)
152
+ @session.click_button("awesome")
153
+ extract_results(@session)["locale"].should == "fi"
154
+ end
155
+
156
+ it "can match option approximately" do
157
+ @session.select("Fin", :from => "Locale", :exact => false)
158
+ @session.click_button("awesome")
159
+ extract_results(@session)["locale"].should == "fi"
160
+ end
161
+
162
+ it "can match option approximately when :from not given" do
163
+ @session.select("made-up language", :exact => false)
164
+ @session.click_button("awesome")
165
+ extract_results(@session)["locale"].should == "jo"
166
+ end
167
+ end
168
+
169
+ context "when `true`" do
170
+ it "can match select box approximately" do
171
+ expect do
172
+ @session.select("Finish", :from => "Loc", :exact => true)
173
+ end.to raise_error(Capybara::ElementNotFound)
174
+ end
175
+
176
+ it "can match option approximately" do
177
+ expect do
178
+ @session.select("Fin", :from => "Locale", :exact => true)
179
+ end.to raise_error(Capybara::ElementNotFound)
180
+ end
181
+
182
+ it "can match option approximately when :from not given" do
183
+ expect do
184
+ @session.select("made-up language", :exact => true)
185
+ end.to raise_error(Capybara::ElementNotFound)
186
+ end
187
+ end
188
+ end
124
189
  end