capybara_minitest_spec 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/HISTORY.md +0 -0
- data/README.md +31 -32
- data/Rakefile +2 -2
- data/capybara_minitest_spec.gemspec +6 -4
- data/lib/capybara_minitest_spec.rb +53 -6
- data/lib/capybara_minitest_spec/test_name.rb +67 -0
- data/lib/capybara_minitest_spec/version.rb +1 -1
- data/spec/capybara_minitest_spec.spec.rb +13 -0
- data/spec/capybara_rspec_matchers.spec.rb +580 -0
- data/spec/helper.rb +39 -0
- data/{test_app → spec/test_app}/test_app.rb +0 -0
- data/{test_app → spec/test_app}/views/buttons.erb +0 -0
- data/{test_app → spec/test_app}/views/fieldsets.erb +0 -0
- data/{test_app → spec/test_app}/views/form.erb +0 -0
- data/{test_app → spec/test_app}/views/frame_one.erb +0 -0
- data/{test_app → spec/test_app}/views/frame_two.erb +0 -0
- data/{test_app → spec/test_app}/views/header_links.erb +0 -0
- data/{test_app → spec/test_app}/views/host_links.erb +0 -0
- data/{test_app → spec/test_app}/views/popup_one.erb +0 -0
- data/{test_app → spec/test_app}/views/popup_two.erb +0 -0
- data/{test_app → spec/test_app}/views/postback.erb +0 -0
- data/{test_app → spec/test_app}/views/tables.erb +0 -0
- data/{test_app → spec/test_app}/views/with_html.erb +0 -0
- data/{test_app → spec/test_app}/views/with_html_entities.erb +0 -0
- data/{test_app → spec/test_app}/views/with_js.erb +0 -0
- data/{test_app → spec/test_app}/views/with_scope.erb +0 -0
- data/{test_app → spec/test_app}/views/with_simple_html.erb +0 -0
- data/{test_app → spec/test_app}/views/within_frames.erb +0 -0
- data/{test_app → spec/test_app}/views/within_popups.erb +0 -0
- data/spec/test_name.spec.rb +47 -0
- metadata +142 -121
- data/lib/capybara_minitest_spec/matcher.rb +0 -126
- data/test/capybara_node_matchers_spec.rb +0 -471
- data/test/custom_matcher_spec.rb +0 -29
- data/test/matcher_spec.rb +0 -45
- data/test/spec_helper.rb +0 -14
- data/test_app/driver.rb +0 -297
- data/test_app/fixtures/capybara.jpg +0 -3
- data/test_app/fixtures/test_file.txt +0 -1
- data/test_app/public/test.js +0 -43
- data/test_app/session.rb +0 -154
- data/test_app/session/all_spec.rb +0 -78
- data/test_app/session/attach_file_spec.rb +0 -73
- data/test_app/session/check_spec.rb +0 -65
- data/test_app/session/choose_spec.rb +0 -26
- data/test_app/session/click_button_spec.rb +0 -304
- data/test_app/session/click_link_or_button_spec.rb +0 -36
- data/test_app/session/click_link_spec.rb +0 -119
- data/test_app/session/current_host_spec.rb +0 -68
- data/test_app/session/current_url_spec.rb +0 -15
- data/test_app/session/fill_in_spec.rb +0 -125
- data/test_app/session/find_button_spec.rb +0 -18
- data/test_app/session/find_by_id_spec.rb +0 -18
- data/test_app/session/find_field_spec.rb +0 -26
- data/test_app/session/find_link_spec.rb +0 -19
- data/test_app/session/find_spec.rb +0 -149
- data/test_app/session/first_spec.rb +0 -105
- data/test_app/session/has_button_spec.rb +0 -32
- data/test_app/session/has_content_spec.rb +0 -106
- data/test_app/session/has_css_spec.rb +0 -243
- data/test_app/session/has_field_spec.rb +0 -192
- data/test_app/session/has_link_spec.rb +0 -37
- data/test_app/session/has_select_spec.rb +0 -129
- data/test_app/session/has_selector_spec.rb +0 -129
- data/test_app/session/has_table_spec.rb +0 -96
- data/test_app/session/has_xpath_spec.rb +0 -123
- data/test_app/session/headers.rb +0 -19
- data/test_app/session/javascript.rb +0 -289
- data/test_app/session/response_code.rb +0 -19
- data/test_app/session/select_spec.rb +0 -113
- data/test_app/session/text_spec.rb +0 -19
- data/test_app/session/uncheck_spec.rb +0 -21
- data/test_app/session/unselect_spec.rb +0 -61
- data/test_app/session/within_spec.rb +0 -178
@@ -1,96 +0,0 @@
|
|
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
|
-
|
@@ -1,123 +0,0 @@
|
|
1
|
-
shared_examples_for "has_xpath" do
|
2
|
-
describe '#has_xpath?' 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_xpath("//p")
|
9
|
-
@session.should have_xpath("//p//a[@id='foo']")
|
10
|
-
@session.should have_xpath("//p[contains(.,'est')]")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should be false if the given selector is not on the page" do
|
14
|
-
@session.should_not have_xpath("//abbr")
|
15
|
-
@session.should_not have_xpath("//p//a[@id='doesnotexist']")
|
16
|
-
@session.should_not have_xpath("//p[contains(.,'thisstringisnotonpage')]")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should use xpath even if default selector is CSS" do
|
20
|
-
Capybara.default_selector = :css
|
21
|
-
@session.should_not have_xpath("//p//a[@id='doesnotexist']")
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should respect scopes" do
|
25
|
-
@session.within "//p[@id='first']" do
|
26
|
-
@session.should have_xpath(".//a[@id='foo']")
|
27
|
-
@session.should_not have_xpath(".//a[@id='red']")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "with count" do
|
32
|
-
it "should be true if the content is on the page the given number of times" do
|
33
|
-
@session.should have_xpath("//p", :count => 3)
|
34
|
-
@session.should have_xpath("//p//a[@id='foo']", :count => 1)
|
35
|
-
@session.should have_xpath("//p[contains(.,'est')]", :count => 1)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should be false if the content is on the page the given number of times" do
|
39
|
-
@session.should_not have_xpath("//p", :count => 6)
|
40
|
-
@session.should_not have_xpath("//p//a[@id='foo']", :count => 2)
|
41
|
-
@session.should_not have_xpath("//p[contains(.,'est')]", :count => 5)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should be false if the content isn't on the page at all" do
|
45
|
-
@session.should_not have_xpath("//abbr", :count => 2)
|
46
|
-
@session.should_not have_xpath("//p//a[@id='doesnotexist']", :count => 1)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "with text" do
|
51
|
-
it "should discard all matches where the given string is not contained" do
|
52
|
-
@session.should have_xpath("//p//a", :text => "Redirect", :count => 1)
|
53
|
-
@session.should_not have_xpath("//p", :text => "Doesnotexist")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should discard all matches where the given regexp is not matched" do
|
57
|
-
@session.should have_xpath("//p//a", :text => /re[dab]i/i, :count => 1)
|
58
|
-
@session.should_not have_xpath("//p//a", :text => /Red$/)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '#has_no_xpath?' do
|
64
|
-
before do
|
65
|
-
@session.visit('/with_html')
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should be false if the given selector is on the page" do
|
69
|
-
@session.should_not have_no_xpath("//p")
|
70
|
-
@session.should_not have_no_xpath("//p//a[@id='foo']")
|
71
|
-
@session.should_not have_no_xpath("//p[contains(.,'est')]")
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should be true if the given selector is not on the page" do
|
75
|
-
@session.should have_no_xpath("//abbr")
|
76
|
-
@session.should have_no_xpath("//p//a[@id='doesnotexist']")
|
77
|
-
@session.should have_no_xpath("//p[contains(.,'thisstringisnotonpage')]")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should use xpath even if default selector is CSS" do
|
81
|
-
Capybara.default_selector = :css
|
82
|
-
@session.should have_no_xpath("//p//a[@id='doesnotexist']")
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should respect scopes" do
|
86
|
-
@session.within "//p[@id='first']" do
|
87
|
-
@session.should_not have_no_xpath(".//a[@id='foo']")
|
88
|
-
@session.should have_no_xpath(".//a[@id='red']")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context "with count" do
|
93
|
-
it "should be false if the content is on the page the given number of times" do
|
94
|
-
@session.should_not have_no_xpath("//p", :count => 3)
|
95
|
-
@session.should_not have_no_xpath("//p//a[@id='foo']", :count => 1)
|
96
|
-
@session.should_not have_no_xpath("//p[contains(.,'est')]", :count => 1)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should be true if the content is on the page the wrong number of times" do
|
100
|
-
@session.should have_no_xpath("//p", :count => 6)
|
101
|
-
@session.should have_no_xpath("//p//a[@id='foo']", :count => 2)
|
102
|
-
@session.should have_no_xpath("//p[contains(.,'est')]", :count => 5)
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should be true if the content isn't on the page at all" do
|
106
|
-
@session.should have_no_xpath("//abbr", :count => 2)
|
107
|
-
@session.should have_no_xpath("//p//a[@id='doesnotexist']", :count => 1)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
context "with text" do
|
112
|
-
it "should discard all matches where the given string is contained" do
|
113
|
-
@session.should_not have_no_xpath("//p//a", :text => "Redirect", :count => 1)
|
114
|
-
@session.should have_no_xpath("//p", :text => "Doesnotexist")
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should discard all matches where the given regexp is matched" do
|
118
|
-
@session.should_not have_no_xpath("//p//a", :text => /re[dab]i/i, :count => 1)
|
119
|
-
@session.should have_no_xpath("//p//a", :text => /Red$/)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
data/test_app/session/headers.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
shared_examples_for "session with headers support" do
|
2
|
-
describe '#response_headers' do
|
3
|
-
it "should return response headers" do
|
4
|
-
@session.visit('/with_simple_html')
|
5
|
-
@session.response_headers['Content-Type'].should =~ %r(text/html)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
shared_examples_for "session without headers support" do
|
11
|
-
describe "#response_headers" do
|
12
|
-
before{ @session.visit('/with_simple_html') }
|
13
|
-
it "should raise an error" do
|
14
|
-
running {
|
15
|
-
@session.response_headers
|
16
|
-
}.should raise_error(Capybara::NotSupportedByDriverError)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,289 +0,0 @@
|
|
1
|
-
shared_examples_for "session with javascript support" do
|
2
|
-
describe 'all JS specs' do
|
3
|
-
before do
|
4
|
-
Capybara.default_wait_time = 1
|
5
|
-
end
|
6
|
-
|
7
|
-
after do
|
8
|
-
Capybara.default_wait_time = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'Node#drag_to' do
|
12
|
-
it "should drag and drop an object" do
|
13
|
-
@session.visit('/with_js')
|
14
|
-
element = @session.find('//div[@id="drag"]')
|
15
|
-
target = @session.find('//div[@id="drop"]')
|
16
|
-
element.drag_to(target)
|
17
|
-
@session.find('//div[contains(., "Dropped!")]').should_not be_nil
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'Node#reload' do
|
22
|
-
context "without automatic reload" do
|
23
|
-
before { Capybara.automatic_reload = false }
|
24
|
-
it "should reload the current context of the node" do
|
25
|
-
@session.visit('/with_js')
|
26
|
-
node = @session.find(:css, '#reload-me')
|
27
|
-
@session.click_link('Reload!')
|
28
|
-
sleep(0.3)
|
29
|
-
node.reload.text.should == 'RELOADED'
|
30
|
-
node.text.should == 'RELOADED'
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should reload a parent node" do
|
34
|
-
@session.visit('/with_js')
|
35
|
-
node = @session.find(:css, '#reload-me').find(:css, 'em')
|
36
|
-
@session.click_link('Reload!')
|
37
|
-
sleep(0.3)
|
38
|
-
node.reload.text.should == 'RELOADED'
|
39
|
-
node.text.should == 'RELOADED'
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should not automatically reload" do
|
43
|
-
@session.visit('/with_js')
|
44
|
-
node = @session.find(:css, '#reload-me')
|
45
|
-
@session.click_link('Reload!')
|
46
|
-
sleep(0.3)
|
47
|
-
running { node.text.should == 'RELOADED' }.should raise_error
|
48
|
-
end
|
49
|
-
after { Capybara.automatic_reload = true }
|
50
|
-
end
|
51
|
-
|
52
|
-
context "with automatic reload" do
|
53
|
-
it "should reload the current context of the node automatically" do
|
54
|
-
@session.visit('/with_js')
|
55
|
-
node = @session.find(:css, '#reload-me')
|
56
|
-
@session.click_link('Reload!')
|
57
|
-
sleep(0.3)
|
58
|
-
node.text.should == 'RELOADED'
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should reload a parent node automatically" do
|
62
|
-
@session.visit('/with_js')
|
63
|
-
node = @session.find(:css, '#reload-me').find(:css, 'em')
|
64
|
-
@session.click_link('Reload!')
|
65
|
-
sleep(0.3)
|
66
|
-
node.text.should == 'RELOADED'
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should reload a node automatically when using find" do
|
70
|
-
@session.visit('/with_js')
|
71
|
-
node = @session.find(:css, '#reload-me')
|
72
|
-
@session.click_link('Reload!')
|
73
|
-
sleep(0.3)
|
74
|
-
node.find(:css, 'a').text.should == 'RELOADED'
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#find' do
|
80
|
-
it "should allow triggering of custom JS events" do
|
81
|
-
pending "cannot figure out how to do this with selenium" if @session.mode == :selenium
|
82
|
-
@session.visit('/with_js')
|
83
|
-
@session.find(:css, '#with_focus_event').trigger(:focus)
|
84
|
-
@session.should have_css('#focus_event_triggered')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#body' do
|
89
|
-
it "should return the current state of the page" do
|
90
|
-
@session.visit('/with_js')
|
91
|
-
@session.body.should include('I changed it')
|
92
|
-
@session.body.should_not include('This is text')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#source' do
|
97
|
-
it "should return the original, unmodified source of the page" do
|
98
|
-
pending "cannot figure out how to do this with selenium" if @session.mode == :selenium
|
99
|
-
@session.visit('/with_js')
|
100
|
-
@session.source.should include('This is text')
|
101
|
-
@session.source.should_not include('I changed it')
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe "#evaluate_script" do
|
106
|
-
it "should evaluate the given script and return whatever it produces" do
|
107
|
-
@session.visit('/with_js')
|
108
|
-
@session.evaluate_script("1+3").should == 4
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "#execute_script" do
|
113
|
-
it "should execute the given script and return nothing" do
|
114
|
-
@session.visit('/with_js')
|
115
|
-
@session.execute_script("$('#change').text('Funky Doodle')").should be_nil
|
116
|
-
@session.should have_css('#change', :text => 'Funky Doodle')
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe '#find' do
|
121
|
-
it "should wait for asynchronous load" do
|
122
|
-
@session.visit('/with_js')
|
123
|
-
@session.click_link('Click me')
|
124
|
-
@session.find(:css, "a#has-been-clicked").text.should include('Has been clicked')
|
125
|
-
end
|
126
|
-
|
127
|
-
context "with frozen time" do
|
128
|
-
it "raises an error suggesting that Capybara is stuck in time" do
|
129
|
-
@session.visit('/with_js')
|
130
|
-
now = Time.now
|
131
|
-
Time.stub(:now).and_return(now)
|
132
|
-
expect { @session.find('//isnotthere') }.to raise_error(Capybara::FrozenInTime)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe '#wait_until' do
|
138
|
-
before do
|
139
|
-
@default_timeout = Capybara.default_wait_time
|
140
|
-
end
|
141
|
-
|
142
|
-
after do
|
143
|
-
Capybara.default_wait_time = @default_wait_time
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should wait for block to return true" do
|
147
|
-
@session.visit('/with_js')
|
148
|
-
@session.select('My Waiting Option', :from => 'waiter')
|
149
|
-
@session.evaluate_script('activeRequests == 1').should be_true
|
150
|
-
@session.wait_until do
|
151
|
-
@session.evaluate_script('activeRequests == 0')
|
152
|
-
end
|
153
|
-
@session.evaluate_script('activeRequests == 0').should be_true
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should raise Capybara::TimeoutError if block doesn't return true within timeout" do
|
157
|
-
@session.visit('/with_html')
|
158
|
-
Proc.new do
|
159
|
-
@session.wait_until(0.1) do
|
160
|
-
@session.all('//div[@id="nosuchthing"]').first
|
161
|
-
end
|
162
|
-
end.should raise_error(::Capybara::TimeoutError)
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should accept custom timeout in seconds" do
|
166
|
-
start = Time.now
|
167
|
-
Capybara.default_wait_time = 5
|
168
|
-
begin
|
169
|
-
@session.wait_until(0.1) { false }
|
170
|
-
rescue Capybara::TimeoutError; end
|
171
|
-
(Time.now - start).should be_within(0.1).of(0.1)
|
172
|
-
end
|
173
|
-
|
174
|
-
it "should default to Capybara.default_wait_time before timeout" do
|
175
|
-
@session.driver # init the driver to exclude init timing from test
|
176
|
-
start = Time.now
|
177
|
-
Capybara.default_wait_time = 0.2
|
178
|
-
begin
|
179
|
-
@session.wait_until { false }
|
180
|
-
rescue Capybara::TimeoutError; end
|
181
|
-
if @session.driver.has_shortcircuit_timeout?
|
182
|
-
(Time.now - start).should be_within(0.1).of(0)
|
183
|
-
else
|
184
|
-
(Time.now - start).should be_within(0.1).of(0.2)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe '#click_link_or_button' do
|
190
|
-
it "should wait for asynchronous load" do
|
191
|
-
@session.visit('/with_js')
|
192
|
-
@session.click_link('Click me')
|
193
|
-
@session.click_link_or_button('Has been clicked')
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe '#click_link' do
|
198
|
-
it "should wait for asynchronous load" do
|
199
|
-
@session.visit('/with_js')
|
200
|
-
@session.click_link('Click me')
|
201
|
-
@session.click_link('Has been clicked')
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe '#click_button' do
|
206
|
-
it "should wait for asynchronous load" do
|
207
|
-
@session.visit('/with_js')
|
208
|
-
@session.click_link('Click me')
|
209
|
-
@session.click_button('New Here')
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
describe '#fill_in' do
|
214
|
-
it "should wait for asynchronous load" do
|
215
|
-
@session.visit('/with_js')
|
216
|
-
@session.click_link('Click me')
|
217
|
-
@session.fill_in('new_field', :with => 'Testing...')
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
describe '#check' do
|
222
|
-
it "should trigger associated events" do
|
223
|
-
@session.visit('/with_js')
|
224
|
-
@session.check('checkbox_with_event')
|
225
|
-
@session.should have_css('#checkbox_event_triggered');
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
describe '#has_xpath?' do
|
230
|
-
it "should wait for content to appear" do
|
231
|
-
@session.visit('/with_js')
|
232
|
-
@session.click_link('Click me')
|
233
|
-
@session.should have_xpath("//input[@type='submit' and @value='New Here']")
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
describe '#has_no_xpath?' do
|
238
|
-
it "should wait for content to disappear" do
|
239
|
-
@session.visit('/with_js')
|
240
|
-
@session.click_link('Click me')
|
241
|
-
@session.should have_no_xpath("//p[@id='change']")
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
describe '#has_css?' do
|
246
|
-
it "should wait for content to appear" do
|
247
|
-
@session.visit('/with_js')
|
248
|
-
@session.click_link('Click me')
|
249
|
-
@session.should have_css("input[type='submit'][value='New Here']")
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
describe '#has_no_xpath?' do
|
254
|
-
it "should wait for content to disappear" do
|
255
|
-
@session.visit('/with_js')
|
256
|
-
@session.click_link('Click me')
|
257
|
-
@session.should have_no_css("p#change")
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
describe '#has_content?' do
|
262
|
-
it "should wait for content to appear" do
|
263
|
-
@session.visit('/with_js')
|
264
|
-
@session.click_link('Click me')
|
265
|
-
@session.should have_content("Has been clicked")
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
describe '#has_no_content?' do
|
270
|
-
it "should wait for content to disappear" do
|
271
|
-
@session.visit('/with_js')
|
272
|
-
@session.click_link('Click me')
|
273
|
-
@session.should have_no_content("I changed it")
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
shared_examples_for "session without javascript support" do
|
281
|
-
describe "#evaluate_script" do
|
282
|
-
before{ @session.visit('/with_simple_html') }
|
283
|
-
it "should raise an error" do
|
284
|
-
running {
|
285
|
-
@session.evaluate_script('3 + 3')
|
286
|
-
}.should raise_error(Capybara::NotSupportedByDriverError)
|
287
|
-
end
|
288
|
-
end
|
289
|
-
end
|