yannp-capybara 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +112 -0
- data/README.rdoc +442 -0
- data/lib/capybara/cucumber.rb +32 -0
- data/lib/capybara/driver/base.rb +56 -0
- data/lib/capybara/driver/celerity_driver.rb +154 -0
- data/lib/capybara/driver/culerity_driver.rb +26 -0
- data/lib/capybara/driver/node.rb +66 -0
- data/lib/capybara/driver/rack_test_driver.rb +279 -0
- data/lib/capybara/driver/selenium_driver.rb +157 -0
- data/lib/capybara/dsl.rb +98 -0
- data/lib/capybara/node/actions.rb +156 -0
- data/lib/capybara/node/finders.rb +155 -0
- data/lib/capybara/node/matchers.rb +97 -0
- data/lib/capybara/node.rb +209 -0
- data/lib/capybara/rails.rb +17 -0
- data/lib/capybara/server.rb +101 -0
- data/lib/capybara/session.rb +278 -0
- data/lib/capybara/spec/driver.rb +190 -0
- data/lib/capybara/spec/fixtures/capybara.jpg +0 -0
- data/lib/capybara/spec/fixtures/test_file.txt +1 -0
- data/lib/capybara/spec/public/jquery-ui.js +35 -0
- data/lib/capybara/spec/public/jquery.js +19 -0
- data/lib/capybara/spec/public/test.js +33 -0
- data/lib/capybara/spec/session/all_spec.rb +73 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +64 -0
- data/lib/capybara/spec/session/check_spec.rb +67 -0
- data/lib/capybara/spec/session/choose_spec.rb +26 -0
- data/lib/capybara/spec/session/click_button_spec.rb +243 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +30 -0
- data/lib/capybara/spec/session/click_link_spec.rb +108 -0
- data/lib/capybara/spec/session/current_url_spec.rb +15 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +119 -0
- data/lib/capybara/spec/session/find_button_spec.rb +18 -0
- data/lib/capybara/spec/session/find_by_id_spec.rb +18 -0
- data/lib/capybara/spec/session/find_field_spec.rb +26 -0
- data/lib/capybara/spec/session/find_link_spec.rb +19 -0
- data/lib/capybara/spec/session/find_spec.rb +91 -0
- data/lib/capybara/spec/session/has_button_spec.rb +32 -0
- data/lib/capybara/spec/session/has_content_spec.rb +106 -0
- data/lib/capybara/spec/session/has_css_spec.rb +107 -0
- data/lib/capybara/spec/session/has_field_spec.rb +96 -0
- data/lib/capybara/spec/session/has_link_spec.rb +33 -0
- data/lib/capybara/spec/session/has_select_spec.rb +89 -0
- data/lib/capybara/spec/session/has_table_spec.rb +96 -0
- data/lib/capybara/spec/session/has_xpath_spec.rb +123 -0
- data/lib/capybara/spec/session/headers.rb +19 -0
- data/lib/capybara/spec/session/javascript.rb +232 -0
- data/lib/capybara/spec/session/response_code.rb +19 -0
- data/lib/capybara/spec/session/select_spec.rb +91 -0
- data/lib/capybara/spec/session/uncheck_spec.rb +21 -0
- data/lib/capybara/spec/session/unselect_spec.rb +54 -0
- data/lib/capybara/spec/session/within_spec.rb +153 -0
- data/lib/capybara/spec/session.rb +78 -0
- data/lib/capybara/spec/test_app.rb +94 -0
- data/lib/capybara/spec/views/buttons.erb +4 -0
- data/lib/capybara/spec/views/fieldsets.erb +29 -0
- data/lib/capybara/spec/views/form.erb +245 -0
- data/lib/capybara/spec/views/frame_one.erb +8 -0
- data/lib/capybara/spec/views/frame_two.erb +8 -0
- data/lib/capybara/spec/views/postback.erb +13 -0
- data/lib/capybara/spec/views/tables.erb +122 -0
- data/lib/capybara/spec/views/with_html.erb +43 -0
- data/lib/capybara/spec/views/with_js.erb +39 -0
- data/lib/capybara/spec/views/with_scope.erb +36 -0
- data/lib/capybara/spec/views/with_simple_html.erb +1 -0
- data/lib/capybara/spec/views/within_frames.erb +10 -0
- data/lib/capybara/util/save_and_open_page.rb +36 -0
- data/lib/capybara/util/timeout.rb +27 -0
- data/lib/capybara/version.rb +3 -0
- data/lib/capybara/xpath.rb +182 -0
- data/lib/capybara.rb +73 -0
- data/spec/capybara_spec.rb +18 -0
- data/spec/driver/celerity_driver_spec.rb +17 -0
- data/spec/driver/culerity_driver_spec.rb +13 -0
- data/spec/driver/rack_test_driver_spec.rb +19 -0
- data/spec/driver/remote_culerity_driver_spec.rb +24 -0
- data/spec/driver/remote_selenium_driver_spec.rb +19 -0
- data/spec/driver/selenium_driver_spec.rb +13 -0
- data/spec/dsl_spec.rb +140 -0
- data/spec/save_and_open_page_spec.rb +83 -0
- data/spec/server_spec.rb +53 -0
- data/spec/session/celerity_session_spec.rb +28 -0
- data/spec/session/culerity_session_spec.rb +26 -0
- data/spec/session/rack_test_session_spec.rb +34 -0
- data/spec/session/selenium_session_spec.rb +26 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/timeout_spec.rb +28 -0
- data/spec/xpath_spec.rb +173 -0
- metadata +314 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
shared_examples_for "find" do
|
2
|
+
describe '#find' do
|
3
|
+
before do
|
4
|
+
@session.visit('/with_html')
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should find the first element using the given locator" do
|
8
|
+
@session.find('//h1').text.should == 'This is a test'
|
9
|
+
@session.find("//input[@id='test_field']")[:value].should == 'monkey'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be aliased as locate for backward compatibility" do
|
13
|
+
@session.locate('//h1').text.should == 'This is a test'
|
14
|
+
@session.locate("//input[@id='test_field']")[:value].should == 'monkey'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should find the first element using the given locator and options" do
|
18
|
+
@session.find('//a', :text => 'Redirect')[:id].should == 'red'
|
19
|
+
@session.find(:css, 'a', :text => 'A link')[:title].should == 'twas a fine link'
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'the returned node' do
|
23
|
+
it "should act like a session object" do
|
24
|
+
@session.visit('/form')
|
25
|
+
@form = @session.find(:css, '#get-form')
|
26
|
+
@form.should have_field('Middle Name')
|
27
|
+
@form.should have_no_field('Languages')
|
28
|
+
@form.fill_in('Middle Name', :with => 'Monkey')
|
29
|
+
@form.click_button('med')
|
30
|
+
extract_results(@session)['middle_name'].should == 'Monkey'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should scope CSS selectors" do
|
34
|
+
@session.find(:css, '#second').should have_no_css('h1')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with css selectors" do
|
39
|
+
it "should find the first element using the given locator" do
|
40
|
+
@session.find(:css, 'h1').text.should == 'This is a test'
|
41
|
+
@session.find(:css, "input[id='test_field']")[:value].should == 'monkey'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with xpath selectors" do
|
46
|
+
it "should find the first element using the given locator" do
|
47
|
+
@session.find(:xpath, '//h1').text.should == 'This is a test'
|
48
|
+
@session.find(:xpath, "//input[@id='test_field']")[:value].should == 'monkey'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "with css as default selector" do
|
53
|
+
before { Capybara.default_selector = :css }
|
54
|
+
it "should find the first element using the given locator" do
|
55
|
+
@session.find('h1').text.should == 'This is a test'
|
56
|
+
@session.find("input[id='test_field']")[:value].should == 'monkey'
|
57
|
+
end
|
58
|
+
after { Capybara.default_selector = :xpath }
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should raise ElementNotFound with specified fail message if nothing was found" do
|
62
|
+
running do
|
63
|
+
@session.find(:xpath, '//div[@id="nosuchthing"]', :message => 'arghh').should be_nil
|
64
|
+
end.should raise_error(Capybara::ElementNotFound, "arghh")
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should raise ElementNotFound with a useful default message if nothing was found" do
|
68
|
+
running do
|
69
|
+
@session.find(:xpath, '//div[@id="nosuchthing"]').should be_nil
|
70
|
+
end.should raise_error(Capybara::ElementNotFound, "Unable to find '//div[@id=\"nosuchthing\"]'")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should accept an XPath instance and respect the order of paths" do
|
74
|
+
@session.visit('/form')
|
75
|
+
@xpath = Capybara::XPath.text_field('Name')
|
76
|
+
@session.find(@xpath).value.should == 'John Smith'
|
77
|
+
end
|
78
|
+
|
79
|
+
context "within a scope" do
|
80
|
+
before do
|
81
|
+
@session.visit('/with_scope')
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should find the first element using the given locator" do
|
85
|
+
@session.within(:xpath, "//div[@id='for_bar']") do
|
86
|
+
@session.find('.//li').text.should =~ /With Simple HTML/
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
shared_examples_for "has_button" do
|
2
|
+
describe '#has_button?' do
|
3
|
+
before do
|
4
|
+
@session.visit('/form')
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should be true if the given button is on the page" do
|
8
|
+
@session.should have_button('med')
|
9
|
+
@session.should have_button('crap321')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be false if the given button is not on the page" do
|
13
|
+
@session.should_not have_button('monkey')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#has_no_button?' do
|
18
|
+
before do
|
19
|
+
@session.visit('/form')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be true if the given button is on the page" do
|
23
|
+
@session.should_not have_no_button('med')
|
24
|
+
@session.should_not have_no_button('crap321')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be false if the given button is not on the page" do
|
28
|
+
@session.should have_no_button('monkey')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,106 @@
|
|
1
|
+
shared_examples_for "has_content" do
|
2
|
+
describe '#has_content?' do
|
3
|
+
it "should be true if the given content is on the page at least once" do
|
4
|
+
@session.visit('/with_html')
|
5
|
+
@session.should have_content('est')
|
6
|
+
@session.should have_content('Lorem')
|
7
|
+
@session.should have_content('Redirect')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be true if scoped to an element which has the content" do
|
11
|
+
@session.visit('/with_html')
|
12
|
+
@session.within("//a[@title='awesome title']") do
|
13
|
+
@session.should have_content('labore')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be false if scoped to an element which does not have the content" do
|
18
|
+
@session.visit('/with_html')
|
19
|
+
@session.within("//a[@title='awesome title']") do
|
20
|
+
@session.should_not have_content('monkey')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should ignore tags" do
|
25
|
+
@session.visit('/with_html')
|
26
|
+
@session.should_not have_content('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
|
27
|
+
@session.should have_content('exercitation ullamco laboris')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should ignore extra whitespace and newlines" do
|
31
|
+
@session.visit('/with_html')
|
32
|
+
@session.should have_content('text with whitespace')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be false if the given content is not on the page" do
|
36
|
+
@session.visit('/with_html')
|
37
|
+
@session.should_not have_content('xxxxyzzz')
|
38
|
+
@session.should_not have_content('monkey')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should handle single quotes in the content' do
|
42
|
+
@session.visit('/with-quotes')
|
43
|
+
@session.should have_content("can't")
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should handle double quotes in the content' do
|
47
|
+
@session.visit('/with-quotes')
|
48
|
+
@session.should have_content(%q{"No," he said})
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should handle mixed single and double quotes in the content' do
|
52
|
+
@session.visit('/with-quotes')
|
53
|
+
@session.should have_content(%q{"you can't do that."})
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#has_no_content?' do
|
58
|
+
it "should be false if the given content is on the page at least once" do
|
59
|
+
@session.visit('/with_html')
|
60
|
+
@session.should_not have_no_content('est')
|
61
|
+
@session.should_not have_no_content('Lorem')
|
62
|
+
@session.should_not have_no_content('Redirect')
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be false if scoped to an element which has the content" do
|
66
|
+
@session.visit('/with_html')
|
67
|
+
@session.within("//a[@title='awesome title']") do
|
68
|
+
@session.should_not have_no_content('labore')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should be true if scoped to an element which does not have the content" do
|
73
|
+
@session.visit('/with_html')
|
74
|
+
@session.within("//a[@title='awesome title']") do
|
75
|
+
@session.should have_no_content('monkey')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should ignore tags" do
|
80
|
+
@session.visit('/with_html')
|
81
|
+
@session.should have_no_content('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
|
82
|
+
@session.should_not have_no_content('exercitation ullamco laboris')
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should be true if the given content is not on the page" do
|
86
|
+
@session.visit('/with_html')
|
87
|
+
@session.should have_no_content('xxxxyzzz')
|
88
|
+
@session.should have_no_content('monkey')
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should handle single quotes in the content' do
|
92
|
+
@session.visit('/with-quotes')
|
93
|
+
@session.should_not have_no_content("can't")
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should handle double quotes in the content' do
|
97
|
+
@session.visit('/with-quotes')
|
98
|
+
@session.should_not have_no_content(%q{"No," he said})
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should handle mixed single and double quotes in the content' do
|
102
|
+
@session.visit('/with-quotes')
|
103
|
+
@session.should_not have_no_content(%q{"you can't do that."})
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
shared_examples_for "has_css" do
|
2
|
+
describe '#has_css?' do
|
3
|
+
before do
|
4
|
+
@session.visit('/with_html')
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should be true if the given selector is on the page" do
|
8
|
+
@session.should have_css("p")
|
9
|
+
@session.should have_css("p a#foo")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be false if the given selector is not on the page" do
|
13
|
+
@session.should_not have_css("abbr")
|
14
|
+
@session.should_not have_css("p a#doesnotexist")
|
15
|
+
@session.should_not have_css("p.nosuchclass")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should respect scopes" do
|
19
|
+
@session.within "//p[@id='first']" do
|
20
|
+
@session.should have_css("a#foo")
|
21
|
+
@session.should_not have_css("a#red")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with count" do
|
26
|
+
it "should be true if the content is on the page the given number of times" do
|
27
|
+
@session.should have_css("p", :count => 3)
|
28
|
+
@session.should have_css("p a#foo", :count => 1)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be false if the content is on the page the given number of times" do
|
32
|
+
@session.should_not have_css("p", :count => 6)
|
33
|
+
@session.should_not have_css("p a#foo", :count => 2)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be false if the content isn't on the page at all" do
|
37
|
+
@session.should_not have_css("abbr", :count => 2)
|
38
|
+
@session.should_not have_css("p a.doesnotexist", :count => 1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "with text" do
|
43
|
+
it "should discard all matches where the given string is not contained" do
|
44
|
+
@session.should have_css("p a", :text => "Redirect", :count => 1)
|
45
|
+
@session.should_not have_css("p a", :text => "Doesnotexist")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should discard all matches where the given regexp is not matched" do
|
49
|
+
@session.should have_css("p a", :text => /re[dab]i/i, :count => 1)
|
50
|
+
@session.should_not have_css("p a", :text => /Red$/)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#has_no_css?' do
|
56
|
+
before do
|
57
|
+
@session.visit('/with_html')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should be false if the given selector is on the page" do
|
61
|
+
@session.should_not have_no_css("p")
|
62
|
+
@session.should_not have_no_css("p a#foo")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be true if the given selector is not on the page" do
|
66
|
+
@session.should have_no_css("abbr")
|
67
|
+
@session.should have_no_css("p a#doesnotexist")
|
68
|
+
@session.should have_no_css("p.nosuchclass")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should respect scopes" do
|
72
|
+
@session.within "//p[@id='first']" do
|
73
|
+
@session.should_not have_no_css("a#foo")
|
74
|
+
@session.should have_no_css("a#red")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with count" do
|
79
|
+
it "should be false if the content is on the page the given number of times" do
|
80
|
+
@session.should_not have_no_css("p", :count => 3)
|
81
|
+
@session.should_not have_no_css("p a#foo", :count => 1)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should be true if the content is on the page the given number of times" do
|
85
|
+
@session.should have_no_css("p", :count => 6)
|
86
|
+
@session.should have_no_css("p a#foo", :count => 2)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should be true if the content isn't on the page at all" do
|
90
|
+
@session.should have_no_css("abbr", :count => 2)
|
91
|
+
@session.should have_no_css("p a.doesnotexist", :count => 1)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "with text" do
|
96
|
+
it "should discard all matches where the given string is not contained" do
|
97
|
+
@session.should_not have_no_css("p a", :text => "Redirect", :count => 1)
|
98
|
+
@session.should have_no_css("p a", :text => "Doesnotexist")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should discard all matches where the given regexp is not matched" do
|
102
|
+
@session.should_not have_no_css("p a", :text => /re[dab]i/i, :count => 1)
|
103
|
+
@session.should have_no_css("p a", :text => /Red$/)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
shared_examples_for "has_field" do
|
2
|
+
describe '#has_field' do
|
3
|
+
before { @session.visit('/form') }
|
4
|
+
|
5
|
+
it "should be true if the field is on the page" do
|
6
|
+
@session.should have_field('Dog')
|
7
|
+
@session.should have_field('form_description')
|
8
|
+
@session.should have_field('Region')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be false if the field is not on the page" do
|
12
|
+
@session.should_not have_field('Monkey')
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with value' do
|
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')
|
21
|
+
end
|
22
|
+
|
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')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#has_no_field' do
|
32
|
+
before { @session.visit('/form') }
|
33
|
+
|
34
|
+
it "should be false if the field is on the page" do
|
35
|
+
@session.should_not have_no_field('Dog')
|
36
|
+
@session.should_not have_no_field('form_description')
|
37
|
+
@session.should_not have_no_field('Region')
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be true if the field is not on the page" do
|
41
|
+
@session.should have_no_field('Monkey')
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with value' do
|
45
|
+
it "should be flase if a field with the given value is on the page" do
|
46
|
+
@session.should_not have_no_field('First Name', :with => 'John')
|
47
|
+
@session.should_not have_no_field('Phone', :with => '+1 555 7021')
|
48
|
+
@session.should_not have_no_field('Street', :with => 'Sesame street 66')
|
49
|
+
@session.should_not have_no_field('Description', :with => 'Descriptive text goes here')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be true if the given field is not on the page" do
|
53
|
+
@session.should have_no_field('First Name', :with => 'Peter')
|
54
|
+
@session.should have_no_field('Wrong Name', :with => 'John')
|
55
|
+
@session.should have_no_field('Description', :with => 'Monkey')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#has_checked_field?' do
|
61
|
+
before { @session.visit('/form') }
|
62
|
+
|
63
|
+
it "should be true if a checked field is on the page" do
|
64
|
+
@session.should have_checked_field('gender_female')
|
65
|
+
@session.should have_checked_field('Hamster')
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should be false if an unchecked field is on the page" do
|
69
|
+
@session.should_not have_checked_field('form_pets_cat')
|
70
|
+
@session.should_not have_checked_field('Male')
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should be false if no field is on the page" do
|
74
|
+
@session.should_not have_checked_field('Does Not Exist')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#has_unchecked_field?' do
|
79
|
+
before { @session.visit('/form') }
|
80
|
+
|
81
|
+
it "should be false if a checked field is on the page" do
|
82
|
+
@session.should_not have_unchecked_field('gender_female')
|
83
|
+
@session.should_not have_unchecked_field('Hamster')
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should be true if an unchecked field is on the page" do
|
87
|
+
@session.should have_unchecked_field('form_pets_cat')
|
88
|
+
@session.should have_unchecked_field('Male')
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should be false if no field is on the page" do
|
92
|
+
@session.should_not have_unchecked_field('Does Not Exist')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
shared_examples_for "has_link" do
|
2
|
+
|
3
|
+
describe '#has_link?' do
|
4
|
+
before do
|
5
|
+
@session.visit('/with_html')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be true if the given link is on the page" do
|
9
|
+
@session.should have_link('foo')
|
10
|
+
@session.should have_link('awesome title')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be false if the given link is not on the page" do
|
14
|
+
@session.should_not have_link('monkey')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#has_no_link?' do
|
19
|
+
before do
|
20
|
+
@session.visit('/with_html')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be false if the given link is on the page" do
|
24
|
+
@session.should_not have_no_link('foo')
|
25
|
+
@session.should_not have_no_link('awesome title')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be true if the given link is not on the page" do
|
29
|
+
@session.should have_no_link('monkey')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
shared_examples_for "has_select" do
|
2
|
+
describe '#has_select?' do
|
3
|
+
before { @session.visit('/form') }
|
4
|
+
|
5
|
+
it "should be true if the field is on the page" do
|
6
|
+
@session.should have_select('Locale')
|
7
|
+
@session.should have_select('form_region')
|
8
|
+
@session.should have_select('Languages')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be false if the field is not on the page" do
|
12
|
+
@session.should_not have_select('Monkey')
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with selected value' do
|
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 => ['Briefs', 'Commando'])
|
20
|
+
end
|
21
|
+
|
22
|
+
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('City', :selected => 'Not there')
|
26
|
+
@session.should_not have_select('Underwear', :selected => ['Briefs', 'Nonexistant'])
|
27
|
+
@session.should_not have_select('Underwear', :selected => ['Briefs', 'Boxers'])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with options' do
|
32
|
+
it "should be true if a field with the given options is on the page" do
|
33
|
+
@session.should have_select('form_locale', :options => ['English'])
|
34
|
+
@session.should have_select('Region', :options => ['Norway', 'Sweden'])
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should be false if the given field is not on the page" do
|
38
|
+
@session.should_not have_select('Locale', :options => ['Not there'])
|
39
|
+
@session.should_not have_select('Does not exist', :options => ['John'])
|
40
|
+
@session.should_not have_select('City', :options => ['London', 'Made up city'])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#has_no_select?' do
|
46
|
+
before { @session.visit('/form') }
|
47
|
+
|
48
|
+
it "should be false if the field is on the page" do
|
49
|
+
@session.should_not have_no_select('Locale')
|
50
|
+
@session.should_not have_no_select('form_region')
|
51
|
+
@session.should_not have_no_select('Languages')
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be true if the field is not on the page" do
|
55
|
+
@session.should have_no_select('Monkey')
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with selected value' do
|
59
|
+
it "should be false if a field with the given value is on the page" do
|
60
|
+
@session.should_not have_no_select('form_locale', :selected => 'English')
|
61
|
+
@session.should_not have_no_select('Region', :selected => 'Norway')
|
62
|
+
@session.should_not have_no_select('Underwear', :selected => ['Briefs', 'Commando'])
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be true if the given field is not on the page" do
|
66
|
+
@session.should have_no_select('Locale', :selected => 'Swedish')
|
67
|
+
@session.should have_no_select('Does not exist', :selected => 'John')
|
68
|
+
@session.should have_no_select('City', :selected => 'Not there')
|
69
|
+
@session.should have_no_select('Underwear', :selected => ['Briefs', 'Nonexistant'])
|
70
|
+
@session.should have_no_select('Underwear', :selected => ['Briefs', 'Boxers'])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'with options' do
|
75
|
+
it "should be false if a field with the given options is on the page" do
|
76
|
+
@session.should_not have_no_select('form_locale', :options => ['English'])
|
77
|
+
@session.should_not have_no_select('Region', :options => ['Norway', 'Sweden'])
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should be true if the given field is not on the page" do
|
81
|
+
@session.should have_no_select('Locale', :options => ['Not there'])
|
82
|
+
@session.should have_no_select('Does not exist', :options => ['John'])
|
83
|
+
@session.should have_no_select('City', :options => ['London', 'Made up city'])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
shared_examples_for "has_table" do
|
2
|
+
describe '#has_table?' do
|
3
|
+
before do
|
4
|
+
@session.visit('/tables')
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should be true if the field is on the page" do
|
8
|
+
@session.should have_table('Deaths')
|
9
|
+
@session.should have_table('villain_table')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be false if the field is not on the page" do
|
13
|
+
@session.should_not have_table('Monkey')
|
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
|
+
end
|
47
|
+
|
48
|
+
describe '#has_no_table?' do
|
49
|
+
before do
|
50
|
+
@session.visit('/tables')
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be false if the field is on the page" do
|
54
|
+
@session.should_not have_no_table('Deaths')
|
55
|
+
@session.should_not have_no_table('villain_table')
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should be true if the field is not on the page" do
|
59
|
+
@session.should have_no_table('Monkey')
|
60
|
+
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
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|