capybara 1.1.4 → 2.0.0.beta2
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.
- data/History.txt +100 -0
- data/License.txt +22 -0
- data/README.md +829 -0
- data/lib/capybara.rb +124 -6
- data/lib/capybara/cucumber.rb +2 -5
- data/lib/capybara/driver/base.rb +5 -5
- data/lib/capybara/driver/node.rb +2 -2
- data/lib/capybara/dsl.rb +3 -121
- data/lib/capybara/node/actions.rb +12 -28
- data/lib/capybara/node/base.rb +5 -13
- data/lib/capybara/node/element.rb +21 -21
- data/lib/capybara/node/finders.rb +27 -89
- data/lib/capybara/node/matchers.rb +107 -69
- data/lib/capybara/node/simple.rb +11 -13
- data/lib/capybara/query.rb +78 -0
- data/lib/capybara/rack_test/browser.rb +16 -27
- data/lib/capybara/rack_test/driver.rb +11 -1
- data/lib/capybara/rack_test/node.rb +17 -1
- data/lib/capybara/result.rb +84 -0
- data/lib/capybara/rspec/matchers.rb +28 -63
- data/lib/capybara/selector.rb +97 -33
- data/lib/capybara/selenium/driver.rb +14 -61
- data/lib/capybara/selenium/node.rb +6 -15
- data/lib/capybara/server.rb +32 -27
- data/lib/capybara/session.rb +54 -30
- data/lib/capybara/spec/public/jquery-ui.js +791 -0
- data/lib/capybara/spec/public/jquery.js +9046 -0
- data/lib/capybara/spec/public/test.js +4 -1
- data/lib/capybara/spec/session.rb +56 -27
- data/lib/capybara/spec/session/all_spec.rb +8 -4
- data/lib/capybara/spec/session/attach_file_spec.rb +12 -9
- data/lib/capybara/spec/session/check_spec.rb +6 -3
- data/lib/capybara/spec/session/choose_spec.rb +4 -1
- data/lib/capybara/spec/session/click_button_spec.rb +5 -14
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +2 -1
- data/lib/capybara/spec/session/click_link_spec.rb +3 -17
- data/lib/capybara/spec/session/current_url_spec.rb +77 -9
- data/lib/capybara/spec/session/fill_in_spec.rb +8 -18
- data/lib/capybara/spec/session/find_spec.rb +19 -46
- data/lib/capybara/spec/session/first_spec.rb +2 -34
- data/lib/capybara/spec/session/has_css_spec.rb +1 -1
- data/lib/capybara/spec/session/has_field_spec.rb +28 -0
- data/lib/capybara/spec/session/has_select_spec.rb +84 -31
- data/lib/capybara/spec/session/has_table_spec.rb +7 -69
- data/lib/capybara/spec/session/has_text_spec.rb +168 -0
- data/lib/capybara/spec/session/javascript.rb +65 -81
- data/lib/capybara/spec/session/node_spec.rb +115 -0
- data/lib/capybara/spec/session/screenshot.rb +29 -0
- data/lib/capybara/spec/session/select_spec.rb +12 -12
- data/lib/capybara/spec/session/text_spec.rb +9 -4
- data/lib/capybara/spec/session/unselect_spec.rb +12 -6
- data/lib/capybara/spec/session/visit_spec.rb +76 -0
- data/lib/capybara/spec/session/within_frame_spec.rb +33 -0
- data/lib/capybara/spec/session/within_spec.rb +47 -58
- data/lib/capybara/spec/session/within_window_spec.rb +40 -0
- data/lib/capybara/spec/test_app.rb +27 -3
- data/lib/capybara/spec/views/form.erb +11 -10
- data/lib/capybara/spec/views/host_links.erb +2 -2
- data/lib/capybara/spec/views/tables.erb +6 -66
- data/lib/capybara/spec/views/with_html.erb +3 -3
- data/lib/capybara/spec/views/with_js.erb +11 -8
- data/lib/capybara/util/save_and_open_page.rb +4 -3
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +15 -3
- data/spec/dsl_spec.rb +12 -10
- data/spec/rack_test_spec.rb +152 -0
- data/spec/rspec/features_spec.rb +0 -2
- data/spec/rspec/matchers_spec.rb +164 -89
- data/spec/rspec_spec.rb +0 -2
- data/spec/selenium_spec.rb +67 -0
- data/spec/server_spec.rb +35 -23
- data/spec/spec_helper.rb +18 -2
- metadata +30 -30
- data/README.rdoc +0 -722
- data/lib/capybara/spec/driver.rb +0 -301
- data/lib/capybara/spec/session/current_host_spec.rb +0 -68
- data/lib/capybara/spec/session/has_content_spec.rb +0 -106
- data/lib/capybara/util/timeout.rb +0 -27
- data/spec/driver/rack_test_driver_spec.rb +0 -89
- data/spec/driver/selenium_driver_spec.rb +0 -37
- data/spec/session/rack_test_session_spec.rb +0 -55
- data/spec/session/selenium_session_spec.rb +0 -26
- data/spec/string_spec.rb +0 -77
- data/spec/timeout_spec.rb +0 -28
@@ -17,9 +17,9 @@ shared_examples_for "fill_in" do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should fill in a text field by label without for" do
|
20
|
-
@session.fill_in('
|
20
|
+
@session.fill_in('First Name', :with => 'Harry')
|
21
21
|
@session.click_button('awesome')
|
22
|
-
extract_results(@session)['
|
22
|
+
extract_results(@session)['first_name'].should == 'Harry'
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should fill in a url field by label without for" do
|
@@ -28,12 +28,6 @@ shared_examples_for "fill_in" do
|
|
28
28
|
extract_results(@session)['html5_url'].should == 'http://www.avenueq.com'
|
29
29
|
end
|
30
30
|
|
31
|
-
it "should favour exact label matches over partial matches" do
|
32
|
-
@session.fill_in('Name', :with => 'Harry Jones')
|
33
|
-
@session.click_button('awesome')
|
34
|
-
extract_results(@session)['name'].should == 'Harry Jones'
|
35
|
-
end
|
36
|
-
|
37
31
|
it "should fill in a textarea by id" do
|
38
32
|
@session.fill_in('form_description', :with => 'Texty text')
|
39
33
|
@session.click_button('awesome')
|
@@ -93,32 +87,28 @@ shared_examples_for "fill_in" do
|
|
93
87
|
@session.click_button('awesome')
|
94
88
|
extract_results(@session)['password'].should == 'supasikrit'
|
95
89
|
end
|
96
|
-
|
97
|
-
it "should prefer exact matches over partial matches" do
|
98
|
-
@session.fill_in('Name', :with => 'Ford Prefect')
|
99
|
-
@session.click_button('awesome')
|
100
|
-
extract_results(@session)['name'].should == 'Ford Prefect'
|
101
|
-
end
|
102
|
-
|
90
|
+
|
103
91
|
it "should throw an exception if a hash containing 'with' is not provided" do
|
104
92
|
lambda{@session.fill_in 'Name', 'ignu'}.should raise_error
|
105
93
|
end
|
106
|
-
|
94
|
+
|
107
95
|
context "with ignore_hidden_fields" do
|
108
96
|
before { Capybara.ignore_hidden_elements = true }
|
109
97
|
after { Capybara.ignore_hidden_elements = false }
|
110
98
|
it "should not find a hidden field" do
|
99
|
+
msg = "Unable to find field \"Super Secret\""
|
111
100
|
running do
|
112
101
|
@session.fill_in('Super Secret', :with => '777')
|
113
|
-
end.should raise_error(Capybara::ElementNotFound)
|
102
|
+
end.should raise_error(Capybara::ElementNotFound, msg)
|
114
103
|
end
|
115
104
|
end
|
116
105
|
|
117
106
|
context "with a locator that doesn't exist" do
|
118
107
|
it "should raise an error" do
|
108
|
+
msg = "Unable to find field \"does not exist\""
|
119
109
|
running do
|
120
110
|
@session.fill_in('does not exist', :with => 'Blah blah')
|
121
|
-
end.should raise_error(Capybara::ElementNotFound)
|
111
|
+
end.should raise_error(Capybara::ElementNotFound, msg)
|
122
112
|
end
|
123
113
|
end
|
124
114
|
end
|
@@ -15,29 +15,11 @@ shared_examples_for "find" do
|
|
15
15
|
|
16
16
|
it "should find the first element using the given locator and options" do
|
17
17
|
@session.find('//a', :text => 'Redirect')[:id].should == 'red'
|
18
|
-
@session.find(:css, 'a', :text => 'A link')[:title].should == 'twas a fine link'
|
18
|
+
@session.find(:css, 'a', :text => 'A link came first')[:title].should == 'twas a fine link'
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
@session.visit('/form')
|
24
|
-
@form = @session.find(:css, '#get-form')
|
25
|
-
@form.should have_field('Middle Name')
|
26
|
-
@form.should have_no_field('Languages')
|
27
|
-
@form.fill_in('Middle Name', :with => 'Monkey')
|
28
|
-
@form.click_button('med')
|
29
|
-
extract_results(@session)['middle_name'].should == 'Monkey'
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should scope CSS selectors" do
|
33
|
-
@session.find(:css, '#second').should have_no_css('h1')
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should have a reference to its parent if there is one" do
|
37
|
-
@node = @session.find(:css, '#first')
|
38
|
-
@node.parent.should == @node.session.document
|
39
|
-
@node.find('a').parent.should == @node
|
40
|
-
end
|
21
|
+
it "should raise an error if there are multiple matches" do
|
22
|
+
expect { @session.find('//a') }.to raise_error(Capybara::Ambiguous)
|
41
23
|
end
|
42
24
|
|
43
25
|
context "with css selectors" do
|
@@ -85,25 +67,22 @@ shared_examples_for "find" do
|
|
85
67
|
end
|
86
68
|
end
|
87
69
|
|
88
|
-
context "with custom selector with
|
89
|
-
|
70
|
+
context "with custom selector with custom filter" do
|
71
|
+
before do
|
90
72
|
Capybara.add_selector(:monkey) do
|
91
73
|
xpath { |num| ".//*[contains(@id, 'monkey')][#{num}]" }
|
92
|
-
|
74
|
+
filter(:name) { |node, name| node.text == name }
|
93
75
|
end
|
94
|
-
running do
|
95
|
-
@session.find(:monkey, '14').text.should == 'Monkey Paul'
|
96
|
-
end.should raise_error(Capybara::ElementNotFound, "Monkey John, Monkey Paul")
|
97
76
|
end
|
98
77
|
|
99
|
-
it "should
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
78
|
+
it "should find elements that match the filter" do
|
79
|
+
@session.find(:monkey, '1', :name => 'Monkey John').text.should == 'Monkey John'
|
80
|
+
@session.find(:monkey, '2', :name => 'Monkey Paul').text.should == 'Monkey Paul'
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should not find elements that don't match the filter" do
|
84
|
+
expect { @session.find(:monkey, '2', :name => 'Monkey John') }.to raise_error(Capybara::ElementNotFound)
|
85
|
+
expect { @session.find(:monkey, '1', :name => 'Monkey Paul') }.to raise_error(Capybara::ElementNotFound)
|
107
86
|
end
|
108
87
|
end
|
109
88
|
|
@@ -116,22 +95,16 @@ shared_examples_for "find" do
|
|
116
95
|
after { Capybara.default_selector = :xpath }
|
117
96
|
end
|
118
97
|
|
119
|
-
it "should raise ElementNotFound with specified fail message if nothing was found" do
|
120
|
-
running do
|
121
|
-
@session.find(:xpath, '//div[@id="nosuchthing"]', :message => 'arghh').should be_nil
|
122
|
-
end.should raise_error(Capybara::ElementNotFound, "arghh")
|
123
|
-
end
|
124
|
-
|
125
98
|
it "should raise ElementNotFound with a useful default message if nothing was found" do
|
126
99
|
running do
|
127
100
|
@session.find(:xpath, '//div[@id="nosuchthing"]').should be_nil
|
128
101
|
end.should raise_error(Capybara::ElementNotFound, "Unable to find xpath \"//div[@id=\\\"nosuchthing\\\"]\"")
|
129
102
|
end
|
130
103
|
|
131
|
-
it "should accept an XPath instance
|
104
|
+
it "should accept an XPath instance" do
|
132
105
|
@session.visit('/form')
|
133
|
-
@xpath = XPath::HTML.fillable_field('Name')
|
134
|
-
@session.find(@xpath).value.should == 'John
|
106
|
+
@xpath = XPath::HTML.fillable_field('First Name')
|
107
|
+
@session.find(@xpath).value.should == 'John'
|
135
108
|
end
|
136
109
|
|
137
110
|
context "within a scope" do
|
@@ -139,9 +112,9 @@ shared_examples_for "find" do
|
|
139
112
|
@session.visit('/with_scope')
|
140
113
|
end
|
141
114
|
|
142
|
-
it "should find the
|
115
|
+
it "should find the an element using the given locator" do
|
143
116
|
@session.within(:xpath, "//div[@id='for_bar']") do
|
144
|
-
@session.find('.//li').text.should =~ /With Simple HTML/
|
117
|
+
@session.find('.//li[1]').text.should =~ /With Simple HTML/
|
145
118
|
end
|
146
119
|
end
|
147
120
|
end
|
@@ -15,8 +15,8 @@ shared_examples_for "first" do
|
|
15
15
|
|
16
16
|
it "should accept an XPath instance" do
|
17
17
|
@session.visit('/form')
|
18
|
-
@xpath = XPath::HTML.fillable_field('Name')
|
19
|
-
@session.first(@xpath).value.should == 'John
|
18
|
+
@xpath = XPath::HTML.fillable_field('First Name')
|
19
|
+
@session.first(@xpath).value.should == 'John'
|
20
20
|
end
|
21
21
|
|
22
22
|
context "with css selectors" do
|
@@ -58,38 +58,6 @@ shared_examples_for "first" do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context "with prefer visible elements" do
|
62
|
-
it "should find invisible elements if no visible element exists" do
|
63
|
-
@session.first(:css, 'a#invisible')[:id].should == 'invisible'
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should prefer visible elements over invisible elements" do
|
67
|
-
@session.first(:css, 'a.visibility')[:id].should == 'visible'
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should return the first invisible element if no visible elements exist" do
|
71
|
-
@session.first(:css, 'a.hidden')[:id].should == 'first_invisble'
|
72
|
-
end
|
73
|
-
|
74
|
-
it "find visible links normally" do
|
75
|
-
@session.first(:css, 'a#visible')[:id].should == 'visible'
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "without prefer visible elements" do
|
80
|
-
before { Capybara.prefer_visible_elements = false }
|
81
|
-
|
82
|
-
it "should find invisible elements if no visible element exists" do
|
83
|
-
@session.first(:css, 'a#invisible')[:id].should == 'invisible'
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should not prefer visible elements over invisible elements" do
|
87
|
-
@session.first(:css, 'a.visibility')[:id].should == 'invisible'
|
88
|
-
end
|
89
|
-
|
90
|
-
after { Capybara.prefer_visible_elements = true }
|
91
|
-
end
|
92
|
-
|
93
61
|
context "within a scope" do
|
94
62
|
before do
|
95
63
|
@session.visit('/with_scope')
|
@@ -36,6 +36,20 @@ shared_examples_for "has_field" do
|
|
36
36
|
@session.should_not have_field('First Name', :with => 'John')
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
context 'with type' do
|
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
|
+
end
|
46
|
+
|
47
|
+
it "should be false if the given field is not on the page" do
|
48
|
+
@session.should_not have_field('First Name', :type => 'email')
|
49
|
+
@session.should_not have_field('Html5 Email', :type => 'tel')
|
50
|
+
@session.should_not have_field('Description', :type => '')
|
51
|
+
end
|
52
|
+
end
|
39
53
|
end
|
40
54
|
|
41
55
|
describe '#has_no_field' do
|
@@ -75,6 +89,20 @@ shared_examples_for "has_field" do
|
|
75
89
|
@session.should have_no_field('First Name', :with => 'John')
|
76
90
|
end
|
77
91
|
end
|
92
|
+
|
93
|
+
context 'with type' do
|
94
|
+
it "should be false if a field with the given type is on the page" do
|
95
|
+
@session.should_not have_no_field('First Name', :type => 'text')
|
96
|
+
@session.should_not have_no_field('Html5 Email', :type => 'email')
|
97
|
+
@session.should_not have_no_field('Html5 Tel', :type => 'tel')
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should be true if the given field is not on the page" do
|
101
|
+
@session.should have_no_field('First Name', :type => 'email')
|
102
|
+
@session.should have_no_field('Html5 Email', :type => 'tel')
|
103
|
+
@session.should have_no_field('Description', :type => '')
|
104
|
+
end
|
105
|
+
end
|
78
106
|
end
|
79
107
|
|
80
108
|
describe '#has_checked_field?' do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_examples_for "has_select" do
|
1
|
+
shared_examples_for "has_select" do
|
2
2
|
describe '#has_select?' do
|
3
3
|
before { @session.visit('/form') }
|
4
4
|
|
@@ -14,17 +14,26 @@ shared_examples_for "has_select" do
|
|
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
|
+
@session.should have_select('form_locale', :selected => 'English')
|
18
|
+
@session.should have_select('Region', :selected => 'Norway')
|
19
|
+
@session.should have_select('Underwear', :selected => [
|
20
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
21
|
+
])
|
20
22
|
end
|
21
23
|
|
22
24
|
it "should be false if the given field is not on the page" do
|
23
|
-
@session.should_not have_select('Locale', :selected => 'Swedish')
|
24
|
-
@session.should_not have_select('Does not exist', :selected => 'John')
|
25
|
+
@session.should_not have_select('Locale', :selected => 'Swedish')
|
26
|
+
@session.should_not have_select('Does not exist', :selected => 'John')
|
25
27
|
@session.should_not have_select('City', :selected => 'Not there')
|
26
|
-
@session.should_not have_select('Underwear', :selected => [
|
27
|
-
|
28
|
+
@session.should_not have_select('Underwear', :selected => [
|
29
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
30
|
+
])
|
31
|
+
@session.should_not have_select('Underwear', :selected => [
|
32
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
33
|
+
])
|
34
|
+
@session.should_not have_select('Underwear', :selected => [
|
35
|
+
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
36
|
+
])
|
28
37
|
end
|
29
38
|
|
30
39
|
it "should be true after the given value is selected" do
|
@@ -39,25 +48,44 @@ shared_examples_for "has_select" do
|
|
39
48
|
|
40
49
|
it "should be true after the given values are selected" do
|
41
50
|
@session.select('Boxers', :from => 'Underwear')
|
42
|
-
@session.should have_select('Underwear', :selected => [
|
51
|
+
@session.should have_select('Underwear', :selected => [
|
52
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
53
|
+
])
|
43
54
|
end
|
44
55
|
|
45
56
|
it "should be false after one of the values is unselected" do
|
46
57
|
@session.unselect('Briefs', :from => 'Underwear')
|
47
|
-
@session.should_not have_select('Underwear', :selected => [
|
58
|
+
@session.should_not have_select('Underwear', :selected => [
|
59
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
60
|
+
])
|
48
61
|
end
|
49
62
|
end
|
50
63
|
|
51
|
-
context 'with options' do
|
64
|
+
context 'with exact options' do
|
52
65
|
it "should be true if a field with the given options is on the page" do
|
53
|
-
@session.should have_select('
|
54
|
-
@session.should have_select('
|
66
|
+
@session.should have_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
67
|
+
@session.should have_select('Tendency', :options => [])
|
55
68
|
end
|
56
69
|
|
57
70
|
it "should be false if the given field is not on the page" do
|
58
|
-
@session.should_not have_select('Locale', :options => ['
|
59
|
-
@session.should_not have_select('Does not exist', :options => ['John'])
|
71
|
+
@session.should_not have_select('Locale', :options => ['Swedish'])
|
72
|
+
@session.should_not have_select('Does not exist', :options => ['John'])
|
60
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'])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'with partial options' do
|
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'])
|
83
|
+
end
|
84
|
+
|
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'])
|
61
89
|
end
|
62
90
|
end
|
63
91
|
end
|
@@ -77,17 +105,26 @@ shared_examples_for "has_select" do
|
|
77
105
|
|
78
106
|
context 'with selected value' do
|
79
107
|
it "should be false if a field with the given value is on the page" do
|
80
|
-
@session.should_not have_no_select('form_locale', :selected => 'English')
|
81
|
-
@session.should_not have_no_select('Region', :selected => 'Norway')
|
82
|
-
@session.should_not have_no_select('Underwear', :selected => [
|
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 => [
|
111
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
112
|
+
])
|
83
113
|
end
|
84
114
|
|
85
115
|
it "should be true if the given field is not on the page" do
|
86
|
-
@session.should have_no_select('Locale', :selected => 'Swedish')
|
87
|
-
@session.should have_no_select('Does not exist', :selected => 'John')
|
116
|
+
@session.should have_no_select('Locale', :selected => 'Swedish')
|
117
|
+
@session.should have_no_select('Does not exist', :selected => 'John')
|
88
118
|
@session.should have_no_select('City', :selected => 'Not there')
|
89
|
-
@session.should have_no_select('Underwear', :selected => [
|
90
|
-
|
119
|
+
@session.should have_no_select('Underwear', :selected => [
|
120
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
121
|
+
])
|
122
|
+
@session.should have_no_select('Underwear', :selected => [
|
123
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
124
|
+
])
|
125
|
+
@session.should have_no_select('Underwear', :selected => [
|
126
|
+
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
127
|
+
])
|
91
128
|
end
|
92
129
|
|
93
130
|
it "should be false after the given value is selected" do
|
@@ -102,28 +139,44 @@ shared_examples_for "has_select" do
|
|
102
139
|
|
103
140
|
it "should be false after the given values are selected" do
|
104
141
|
@session.select('Boxers', :from => 'Underwear')
|
105
|
-
@session.should_not have_no_select('Underwear', :selected => [
|
142
|
+
@session.should_not have_no_select('Underwear', :selected => [
|
143
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
144
|
+
])
|
106
145
|
end
|
107
146
|
|
108
147
|
it "should be true after one of the values is unselected" do
|
109
148
|
@session.unselect('Briefs', :from => 'Underwear')
|
110
|
-
@session.should have_no_select('Underwear', :selected => [
|
149
|
+
@session.should have_no_select('Underwear', :selected => [
|
150
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
151
|
+
])
|
111
152
|
end
|
112
153
|
end
|
113
154
|
|
114
|
-
context 'with options' do
|
155
|
+
context 'with exact options' do
|
115
156
|
it "should be false if a field with the given options is on the page" do
|
116
|
-
@session.should_not have_no_select('
|
117
|
-
@session.should_not have_no_select('Region', :options => ['Norway', 'Sweden'])
|
157
|
+
@session.should_not have_no_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
118
158
|
end
|
119
159
|
|
120
160
|
it "should be true if the given field is not on the page" do
|
121
|
-
@session.should have_no_select('Locale', :options => ['
|
122
|
-
@session.should have_no_select('Does not exist', :options => ['John'])
|
161
|
+
@session.should have_no_select('Locale', :options => ['Swedish'])
|
162
|
+
@session.should have_no_select('Does not exist', :options => ['John'])
|
123
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'])
|
124
166
|
end
|
125
167
|
end
|
126
|
-
end
|
127
|
-
end
|
128
168
|
|
169
|
+
context 'with partial options' do
|
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'])
|
173
|
+
end
|
129
174
|
|
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'])
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -1,48 +1,17 @@
|
|
1
|
-
shared_examples_for "has_table" do
|
1
|
+
shared_examples_for "has_table" do
|
2
2
|
describe '#has_table?' do
|
3
3
|
before do
|
4
4
|
@session.visit('/tables')
|
5
5
|
end
|
6
6
|
|
7
|
-
it "should be true if the
|
8
|
-
@session.should have_table('
|
7
|
+
it "should be true if the table is on the page" do
|
8
|
+
@session.should have_table('Villain')
|
9
9
|
@session.should have_table('villain_table')
|
10
10
|
end
|
11
11
|
|
12
|
-
it "should be false if the
|
12
|
+
it "should be false if the table is not on the page" do
|
13
13
|
@session.should_not have_table('Monkey')
|
14
14
|
end
|
15
|
-
|
16
|
-
context 'with rows' do
|
17
|
-
it "should be true if a table with the given rows is on the page" do
|
18
|
-
@session.should have_table('Ransom', :rows => [['2007', '$300', '$100']])
|
19
|
-
@session.should have_table('Deaths', :rows => [['2007', '66', '7'], ['2008', '123', '12']])
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should be true if the given rows are incomplete" do
|
23
|
-
@session.should have_table('Ransom', :rows => [['$300', '$100']])
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should be false if the given table is not on the page" do
|
27
|
-
@session.should_not have_table('Does not exist', :selected => 'John')
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be false if the given rows contain incorrect elements" do
|
31
|
-
@session.should_not have_table('Ransom', :rows => [['2007', '$1000000000', '$100']])
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should be false if the given rows are incorrectly ordered" do
|
35
|
-
@session.should_not have_table('Ransom', :rows => [['2007', '$100', '$300']])
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should be false if the only some of the given rows are correct" do
|
39
|
-
@session.should_not have_table('Deaths', :rows => [['2007', '66', '7'], ['2007', '99999999', '12']])
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should be false if the given rows are out of order" do
|
43
|
-
@session.should_not have_table('Deaths', :rows => [['2007', '123', '12'], ['2007', '66', '7']])
|
44
|
-
end
|
45
|
-
end
|
46
15
|
end
|
47
16
|
|
48
17
|
describe '#has_no_table?' do
|
@@ -50,45 +19,14 @@ shared_examples_for "has_table" do
|
|
50
19
|
@session.visit('/tables')
|
51
20
|
end
|
52
21
|
|
53
|
-
it "should be false if the
|
54
|
-
@session.should_not have_no_table('
|
22
|
+
it "should be false if the table is on the page" do
|
23
|
+
@session.should_not have_no_table('Villain')
|
55
24
|
@session.should_not have_no_table('villain_table')
|
56
25
|
end
|
57
26
|
|
58
|
-
it "should be true if the
|
27
|
+
it "should be true if the table is not on the page" do
|
59
28
|
@session.should have_no_table('Monkey')
|
60
29
|
end
|
61
|
-
|
62
|
-
context 'with rows' do
|
63
|
-
it "should be false if a table with the given rows is on the page" do
|
64
|
-
@session.should_not have_no_table('Ransom', :rows => [['2007', '$300', '$100']])
|
65
|
-
@session.should_not have_no_table('Deaths', :rows => [['2007', '66', '7'], ['2008', '123', '12']])
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should be false if the given rows are incomplete" do
|
69
|
-
@session.should_not have_no_table('Ransom', :rows => [['$300', '$100']])
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should be true if the given table is not on the page" do
|
73
|
-
@session.should have_no_table('Does not exist', :selected => 'John')
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should be true if the given rows contain incorrect elements" do
|
77
|
-
@session.should have_no_table('Ransom', :rows => [['2007', '$1000000000', '$100']])
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should be true if the given rows are incorrectly ordered" do
|
81
|
-
@session.should have_no_table('Ransom', :rows => [['2007', '$100', '$300']])
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should be true if the only some of the given rows are correct" do
|
85
|
-
@session.should have_no_table('Deaths', :rows => [['2007', '66', '7'], ['2007', '99999999', '12']])
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should be true if the given rows are out of order" do
|
89
|
-
@session.should have_no_table('Deaths', :rows => [['2007', '123', '12'], ['2007', '66', '7']])
|
90
|
-
end
|
91
|
-
end
|
92
30
|
end
|
93
31
|
end
|
94
32
|
|