bbc-capybara 1.1.2
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 +325 -0
- data/License.txt +22 -0
- data/README.md +815 -0
- data/lib/capybara.rb +368 -0
- data/lib/capybara/cucumber.rb +25 -0
- data/lib/capybara/driver/base.rb +64 -0
- data/lib/capybara/driver/node.rb +74 -0
- data/lib/capybara/dsl.rb +50 -0
- data/lib/capybara/node/actions.rb +146 -0
- data/lib/capybara/node/base.rb +63 -0
- data/lib/capybara/node/document.rb +25 -0
- data/lib/capybara/node/element.rb +201 -0
- data/lib/capybara/node/finders.rb +154 -0
- data/lib/capybara/node/matchers.rb +442 -0
- data/lib/capybara/node/simple.rb +132 -0
- data/lib/capybara/query.rb +63 -0
- data/lib/capybara/rack_test/browser.rb +126 -0
- data/lib/capybara/rack_test/driver.rb +80 -0
- data/lib/capybara/rack_test/form.rb +80 -0
- data/lib/capybara/rack_test/node.rb +121 -0
- data/lib/capybara/rails.rb +17 -0
- data/lib/capybara/rspec.rb +26 -0
- data/lib/capybara/rspec/features.rb +22 -0
- data/lib/capybara/rspec/matchers.rb +152 -0
- data/lib/capybara/selector.rb +156 -0
- data/lib/capybara/selenium/driver.rb +169 -0
- data/lib/capybara/selenium/node.rb +91 -0
- data/lib/capybara/server.rb +87 -0
- data/lib/capybara/session.rb +322 -0
- data/lib/capybara/spec/driver.rb +329 -0
- data/lib/capybara/spec/fixtures/capybara.jpg +3 -0
- data/lib/capybara/spec/fixtures/test_file.txt +1 -0
- 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 +43 -0
- data/lib/capybara/spec/session.rb +148 -0
- data/lib/capybara/spec/session/all_spec.rb +78 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +76 -0
- data/lib/capybara/spec/session/check_spec.rb +68 -0
- data/lib/capybara/spec/session/choose_spec.rb +29 -0
- data/lib/capybara/spec/session/click_button_spec.rb +305 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +37 -0
- data/lib/capybara/spec/session/click_link_spec.rb +120 -0
- data/lib/capybara/spec/session/current_url_spec.rb +83 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +127 -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 +168 -0
- data/lib/capybara/spec/session/first_spec.rb +105 -0
- data/lib/capybara/spec/session/has_button_spec.rb +32 -0
- data/lib/capybara/spec/session/has_css_spec.rb +243 -0
- data/lib/capybara/spec/session/has_field_spec.rb +192 -0
- data/lib/capybara/spec/session/has_link_spec.rb +37 -0
- data/lib/capybara/spec/session/has_select_spec.rb +129 -0
- data/lib/capybara/spec/session/has_selector_spec.rb +129 -0
- data/lib/capybara/spec/session/has_table_spec.rb +34 -0
- data/lib/capybara/spec/session/has_text_spec.rb +138 -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 +312 -0
- data/lib/capybara/spec/session/response_code.rb +19 -0
- data/lib/capybara/spec/session/select_spec.rb +119 -0
- data/lib/capybara/spec/session/text_spec.rb +24 -0
- data/lib/capybara/spec/session/uncheck_spec.rb +21 -0
- data/lib/capybara/spec/session/unselect_spec.rb +67 -0
- data/lib/capybara/spec/session/within_spec.rb +178 -0
- data/lib/capybara/spec/test_app.rb +156 -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 +366 -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/header_links.erb +7 -0
- data/lib/capybara/spec/views/host_links.erb +12 -0
- data/lib/capybara/spec/views/popup_one.erb +8 -0
- data/lib/capybara/spec/views/popup_two.erb +8 -0
- data/lib/capybara/spec/views/postback.erb +13 -0
- data/lib/capybara/spec/views/tables.erb +62 -0
- data/lib/capybara/spec/views/with_html.erb +75 -0
- data/lib/capybara/spec/views/with_html_entities.erb +1 -0
- data/lib/capybara/spec/views/with_js.erb +53 -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/spec/views/within_popups.erb +25 -0
- data/lib/capybara/util/save_and_open_page.rb +45 -0
- data/lib/capybara/util/timeout.rb +27 -0
- data/lib/capybara/version.rb +3 -0
- data/spec/basic_node_spec.rb +89 -0
- data/spec/capybara_spec.rb +46 -0
- data/spec/driver/rack_test_driver_spec.rb +90 -0
- data/spec/driver/selenium_driver_spec.rb +55 -0
- data/spec/dsl_spec.rb +255 -0
- data/spec/fixtures/selenium_driver_rspec_failure.rb +8 -0
- data/spec/fixtures/selenium_driver_rspec_success.rb +8 -0
- data/spec/rspec/features_spec.rb +43 -0
- data/spec/rspec/matchers_spec.rb +564 -0
- data/spec/rspec_spec.rb +51 -0
- data/spec/save_and_open_page_spec.rb +155 -0
- data/spec/server_spec.rb +74 -0
- data/spec/session/rack_test_session_spec.rb +61 -0
- data/spec/session/selenium_session_spec.rb +26 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/timeout_spec.rb +28 -0
- metadata +297 -0
data/spec/rspec_spec.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'capybara/rspec', :type => :request do
|
|
4
|
+
it "should include Capybara in rspec" do
|
|
5
|
+
visit('/foo')
|
|
6
|
+
page.body.should include('Another World')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "resetting session" do
|
|
10
|
+
it "sets a cookie in one example..." do
|
|
11
|
+
visit('/set_cookie')
|
|
12
|
+
page.body.should include('Cookie set to test_cookie')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "...then it is not availbable in the next" do
|
|
16
|
+
visit('/get_cookie')
|
|
17
|
+
page.body.should_not include('test_cookie')
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "setting the current driver" do
|
|
22
|
+
it "sets the current driver in one example..." do
|
|
23
|
+
Capybara.current_driver = :selenium
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "...then it has returned to the default in the next example" do
|
|
27
|
+
Capybara.current_driver.should == :rack_test
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "switches to the javascript driver when giving it as metadata", :js => true do
|
|
32
|
+
Capybara.current_driver.should == Capybara.javascript_driver
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "switches to the given driver when giving it as metadata", :driver => :culerity do
|
|
36
|
+
Capybara.current_driver.should == :culerity
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe 'capybara/rspec', :type => :other do
|
|
41
|
+
it "should not include Capybara" do
|
|
42
|
+
expect { visit('/') }.to raise_error(NoMethodError)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
feature "Feature DSL" do
|
|
47
|
+
scenario "is pulled in" do
|
|
48
|
+
visit('/foo')
|
|
49
|
+
page.body.should include('Another World')
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
require 'capybara/util/save_and_open_page'
|
|
4
|
+
require 'launchy'
|
|
5
|
+
describe Capybara do
|
|
6
|
+
describe ".save_page & .save_and_open_page" do
|
|
7
|
+
before do
|
|
8
|
+
@temp_file = mock("FILE")
|
|
9
|
+
@temp_file.stub!(:write)
|
|
10
|
+
@temp_file.stub!(:close)
|
|
11
|
+
|
|
12
|
+
@html = <<-HTML
|
|
13
|
+
<html>
|
|
14
|
+
<head>
|
|
15
|
+
<script type="text/javascript" src="/javascripts/prototype.js?123"/>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<h1>test</h1>
|
|
19
|
+
<p>
|
|
20
|
+
Some images (note differing whitespace closing tag):
|
|
21
|
+
<img src="/images/image1.jpeg" />
|
|
22
|
+
<img src="/images/image2.jpeg"/>
|
|
23
|
+
</p>
|
|
24
|
+
<p>
|
|
25
|
+
Some more in a non-existent directory:
|
|
26
|
+
<img src="/img/image3.jpeg" />
|
|
27
|
+
<img src="/img/image4.jpeg"/>
|
|
28
|
+
</p>
|
|
29
|
+
<p>
|
|
30
|
+
<a href="/not-here/foo.html">
|
|
31
|
+
A link to a file in a non-existent directory.
|
|
32
|
+
</a>
|
|
33
|
+
</p>
|
|
34
|
+
</body>
|
|
35
|
+
<html>
|
|
36
|
+
HTML
|
|
37
|
+
|
|
38
|
+
Launchy.stub(:open)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def default_file_expectations
|
|
42
|
+
@temp_file.stub!(:path).and_return('page.html')
|
|
43
|
+
|
|
44
|
+
File.should_receive(:exist?).and_return true
|
|
45
|
+
File.should_receive(:new).and_return @temp_file
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "defaults" do
|
|
49
|
+
before do
|
|
50
|
+
default_file_expectations
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should create a new temporary file" do
|
|
54
|
+
@temp_file.should_receive(:write).with @html
|
|
55
|
+
Capybara.save_page @html, 'page.html'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should open the file in the browser" do
|
|
59
|
+
Capybara.should_receive(:open_in_browser).with('page.html')
|
|
60
|
+
Capybara.save_and_open_page @html, 'page.html'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "custom output path" do
|
|
65
|
+
before do
|
|
66
|
+
@custom_path = File.join('tmp', 'capybara')
|
|
67
|
+
@custom_name = File.join(@custom_path, 'page.html')
|
|
68
|
+
|
|
69
|
+
@temp_file.stub!(:path).and_return(@custom_name)
|
|
70
|
+
|
|
71
|
+
Capybara.should_receive(:save_and_open_page_path).at_least(:once).and_return(@custom_path)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "should create a new temporary file in the custom path" do
|
|
75
|
+
File.should_receive(:directory?).and_return true
|
|
76
|
+
File.should_receive(:exist?).and_return true
|
|
77
|
+
File.should_receive(:new).and_return @temp_file
|
|
78
|
+
|
|
79
|
+
@temp_file.should_receive(:write).with @html
|
|
80
|
+
Capybara.save_page @html, 'page.html'
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should open the file - in the custom path - in the browser" do
|
|
84
|
+
Capybara.should_receive(:open_in_browser).with(@custom_name)
|
|
85
|
+
Capybara.save_and_open_page @html, 'page.html'
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should be possible to configure output path" do
|
|
89
|
+
Capybara.should respond_to(:save_and_open_page_path)
|
|
90
|
+
default_setting = Capybara.save_and_open_page_path
|
|
91
|
+
lambda {
|
|
92
|
+
Capybara.save_and_open_page_path = File.join('tmp', 'capybara')
|
|
93
|
+
Capybara.save_and_open_page_path.should == File.join('tmp', 'capybara')
|
|
94
|
+
}.should_not raise_error
|
|
95
|
+
Capybara.save_and_open_page_path = default_setting
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe "rewrite_css_and_image_references" do
|
|
100
|
+
before do
|
|
101
|
+
default_file_expectations
|
|
102
|
+
@asset_root_dir = "/path/to/rails/public"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def mock_asset_root_with(directories)
|
|
106
|
+
@asset_root = Pathname.new(@asset_root_dir)
|
|
107
|
+
Capybara.should_receive(:asset_root).and_return @asset_root
|
|
108
|
+
|
|
109
|
+
dir = mock('asset_root mock dir')
|
|
110
|
+
Dir.should_receive(:new).with(@asset_root).and_return dir
|
|
111
|
+
|
|
112
|
+
dirents = [ '.', '..', 'file.html' ] + directories
|
|
113
|
+
dir.should_receive(:entries).and_return dirents
|
|
114
|
+
|
|
115
|
+
directories_regexp = directories.join('|')
|
|
116
|
+
FileTest.should_receive(:directory?) \
|
|
117
|
+
.at_least(dirents.size - 2).times \
|
|
118
|
+
.and_return { |dir|
|
|
119
|
+
dir =~ %r!#{@asset_root_dir}/(#{directories_regexp})$!
|
|
120
|
+
}
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def expected_html_for_asset_root_with(directories)
|
|
124
|
+
mock_asset_root_with(directories)
|
|
125
|
+
|
|
126
|
+
expected_html = @html.clone
|
|
127
|
+
if not directories.empty?
|
|
128
|
+
directories_regexp = directories.join('|')
|
|
129
|
+
expected_html.gsub!(/"(\/(#{directories_regexp})\/)/,
|
|
130
|
+
'"%s\1' % @asset_root_dir)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
return expected_html
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_with_directories(directories)
|
|
137
|
+
@temp_file.should_receive(:write) \
|
|
138
|
+
.with expected_html_for_asset_root_with(directories)
|
|
139
|
+
Capybara.save_page @html, 'page.html'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
context "asset_root contains some directories" do
|
|
143
|
+
it "should rewrite relative paths to absolute local paths" do
|
|
144
|
+
test_with_directories([ 'javascripts', 'images' ])
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
context "asset_root path contains no directories" do
|
|
149
|
+
it "should not rewrite any relative paths" do
|
|
150
|
+
test_with_directories([ ])
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
data/spec/server_spec.rb
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Capybara::Server do
|
|
4
|
+
|
|
5
|
+
it "should spool up a rack server" do
|
|
6
|
+
@app = proc { |env| [200, {}, "Hello Server!"]}
|
|
7
|
+
@server = Capybara::Server.new(@app).boot
|
|
8
|
+
|
|
9
|
+
@res = Net::HTTP.start(@server.host, @server.port) { |http| http.get('/') }
|
|
10
|
+
|
|
11
|
+
@res.body.should include('Hello Server')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should do nothing when no server given" do
|
|
15
|
+
running do
|
|
16
|
+
@server = Capybara::Server.new(nil).boot
|
|
17
|
+
end.should_not raise_error
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should bind to the specified host" do
|
|
21
|
+
Capybara.server_host = '0.0.0.0'
|
|
22
|
+
|
|
23
|
+
app = proc { |env| [200, {}, "Hello Server!"]}
|
|
24
|
+
server = Capybara::Server.new(app).boot
|
|
25
|
+
server.host.should == '0.0.0.0'
|
|
26
|
+
|
|
27
|
+
Capybara.server_host = nil
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should use specified port" do
|
|
31
|
+
Capybara.server_port = 22789
|
|
32
|
+
|
|
33
|
+
@app = proc { |env| [200, {}, "Hello Server!"]}
|
|
34
|
+
@server = Capybara::Server.new(@app).boot
|
|
35
|
+
|
|
36
|
+
@res = Net::HTTP.start(@server.host, 22789) { |http| http.get('/') }
|
|
37
|
+
@res.body.should include('Hello Server')
|
|
38
|
+
|
|
39
|
+
Capybara.server_port = nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should find an available port" do
|
|
43
|
+
@app1 = proc { |env| [200, {}, "Hello Server!"]}
|
|
44
|
+
@app2 = proc { |env| [200, {}, "Hello Second Server!"]}
|
|
45
|
+
|
|
46
|
+
@server1 = Capybara::Server.new(@app1).boot
|
|
47
|
+
@server2 = Capybara::Server.new(@app2).boot
|
|
48
|
+
|
|
49
|
+
@res1 = Net::HTTP.start(@server1.host, @server1.port) { |http| http.get('/') }
|
|
50
|
+
@res1.body.should include('Hello Server')
|
|
51
|
+
|
|
52
|
+
@res2 = Net::HTTP.start(@server2.host, @server2.port) { |http| http.get('/') }
|
|
53
|
+
@res2.body.should include('Hello Second Server')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should use the server if it already running" do
|
|
57
|
+
@app1 = proc { |env| [200, {}, "Hello Server!"]}
|
|
58
|
+
@app2 = proc { |env| [200, {}, "Hello Second Server!"]}
|
|
59
|
+
|
|
60
|
+
@server1a = Capybara::Server.new(@app1).boot
|
|
61
|
+
@server1b = Capybara::Server.new(@app1).boot
|
|
62
|
+
@server2a = Capybara::Server.new(@app2).boot
|
|
63
|
+
@server2b = Capybara::Server.new(@app2).boot
|
|
64
|
+
|
|
65
|
+
@res1 = Net::HTTP.start(@server1b.host, @server1b.port) { |http| http.get('/') }
|
|
66
|
+
@res1.body.should include('Hello Server')
|
|
67
|
+
|
|
68
|
+
@res2 = Net::HTTP.start(@server2b.host, @server2b.port) { |http| http.get('/') }
|
|
69
|
+
@res2.body.should include('Hello Second Server')
|
|
70
|
+
|
|
71
|
+
@server1a.port.should == @server1b.port
|
|
72
|
+
@server2a.port.should == @server2b.port
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Capybara::Session do
|
|
4
|
+
context 'with rack test driver' do
|
|
5
|
+
before do
|
|
6
|
+
@session = TestSessions::RackTest
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe '#driver' do
|
|
10
|
+
it "should be a rack test driver" do
|
|
11
|
+
@session.driver.should be_an_instance_of(Capybara::RackTest::Driver)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#mode' do
|
|
16
|
+
it "should remember the mode" do
|
|
17
|
+
@session.mode.should == :rack_test
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#click_link' do
|
|
22
|
+
it "should use data-method if available" do
|
|
23
|
+
@session.visit "/with_html"
|
|
24
|
+
@session.click_link "A link with data-method"
|
|
25
|
+
@session.body.should include('The requested object was deleted')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should not use data-method if option is false" do
|
|
29
|
+
@session.driver.options[:respect_data_method] = false
|
|
30
|
+
@session.visit "/with_html"
|
|
31
|
+
@session.click_link "A link with data-method"
|
|
32
|
+
@session.body.should include('Not deleted')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should use data-method if available even if it's capitalized" do
|
|
36
|
+
@session.visit "/with_html"
|
|
37
|
+
@session.click_link "A link with data-method capitalized"
|
|
38
|
+
@session.body.should include('The requested object was deleted')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
after do
|
|
42
|
+
@session.driver.options[:respect_data_method] = true
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "#attach_file" do
|
|
47
|
+
context "with multipart form" do
|
|
48
|
+
it "should submit an empty form-data section if no file is submitted" do
|
|
49
|
+
@session.visit("/form")
|
|
50
|
+
@session.click_button("Upload Empty")
|
|
51
|
+
@session.body.should include('Successfully ignored empty file field.')
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it_should_behave_like "session"
|
|
57
|
+
it_should_behave_like "session without javascript support"
|
|
58
|
+
it_should_behave_like "session with headers support"
|
|
59
|
+
it_should_behave_like "session with status code support"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Capybara::Session do
|
|
4
|
+
context 'with selenium driver' do
|
|
5
|
+
before do
|
|
6
|
+
@session = TestSessions::Selenium
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe '#driver' do
|
|
10
|
+
it "should be a selenium driver" do
|
|
11
|
+
@session.driver.should be_an_instance_of(Capybara::Selenium::Driver)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#mode' do
|
|
16
|
+
it "should remember the mode" do
|
|
17
|
+
@session.mode.should == :selenium
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it_should_behave_like "session"
|
|
22
|
+
it_should_behave_like "session with javascript support"
|
|
23
|
+
it_should_behave_like "session without headers support"
|
|
24
|
+
it_should_behave_like "session without status code support"
|
|
25
|
+
end
|
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
$:.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
|
|
6
|
+
require 'rspec'
|
|
7
|
+
require 'capybara'
|
|
8
|
+
|
|
9
|
+
RSpec.configure do |config|
|
|
10
|
+
config.before do
|
|
11
|
+
Capybara.configure do |config|
|
|
12
|
+
config.default_selector = :xpath
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Required here instead of in rspec_spec to avoid RSpec deprecation warning
|
|
18
|
+
require 'capybara/rspec'
|
|
19
|
+
|
|
20
|
+
require 'capybara/spec/driver'
|
|
21
|
+
require 'capybara/spec/session'
|
|
22
|
+
|
|
23
|
+
alias :running :lambda
|
|
24
|
+
|
|
25
|
+
Capybara.app = TestApp
|
|
26
|
+
Capybara.default_wait_time = 0 # less timeout so tests run faster
|
|
27
|
+
|
|
28
|
+
module TestSessions
|
|
29
|
+
RackTest = Capybara::Session.new(:rack_test, TestApp)
|
|
30
|
+
Selenium = Capybara::Session.new(:selenium, TestApp)
|
|
31
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
require 'capybara'
|
|
4
|
+
require 'capybara/util/timeout'
|
|
5
|
+
|
|
6
|
+
module Capybara
|
|
7
|
+
|
|
8
|
+
describe '.timeout' do
|
|
9
|
+
|
|
10
|
+
it "should return result of yield if it returns true value within timeout" do
|
|
11
|
+
Capybara.timeout { "hello" }.should == "hello"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should keep trying within timeout" do
|
|
15
|
+
count = 0
|
|
16
|
+
Capybara.timeout { count += 1; count == 5 ? count : nil }.should == 5
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should raise Capybara::TimeoutError if block fails to return true within timeout" do
|
|
20
|
+
running do
|
|
21
|
+
Capybara.timeout(0.1) { false }
|
|
22
|
+
end.should raise_error(::Capybara::TimeoutError)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
metadata
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bbc-capybara
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.1.2
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Jonas Nicklas
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-01-18 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: nokogiri
|
|
16
|
+
requirement: &2169433340 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 1.3.3
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *2169433340
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: mime-types
|
|
27
|
+
requirement: &2169432760 !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ! '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.16'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: *2169432760
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: bbc-selenium-webdriver
|
|
38
|
+
requirement: &2169432240 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ~>
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '1.0'
|
|
44
|
+
type: :runtime
|
|
45
|
+
prerelease: false
|
|
46
|
+
version_requirements: *2169432240
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: rack
|
|
49
|
+
requirement: &2169431580 !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ! '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 1.0.0
|
|
55
|
+
type: :runtime
|
|
56
|
+
prerelease: false
|
|
57
|
+
version_requirements: *2169431580
|
|
58
|
+
- !ruby/object:Gem::Dependency
|
|
59
|
+
name: rack-test
|
|
60
|
+
requirement: &2169430860 !ruby/object:Gem::Requirement
|
|
61
|
+
none: false
|
|
62
|
+
requirements:
|
|
63
|
+
- - ! '>='
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: 0.5.4
|
|
66
|
+
type: :runtime
|
|
67
|
+
prerelease: false
|
|
68
|
+
version_requirements: *2169430860
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: xpath
|
|
71
|
+
requirement: &2169430180 !ruby/object:Gem::Requirement
|
|
72
|
+
none: false
|
|
73
|
+
requirements:
|
|
74
|
+
- - ~>
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: 0.1.4
|
|
77
|
+
type: :runtime
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: *2169430180
|
|
80
|
+
- !ruby/object:Gem::Dependency
|
|
81
|
+
name: sinatra
|
|
82
|
+
requirement: &2169429700 !ruby/object:Gem::Requirement
|
|
83
|
+
none: false
|
|
84
|
+
requirements:
|
|
85
|
+
- - ! '>='
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: 0.9.4
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: *2169429700
|
|
91
|
+
- !ruby/object:Gem::Dependency
|
|
92
|
+
name: rspec
|
|
93
|
+
requirement: &2169429160 !ruby/object:Gem::Requirement
|
|
94
|
+
none: false
|
|
95
|
+
requirements:
|
|
96
|
+
- - ! '>='
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: 2.0.0
|
|
99
|
+
type: :development
|
|
100
|
+
prerelease: false
|
|
101
|
+
version_requirements: *2169429160
|
|
102
|
+
- !ruby/object:Gem::Dependency
|
|
103
|
+
name: launchy
|
|
104
|
+
requirement: &2169428400 !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ~>
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 2.0.4
|
|
110
|
+
type: :development
|
|
111
|
+
prerelease: false
|
|
112
|
+
version_requirements: *2169428400
|
|
113
|
+
- !ruby/object:Gem::Dependency
|
|
114
|
+
name: yard
|
|
115
|
+
requirement: &2169427720 !ruby/object:Gem::Requirement
|
|
116
|
+
none: false
|
|
117
|
+
requirements:
|
|
118
|
+
- - ! '>='
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: 0.5.8
|
|
121
|
+
type: :development
|
|
122
|
+
prerelease: false
|
|
123
|
+
version_requirements: *2169427720
|
|
124
|
+
- !ruby/object:Gem::Dependency
|
|
125
|
+
name: fuubar
|
|
126
|
+
requirement: &2169420300 !ruby/object:Gem::Requirement
|
|
127
|
+
none: false
|
|
128
|
+
requirements:
|
|
129
|
+
- - ! '>='
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 0.0.1
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: *2169420300
|
|
135
|
+
- !ruby/object:Gem::Dependency
|
|
136
|
+
name: cucumber
|
|
137
|
+
requirement: &2169419620 !ruby/object:Gem::Requirement
|
|
138
|
+
none: false
|
|
139
|
+
requirements:
|
|
140
|
+
- - ! '>='
|
|
141
|
+
- !ruby/object:Gem::Version
|
|
142
|
+
version: '0.10'
|
|
143
|
+
type: :development
|
|
144
|
+
prerelease: false
|
|
145
|
+
version_requirements: *2169419620
|
|
146
|
+
- !ruby/object:Gem::Dependency
|
|
147
|
+
name: rake
|
|
148
|
+
requirement: &2169419060 !ruby/object:Gem::Requirement
|
|
149
|
+
none: false
|
|
150
|
+
requirements:
|
|
151
|
+
- - ! '>='
|
|
152
|
+
- !ruby/object:Gem::Version
|
|
153
|
+
version: '0'
|
|
154
|
+
type: :development
|
|
155
|
+
prerelease: false
|
|
156
|
+
version_requirements: *2169419060
|
|
157
|
+
description: Capybara is an integration testing tool for rack based web applications.
|
|
158
|
+
It simulates how a user would interact with a website
|
|
159
|
+
email:
|
|
160
|
+
- jonas.nicklas@gmail.com
|
|
161
|
+
executables: []
|
|
162
|
+
extensions: []
|
|
163
|
+
extra_rdoc_files: []
|
|
164
|
+
files:
|
|
165
|
+
- lib/capybara/cucumber.rb
|
|
166
|
+
- lib/capybara/driver/base.rb
|
|
167
|
+
- lib/capybara/driver/node.rb
|
|
168
|
+
- lib/capybara/dsl.rb
|
|
169
|
+
- lib/capybara/node/actions.rb
|
|
170
|
+
- lib/capybara/node/base.rb
|
|
171
|
+
- lib/capybara/node/document.rb
|
|
172
|
+
- lib/capybara/node/element.rb
|
|
173
|
+
- lib/capybara/node/finders.rb
|
|
174
|
+
- lib/capybara/node/matchers.rb
|
|
175
|
+
- lib/capybara/node/simple.rb
|
|
176
|
+
- lib/capybara/query.rb
|
|
177
|
+
- lib/capybara/rack_test/browser.rb
|
|
178
|
+
- lib/capybara/rack_test/driver.rb
|
|
179
|
+
- lib/capybara/rack_test/form.rb
|
|
180
|
+
- lib/capybara/rack_test/node.rb
|
|
181
|
+
- lib/capybara/rails.rb
|
|
182
|
+
- lib/capybara/rspec/features.rb
|
|
183
|
+
- lib/capybara/rspec/matchers.rb
|
|
184
|
+
- lib/capybara/rspec.rb
|
|
185
|
+
- lib/capybara/selector.rb
|
|
186
|
+
- lib/capybara/selenium/driver.rb
|
|
187
|
+
- lib/capybara/selenium/node.rb
|
|
188
|
+
- lib/capybara/server.rb
|
|
189
|
+
- lib/capybara/session.rb
|
|
190
|
+
- lib/capybara/spec/driver.rb
|
|
191
|
+
- lib/capybara/spec/fixtures/capybara.jpg
|
|
192
|
+
- lib/capybara/spec/fixtures/test_file.txt
|
|
193
|
+
- lib/capybara/spec/public/jquery-ui.js
|
|
194
|
+
- lib/capybara/spec/public/jquery.js
|
|
195
|
+
- lib/capybara/spec/public/test.js
|
|
196
|
+
- lib/capybara/spec/session/all_spec.rb
|
|
197
|
+
- lib/capybara/spec/session/attach_file_spec.rb
|
|
198
|
+
- lib/capybara/spec/session/check_spec.rb
|
|
199
|
+
- lib/capybara/spec/session/choose_spec.rb
|
|
200
|
+
- lib/capybara/spec/session/click_button_spec.rb
|
|
201
|
+
- lib/capybara/spec/session/click_link_or_button_spec.rb
|
|
202
|
+
- lib/capybara/spec/session/click_link_spec.rb
|
|
203
|
+
- lib/capybara/spec/session/current_url_spec.rb
|
|
204
|
+
- lib/capybara/spec/session/fill_in_spec.rb
|
|
205
|
+
- lib/capybara/spec/session/find_button_spec.rb
|
|
206
|
+
- lib/capybara/spec/session/find_by_id_spec.rb
|
|
207
|
+
- lib/capybara/spec/session/find_field_spec.rb
|
|
208
|
+
- lib/capybara/spec/session/find_link_spec.rb
|
|
209
|
+
- lib/capybara/spec/session/find_spec.rb
|
|
210
|
+
- lib/capybara/spec/session/first_spec.rb
|
|
211
|
+
- lib/capybara/spec/session/has_button_spec.rb
|
|
212
|
+
- lib/capybara/spec/session/has_css_spec.rb
|
|
213
|
+
- lib/capybara/spec/session/has_field_spec.rb
|
|
214
|
+
- lib/capybara/spec/session/has_link_spec.rb
|
|
215
|
+
- lib/capybara/spec/session/has_select_spec.rb
|
|
216
|
+
- lib/capybara/spec/session/has_selector_spec.rb
|
|
217
|
+
- lib/capybara/spec/session/has_table_spec.rb
|
|
218
|
+
- lib/capybara/spec/session/has_text_spec.rb
|
|
219
|
+
- lib/capybara/spec/session/has_xpath_spec.rb
|
|
220
|
+
- lib/capybara/spec/session/headers.rb
|
|
221
|
+
- lib/capybara/spec/session/javascript.rb
|
|
222
|
+
- lib/capybara/spec/session/response_code.rb
|
|
223
|
+
- lib/capybara/spec/session/select_spec.rb
|
|
224
|
+
- lib/capybara/spec/session/text_spec.rb
|
|
225
|
+
- lib/capybara/spec/session/uncheck_spec.rb
|
|
226
|
+
- lib/capybara/spec/session/unselect_spec.rb
|
|
227
|
+
- lib/capybara/spec/session/within_spec.rb
|
|
228
|
+
- lib/capybara/spec/session.rb
|
|
229
|
+
- lib/capybara/spec/test_app.rb
|
|
230
|
+
- lib/capybara/spec/views/buttons.erb
|
|
231
|
+
- lib/capybara/spec/views/fieldsets.erb
|
|
232
|
+
- lib/capybara/spec/views/form.erb
|
|
233
|
+
- lib/capybara/spec/views/frame_one.erb
|
|
234
|
+
- lib/capybara/spec/views/frame_two.erb
|
|
235
|
+
- lib/capybara/spec/views/header_links.erb
|
|
236
|
+
- lib/capybara/spec/views/host_links.erb
|
|
237
|
+
- lib/capybara/spec/views/popup_one.erb
|
|
238
|
+
- lib/capybara/spec/views/popup_two.erb
|
|
239
|
+
- lib/capybara/spec/views/postback.erb
|
|
240
|
+
- lib/capybara/spec/views/tables.erb
|
|
241
|
+
- lib/capybara/spec/views/with_html.erb
|
|
242
|
+
- lib/capybara/spec/views/with_html_entities.erb
|
|
243
|
+
- lib/capybara/spec/views/with_js.erb
|
|
244
|
+
- lib/capybara/spec/views/with_scope.erb
|
|
245
|
+
- lib/capybara/spec/views/with_simple_html.erb
|
|
246
|
+
- lib/capybara/spec/views/within_frames.erb
|
|
247
|
+
- lib/capybara/spec/views/within_popups.erb
|
|
248
|
+
- lib/capybara/util/save_and_open_page.rb
|
|
249
|
+
- lib/capybara/util/timeout.rb
|
|
250
|
+
- lib/capybara/version.rb
|
|
251
|
+
- lib/capybara.rb
|
|
252
|
+
- spec/basic_node_spec.rb
|
|
253
|
+
- spec/capybara_spec.rb
|
|
254
|
+
- spec/driver/rack_test_driver_spec.rb
|
|
255
|
+
- spec/driver/selenium_driver_spec.rb
|
|
256
|
+
- spec/dsl_spec.rb
|
|
257
|
+
- spec/fixtures/selenium_driver_rspec_failure.rb
|
|
258
|
+
- spec/fixtures/selenium_driver_rspec_success.rb
|
|
259
|
+
- spec/rspec/features_spec.rb
|
|
260
|
+
- spec/rspec/matchers_spec.rb
|
|
261
|
+
- spec/rspec_spec.rb
|
|
262
|
+
- spec/save_and_open_page_spec.rb
|
|
263
|
+
- spec/server_spec.rb
|
|
264
|
+
- spec/session/rack_test_session_spec.rb
|
|
265
|
+
- spec/session/selenium_session_spec.rb
|
|
266
|
+
- spec/spec_helper.rb
|
|
267
|
+
- spec/timeout_spec.rb
|
|
268
|
+
- README.md
|
|
269
|
+
- History.txt
|
|
270
|
+
- License.txt
|
|
271
|
+
homepage: http://github.com/jnicklas/capybara
|
|
272
|
+
licenses: []
|
|
273
|
+
post_install_message:
|
|
274
|
+
rdoc_options: []
|
|
275
|
+
require_paths:
|
|
276
|
+
- lib
|
|
277
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
278
|
+
none: false
|
|
279
|
+
requirements:
|
|
280
|
+
- - ! '>='
|
|
281
|
+
- !ruby/object:Gem::Version
|
|
282
|
+
version: '0'
|
|
283
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
284
|
+
none: false
|
|
285
|
+
requirements:
|
|
286
|
+
- - ! '>='
|
|
287
|
+
- !ruby/object:Gem::Version
|
|
288
|
+
version: '0'
|
|
289
|
+
requirements: []
|
|
290
|
+
rubyforge_project: bbc-capybara
|
|
291
|
+
rubygems_version: 1.8.12
|
|
292
|
+
signing_key:
|
|
293
|
+
specification_version: 3
|
|
294
|
+
summary: Capybara aims to simplify the process of integration testing Rack applications,
|
|
295
|
+
such as Rails, Sinatra or Merb
|
|
296
|
+
test_files: []
|
|
297
|
+
has_rdoc:
|