capybara 2.0.0.beta2 → 2.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +30 -1
- data/README.md +52 -31
- data/lib/capybara.rb +1 -0
- data/lib/capybara/driver/base.rb +1 -1
- data/lib/capybara/driver/node.rb +1 -0
- data/lib/capybara/dsl.rb +12 -5
- data/lib/capybara/helpers.rb +33 -0
- data/lib/capybara/node/actions.rb +4 -2
- data/lib/capybara/node/base.rb +52 -1
- data/lib/capybara/node/element.rb +0 -12
- data/lib/capybara/node/finders.rb +1 -1
- data/lib/capybara/node/matchers.rb +57 -47
- data/lib/capybara/node/simple.rb +4 -0
- data/lib/capybara/query.rb +11 -11
- data/lib/capybara/rack_test/browser.rb +14 -15
- data/lib/capybara/rack_test/driver.rb +2 -2
- data/lib/capybara/rack_test/node.rb +15 -2
- data/lib/capybara/result.rb +7 -19
- data/lib/capybara/rspec.rb +7 -4
- data/lib/capybara/rspec/features.rb +4 -1
- data/lib/capybara/rspec/matchers.rb +8 -3
- data/lib/capybara/selector.rb +1 -2
- data/lib/capybara/selenium/driver.rb +2 -2
- data/lib/capybara/selenium/node.rb +9 -7
- data/lib/capybara/session.rb +47 -31
- data/lib/capybara/spec/fixtures/another_test_file.txt +1 -0
- data/lib/capybara/spec/public/test.js +1 -1
- data/lib/capybara/spec/session/all_spec.rb +60 -62
- data/lib/capybara/spec/session/assert_selector.rb +123 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +72 -58
- data/lib/capybara/spec/session/body_spec.rb +21 -0
- data/lib/capybara/spec/session/check_spec.rb +67 -50
- data/lib/capybara/spec/session/choose_spec.rb +32 -21
- data/lib/capybara/spec/session/click_button_spec.rb +261 -221
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +40 -30
- data/lib/capybara/spec/session/click_link_spec.rb +95 -81
- data/lib/capybara/spec/session/current_url_spec.rb +70 -60
- data/lib/capybara/spec/session/evaluate_script_spec.rb +6 -0
- data/lib/capybara/spec/session/execute_script_spec.rb +7 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +118 -92
- data/lib/capybara/spec/session/find_button_spec.rb +16 -14
- data/lib/capybara/spec/session/find_by_id_spec.rb +16 -14
- data/lib/capybara/spec/session/find_field_spec.rb +23 -21
- data/lib/capybara/spec/session/find_link_spec.rb +15 -14
- data/lib/capybara/spec/session/find_spec.rb +96 -91
- data/lib/capybara/spec/session/first_spec.rb +53 -55
- data/lib/capybara/spec/session/has_button_spec.rb +22 -24
- data/lib/capybara/spec/session/has_css_spec.rb +190 -205
- data/lib/capybara/spec/session/has_field_spec.rb +167 -169
- data/lib/capybara/spec/session/has_link_spec.rb +26 -29
- data/lib/capybara/spec/session/has_select_spec.rb +175 -176
- data/lib/capybara/spec/session/has_selector_spec.rb +94 -100
- data/lib/capybara/spec/session/has_table_spec.rb +22 -26
- data/lib/capybara/spec/session/has_text_spec.rb +159 -132
- data/lib/capybara/spec/session/has_xpath_spec.rb +100 -96
- data/lib/capybara/spec/session/headers.rb +4 -17
- data/lib/capybara/spec/session/html_spec.rb +15 -0
- data/lib/capybara/spec/session/node_spec.rb +172 -82
- data/lib/capybara/spec/session/reset_session_spec.rb +42 -0
- data/lib/capybara/spec/session/response_code.rb +4 -17
- data/lib/capybara/spec/session/save_page_spec.rb +46 -0
- data/lib/capybara/spec/session/screenshot.rb +8 -24
- data/lib/capybara/spec/session/select_spec.rb +100 -89
- data/lib/capybara/spec/session/source_spec.rb +12 -0
- data/lib/capybara/spec/session/text_spec.rb +15 -17
- data/lib/capybara/spec/session/uncheck_spec.rb +22 -17
- data/lib/capybara/spec/session/unselect_spec.rb +57 -52
- data/lib/capybara/spec/session/visit_spec.rb +58 -60
- data/lib/capybara/spec/session/within_frame_spec.rb +24 -26
- data/lib/capybara/spec/session/within_spec.rb +119 -121
- data/lib/capybara/spec/session/within_window_spec.rb +29 -31
- data/lib/capybara/spec/spec_helper.rb +84 -0
- data/lib/capybara/spec/test_app.rb +5 -3
- data/lib/capybara/spec/views/form.erb +1 -0
- data/lib/capybara/spec/views/with_html.erb +6 -1
- data/lib/capybara/spec/views/with_js.erb +1 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +2 -2
- data/spec/capybara_spec.rb +9 -0
- data/spec/dsl_spec.rb +22 -10
- data/spec/rack_test_spec.rb +28 -23
- data/spec/result_spec.rb +51 -0
- data/spec/rspec/features_spec.rb +19 -0
- data/spec/rspec/matchers_spec.rb +6 -0
- data/spec/rspec_spec.rb +1 -1
- data/spec/selenium_spec.rb +11 -25
- data/spec/server_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -46
- metadata +41 -98
- data/lib/capybara/spec/session.rb +0 -183
- data/lib/capybara/spec/session/javascript.rb +0 -290
- data/lib/capybara/util/save_and_open_page.rb +0 -45
- data/spec/save_and_open_page_spec.rb +0 -155
@@ -1,67 +1,72 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
Capybara::SpecHelper.spec "#unselect" do
|
2
|
+
before do
|
3
|
+
@session.visit('/form')
|
4
|
+
end
|
5
|
+
|
6
|
+
context "with multiple select" do
|
7
|
+
it "should unselect an option from a select box by id" do
|
8
|
+
@session.unselect('Commando', :from => 'form_underwear')
|
9
|
+
@session.click_button('awesome')
|
10
|
+
extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
|
11
|
+
extract_results(@session)['underwear'].should_not include('Commando')
|
5
12
|
end
|
6
13
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
+
it "should unselect an option without a select box" do
|
15
|
+
@session.unselect('Commando')
|
16
|
+
@session.click_button('awesome')
|
17
|
+
extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
|
18
|
+
extract_results(@session)['underwear'].should_not include('Commando')
|
19
|
+
end
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
it "should unselect an option from a select box by label" do
|
22
|
+
@session.unselect('Commando', :from => 'Underwear')
|
23
|
+
@session.click_button('awesome')
|
24
|
+
extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
|
25
|
+
extract_results(@session)['underwear'].should_not include('Commando')
|
26
|
+
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
it "should favour exact matches to option labels" do
|
29
|
+
@session.unselect("Briefs", :from => 'Underwear')
|
30
|
+
@session.click_button('awesome')
|
31
|
+
extract_results(@session)['underwear'].should include('Commando', 'Boxerbriefs')
|
32
|
+
extract_results(@session)['underwear'].should_not include('Briefs')
|
33
|
+
end
|
28
34
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
+
it "should escape quotes" do
|
36
|
+
@session.unselect("Frenchman's Pantalons", :from => 'Underwear')
|
37
|
+
@session.click_button('awesome')
|
38
|
+
extract_results(@session)['underwear'].should_not include("Frenchman's Pantalons")
|
39
|
+
end
|
35
40
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
it "casts to string" do
|
42
|
+
@session.unselect(:"Briefs", :from => :'Underwear')
|
43
|
+
@session.click_button('awesome')
|
44
|
+
extract_results(@session)['underwear'].should include('Commando', 'Boxerbriefs')
|
45
|
+
extract_results(@session)['underwear'].should_not include('Briefs')
|
41
46
|
end
|
47
|
+
end
|
42
48
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
49
|
+
context "with single select" do
|
50
|
+
it "should raise an error" do
|
51
|
+
expect { @session.unselect("English", :from => 'form_locale') }.to raise_error(Capybara::UnselectNotAllowed)
|
47
52
|
end
|
53
|
+
end
|
48
54
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
55
|
+
context "with a locator that doesn't exist" do
|
56
|
+
it "should raise an error" do
|
57
|
+
msg = "Unable to find select box \"does not exist\""
|
58
|
+
expect do
|
59
|
+
@session.unselect('foo', :from => 'does not exist')
|
60
|
+
end.to raise_error(Capybara::ElementNotFound, msg)
|
56
61
|
end
|
62
|
+
end
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
64
|
+
context "with an option that doesn't exist" do
|
65
|
+
it "should raise an error" do
|
66
|
+
msg = "Unable to find option \"Does not Exist\""
|
67
|
+
expect do
|
68
|
+
@session.unselect('Does not Exist', :from => 'form_underwear')
|
69
|
+
end.to raise_error(Capybara::ElementNotFound, msg)
|
65
70
|
end
|
66
71
|
end
|
67
72
|
end
|
@@ -1,76 +1,74 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
1
|
+
Capybara::SpecHelper.spec '#visit' do
|
2
|
+
it "should fetch a response from the driver with a relative url" do
|
3
|
+
@session.visit('/')
|
4
|
+
@session.should have_content('Hello world!')
|
5
|
+
@session.visit('/foo')
|
6
|
+
@session.should have_content('Another World')
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
it "should fetch a response from the driver with an absolute url with a port" do
|
10
|
+
# Preparation
|
11
|
+
@session.visit('/')
|
12
|
+
root_uri = URI.parse(@session.current_url)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
@session.visit("http://#{root_uri.host}:#{root_uri.port}/")
|
15
|
+
@session.should have_content('Hello world!')
|
16
|
+
@session.visit("http://#{root_uri.host}:#{root_uri.port}/foo")
|
17
|
+
@session.should have_content('Another World')
|
18
|
+
end
|
20
19
|
|
21
|
-
|
20
|
+
context "when Capybara.always_include_port is true" do
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
let(:root_uri) do
|
23
|
+
@session.visit('/')
|
24
|
+
URI.parse(@session.current_url)
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
before(:each) do
|
28
|
+
Capybara.always_include_port = true
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
after(:each) do
|
32
|
+
Capybara.always_include_port = false
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
it "should fetch a response from the driver with an absolute url without a port" do
|
36
|
+
@session.visit("http://#{root_uri.host}/")
|
37
|
+
URI.parse(@session.current_url).port.should == root_uri.port
|
38
|
+
@session.should have_content('Hello world!')
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
40
|
+
@session.visit("http://#{root_uri.host}/foo")
|
41
|
+
URI.parse(@session.current_url).port.should == root_uri.port
|
42
|
+
@session.should have_content('Another World')
|
45
43
|
end
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
it "should send no referer when visiting a page" do
|
47
|
+
@session.visit '/get_referer'
|
48
|
+
@session.should have_content 'No referer'
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
it "should send no referer when visiting a second page" do
|
52
|
+
@session.visit '/get_referer'
|
53
|
+
@session.visit '/get_referer'
|
54
|
+
@session.should have_content 'No referer'
|
55
|
+
end
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
it "should send a referer when following a link" do
|
58
|
+
@session.visit '/referer_base'
|
59
|
+
@session.find('//a[@href="/get_referer"]').click
|
60
|
+
@session.body.should match %r{http://.*/referer_base}
|
61
|
+
end
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
it "should preserve the original referer URL when following a redirect" do
|
64
|
+
@session.visit('/referer_base')
|
65
|
+
@session.find('//a[@href="/redirect_to_get_referer"]').click
|
66
|
+
@session.body.should match %r{http://.*/referer_base}
|
67
|
+
end
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
69
|
+
it "should send a referer when submitting a form" do
|
70
|
+
@session.visit '/referer_base'
|
71
|
+
@session.find('//input').click
|
72
|
+
@session.body.should match %r{http://.*/referer_base}
|
75
73
|
end
|
76
74
|
end
|
@@ -1,33 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
1
|
+
Capybara::SpecHelper.spec '#within_frame', :requires => [:frames] do
|
2
|
+
before(:each) do
|
3
|
+
@session.visit('/within_frames')
|
4
|
+
end
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
6
|
+
it "should find the div in frameOne" do
|
7
|
+
@session.within_frame("frameOne") do
|
8
|
+
@session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
|
11
9
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
it "should find the text div in the main window after finding text in frameOne" do
|
18
|
-
@session.within_frame("frameOne") do
|
19
|
-
@session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
|
20
|
-
end
|
21
|
-
@session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
|
10
|
+
end
|
11
|
+
it "should find the div in FrameTwo" do
|
12
|
+
@session.within_frame("frameTwo") do
|
13
|
+
@session.find("//*[@id='divInFrameTwo']").text.should eql 'This is the text of divInFrameTwo'
|
22
14
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
|
15
|
+
end
|
16
|
+
it "should find the text div in the main window after finding text in frameOne" do
|
17
|
+
@session.within_frame("frameOne") do
|
18
|
+
@session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
|
28
19
|
end
|
29
|
-
|
30
|
-
|
20
|
+
@session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
|
21
|
+
end
|
22
|
+
it "should find the text div in the main window after finding text in frameTwo" do
|
23
|
+
@session.within_frame("frameTwo") do
|
24
|
+
@session.find("//*[@id='divInFrameTwo']").text.should eql 'This is the text of divInFrameTwo'
|
31
25
|
end
|
26
|
+
@session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
|
27
|
+
end
|
28
|
+
it "should return the result of executing the block" do
|
29
|
+
@session.within_frame("frameOne") { "return value" }.should eql "return value"
|
32
30
|
end
|
33
31
|
end
|
@@ -1,167 +1,165 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
Capybara::SpecHelper.spec '#within' do
|
2
|
+
before do
|
3
|
+
@session.visit('/with_scope')
|
4
|
+
end
|
5
|
+
|
6
|
+
context "with CSS selector" do
|
7
|
+
it "should click links in the given scope" do
|
8
|
+
@session.within(:css, "#for_bar li[contains('With Simple HTML')]") do
|
9
|
+
@session.click_link('Go')
|
10
|
+
end
|
11
|
+
@session.should have_content('Bar')
|
5
12
|
end
|
6
13
|
|
7
|
-
|
8
|
-
|
9
|
-
@session.
|
10
|
-
@session.click_link('Go')
|
11
|
-
end
|
12
|
-
@session.body.should include('Bar')
|
14
|
+
it "should assert content in the given scope" do
|
15
|
+
@session.within(:css, "#for_foo") do
|
16
|
+
@session.should_not have_content('First Name')
|
13
17
|
end
|
18
|
+
@session.should have_content('First Name')
|
19
|
+
end
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
@session.should have_content('First Name')
|
21
|
+
it "should accept additional options" do
|
22
|
+
@session.within(:css, "#for_bar li", :text => 'With Simple HTML') do
|
23
|
+
@session.click_link('Go')
|
20
24
|
end
|
25
|
+
@session.should have_content('Bar')
|
26
|
+
end
|
27
|
+
end
|
21
28
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@session.body.should include('Bar')
|
29
|
+
context "with XPath selector" do
|
30
|
+
it "should click links in the given scope" do
|
31
|
+
@session.within(:xpath, "//div[@id='for_bar']//li[contains(.,'With Simple HTML')]") do
|
32
|
+
@session.click_link('Go')
|
27
33
|
end
|
34
|
+
@session.should have_content('Bar')
|
28
35
|
end
|
36
|
+
end
|
29
37
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
@session.body.should include('Bar')
|
38
|
+
context "with the default selector" do
|
39
|
+
it "should use XPath" do
|
40
|
+
@session.within("//div[@id='for_bar']//li[contains(.,'With Simple HTML')]") do
|
41
|
+
@session.click_link('Go')
|
36
42
|
end
|
43
|
+
@session.should have_content('Bar')
|
37
44
|
end
|
45
|
+
end
|
38
46
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@session.
|
47
|
+
context "with Node rather than selector" do
|
48
|
+
it "should click links in the given scope" do
|
49
|
+
node_of_interest = @session.find(:css, "#for_bar li[contains('With Simple HTML')]")
|
50
|
+
|
51
|
+
@session.within(node_of_interest) do
|
52
|
+
@session.click_link('Go')
|
45
53
|
end
|
54
|
+
@session.should have_content('Bar')
|
46
55
|
end
|
56
|
+
end
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
58
|
+
context "with the default selector set to CSS" do
|
59
|
+
before { Capybara.default_selector = :css }
|
60
|
+
it "should use CSS" do
|
61
|
+
@session.within("#for_bar li[contains('With Simple HTML')]") do
|
62
|
+
@session.click_link('Go')
|
63
|
+
end
|
64
|
+
@session.should have_content('Bar')
|
65
|
+
end
|
66
|
+
after { Capybara.default_selector = :xpath }
|
67
|
+
end
|
51
68
|
|
52
|
-
|
69
|
+
context "with nested scopes" do
|
70
|
+
it "should respect the inner scope" do
|
71
|
+
@session.within("//div[@id='for_bar']") do
|
72
|
+
@session.within(".//li[contains(.,'Bar')]") do
|
53
73
|
@session.click_link('Go')
|
54
74
|
end
|
55
|
-
@session.body.should include('Bar')
|
56
75
|
end
|
76
|
+
@session.should have_content('Another World')
|
57
77
|
end
|
58
78
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@session.within("#for_bar li[contains('With Simple HTML')]") do
|
79
|
+
it "should respect the outer scope" do
|
80
|
+
@session.within("//div[@id='another_foo']") do
|
81
|
+
@session.within(".//li[contains(.,'With Simple HTML')]") do
|
63
82
|
@session.click_link('Go')
|
64
83
|
end
|
65
|
-
@session.body.should include('Bar')
|
66
84
|
end
|
67
|
-
|
85
|
+
@session.should have_content('Hello world')
|
68
86
|
end
|
87
|
+
end
|
69
88
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@session.within(".//li[contains(.,'Bar')]") do
|
74
|
-
@session.click_link('Go')
|
75
|
-
end
|
76
|
-
end
|
77
|
-
@session.body.should include('Another World')
|
89
|
+
it "should raise an error if the scope is not found on the page" do
|
90
|
+
expect do
|
91
|
+
@session.within("//div[@id='doesnotexist']") do
|
78
92
|
end
|
93
|
+
end.to raise_error(Capybara::ElementNotFound)
|
94
|
+
end
|
79
95
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
96
|
+
it "should restore the scope when an error is raised" do
|
97
|
+
expect do
|
98
|
+
@session.within("//div[@id='for_bar']") do
|
99
|
+
expect do
|
100
|
+
expect do
|
101
|
+
@session.within(".//div[@id='doesnotexist']") do
|
102
|
+
end
|
103
|
+
end.to raise_error(Capybara::ElementNotFound)
|
104
|
+
end.to_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
|
87
105
|
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should raise an error if the scope is not found on the page" do
|
91
|
-
running do
|
92
|
-
@session.within("//div[@id='doesnotexist']") do
|
93
|
-
end
|
94
|
-
end.should raise_error(Capybara::ElementNotFound)
|
95
|
-
end
|
106
|
+
end.to_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
|
107
|
+
end
|
96
108
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
running do
|
101
|
-
running do
|
102
|
-
@session.within(".//div[@id='doesnotexist']") do
|
103
|
-
end
|
104
|
-
end.should raise_error(Capybara::ElementNotFound)
|
105
|
-
end.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
|
106
|
-
end
|
107
|
-
end.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
|
109
|
+
it "should fill in a field and click a button" do
|
110
|
+
@session.within("//li[contains(.,'Bar')]") do
|
111
|
+
@session.click_button('Go')
|
108
112
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
extract_results(@session)['first_name'].should == 'Peter'
|
115
|
-
@session.visit('/with_scope')
|
116
|
-
@session.within("//li[contains(.,'Bar')]") do
|
117
|
-
@session.fill_in('First Name', :with => 'Dagobert')
|
118
|
-
@session.click_button('Go')
|
119
|
-
end
|
120
|
-
extract_results(@session)['first_name'].should == 'Dagobert'
|
113
|
+
extract_results(@session)['first_name'].should == 'Peter'
|
114
|
+
@session.visit('/with_scope')
|
115
|
+
@session.within("//li[contains(.,'Bar')]") do
|
116
|
+
@session.fill_in('First Name', :with => 'Dagobert')
|
117
|
+
@session.click_button('Go')
|
121
118
|
end
|
119
|
+
extract_results(@session)['first_name'].should == 'Dagobert'
|
122
120
|
end
|
121
|
+
end
|
123
122
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
123
|
+
Capybara::SpecHelper.spec '#within_fieldset' do
|
124
|
+
before do
|
125
|
+
@session.visit('/fieldsets')
|
126
|
+
end
|
128
127
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
extract_results(@session)['villain_name'].should == 'Goldfinger'
|
128
|
+
it "should restrict scope to a fieldset given by id" do
|
129
|
+
@session.within_fieldset("villain_fieldset") do
|
130
|
+
@session.fill_in("Name", :with => 'Goldfinger')
|
131
|
+
@session.click_button("Create")
|
135
132
|
end
|
133
|
+
extract_results(@session)['villain_name'].should == 'Goldfinger'
|
134
|
+
end
|
136
135
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
142
|
-
extract_results(@session)['villain_name'].should == 'Goldfinger'
|
136
|
+
it "should restrict scope to a fieldset given by legend" do
|
137
|
+
@session.within_fieldset("Villain") do
|
138
|
+
@session.fill_in("Name", :with => 'Goldfinger')
|
139
|
+
@session.click_button("Create")
|
143
140
|
end
|
141
|
+
extract_results(@session)['villain_name'].should == 'Goldfinger'
|
144
142
|
end
|
143
|
+
end
|
145
144
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
145
|
+
Capybara::SpecHelper.spec '#within_table' do
|
146
|
+
before do
|
147
|
+
@session.visit('/tables')
|
148
|
+
end
|
150
149
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
end
|
156
|
-
extract_results(@session)['girl_name'].should == 'Christmas'
|
150
|
+
it "should restrict scope to a fieldset given by id" do
|
151
|
+
@session.within_table("girl_table") do
|
152
|
+
@session.fill_in("Name", :with => 'Christmas')
|
153
|
+
@session.click_button("Create")
|
157
154
|
end
|
155
|
+
extract_results(@session)['girl_name'].should == 'Christmas'
|
156
|
+
end
|
158
157
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
164
|
-
extract_results(@session)['villain_name'].should == 'Quantum'
|
158
|
+
it "should restrict scope to a fieldset given by legend" do
|
159
|
+
@session.within_table("Villain") do
|
160
|
+
@session.fill_in("Name", :with => 'Quantum')
|
161
|
+
@session.click_button("Create")
|
165
162
|
end
|
163
|
+
extract_results(@session)['villain_name'].should == 'Quantum'
|
166
164
|
end
|
167
165
|
end
|