capybara 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +21 -0
- data/README.md +7 -7
- data/lib/capybara/driver/base.rb +0 -4
- data/lib/capybara/driver/node.rb +4 -0
- data/lib/capybara/node/actions.rb +1 -1
- data/lib/capybara/node/finders.rb +1 -2
- data/lib/capybara/node/matchers.rb +1 -5
- data/lib/capybara/rack_test/browser.rb +2 -6
- data/lib/capybara/rack_test/driver.rb +0 -4
- data/lib/capybara/rack_test/node.rb +4 -0
- data/lib/capybara/rails.rb +5 -1
- data/lib/capybara/rspec.rb +0 -5
- data/lib/capybara/selenium/driver.rb +0 -4
- data/lib/capybara/selenium/node.rb +6 -1
- data/lib/capybara/session.rb +7 -12
- data/lib/capybara/spec/session/html_spec.rb +26 -3
- data/lib/capybara/spec/session/node_spec.rb +6 -0
- data/lib/capybara/spec/session/source_spec.rb +0 -12
- data/lib/capybara/spec/session/visit_spec.rb +15 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/dsl_spec.rb +2 -1
- data/spec/rack_test_spec.rb +2 -1
- data/spec/selenium_spec.rb +0 -1
- metadata +2 -2
data/History.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# master
|
2
|
+
|
3
|
+
### Changed
|
4
|
+
|
5
|
+
* Move the RackTest driver override with the `:respect_data_method` option
|
6
|
+
enabled from capybara/rspec to capybara/rails, so that it is enabled in
|
7
|
+
Rails projects that don't use RSpec. [Carlos Antonio da Silva]
|
8
|
+
* Source is now an alias for `body`. RackTest no longer returns modifications
|
9
|
+
to `body`. This basically codifies the behaviour which we've had for a while
|
10
|
+
anyway, and should have minimal impact for end users. It is important to
|
11
|
+
driver authors though. [Jonas Nicklas]
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
* Visiting relative URLs when `app_host` is set and no server is running works
|
16
|
+
as expected. [Jonas Nicklas]
|
17
|
+
* `fill_in` works properly under Selenium again when the caret is not at the
|
18
|
+
end of the field before the method is called. [Douwe Maan, Jonas Nicklas, Jari
|
19
|
+
Bakken]
|
20
|
+
* `attach_file` can once again be given a Pathname [Jake Goulding]
|
21
|
+
|
1
22
|
# Version 2.0.0
|
2
23
|
|
3
24
|
Release date: 2012-11-05
|
data/README.md
CHANGED
@@ -88,16 +88,15 @@ Load RSpec 2.x support by adding the following line (typically to your
|
|
88
88
|
require 'capybara/rspec'
|
89
89
|
```
|
90
90
|
|
91
|
-
If you are using Rails, put your Capybara specs in `spec/
|
92
|
-
`spec/integration`.
|
91
|
+
If you are using Rails, put your Capybara specs in `spec/features`.
|
93
92
|
|
94
93
|
If you are not using Rails, tag all the example groups in which you want to use
|
95
|
-
Capybara with `:type => :
|
94
|
+
Capybara with `:type => :feature`.
|
96
95
|
|
97
96
|
You can now write your specs like so:
|
98
97
|
|
99
98
|
```ruby
|
100
|
-
describe "the signup process", :type => :
|
99
|
+
describe "the signup process", :type => :feature do
|
101
100
|
before :each do
|
102
101
|
User.make(:email => 'user@example.com', :password => 'caplin')
|
103
102
|
end
|
@@ -140,7 +139,7 @@ feature "Signing up" do
|
|
140
139
|
end
|
141
140
|
|
142
141
|
given(:other_user) { User.make(:email => 'other@example.com', :password => 'rous') }
|
143
|
-
|
142
|
+
|
144
143
|
scenario "Signing in as another user" do
|
145
144
|
within("#session") do
|
146
145
|
fill_in 'Login', :with => other_user.email
|
@@ -151,8 +150,9 @@ feature "Signing up" do
|
|
151
150
|
end
|
152
151
|
```
|
153
152
|
|
154
|
-
`feature` is in fact just an alias for `describe ..., :type => :
|
155
|
-
`background` is an alias for `before`, `scenario` for `it`, and
|
153
|
+
`feature` is in fact just an alias for `describe ..., :type => :feature`,
|
154
|
+
`background` is an alias for `before`, `scenario` for `it`, and
|
155
|
+
`given`/`given!` aliases for `let`/`let!`, respectively.
|
156
156
|
|
157
157
|
## Using Capybara with Test::Unit
|
158
158
|
|
data/lib/capybara/driver/base.rb
CHANGED
data/lib/capybara/driver/node.rb
CHANGED
@@ -138,7 +138,7 @@ module Capybara
|
|
138
138
|
# @param [String] path The path of the file that will be attached, or an array of paths
|
139
139
|
#
|
140
140
|
def attach_file(locator, path)
|
141
|
-
(
|
141
|
+
Array(path).each do |p|
|
142
142
|
raise Capybara::FileNotFound, "cannot attach file, #{p} does not exist" unless File.exist?(p.to_s)
|
143
143
|
end
|
144
144
|
find(:file_field, locator).set(path)
|
@@ -5,7 +5,7 @@ module Capybara
|
|
5
5
|
##
|
6
6
|
#
|
7
7
|
# Find an {Capybara::Element} based on the given arguments. +find+ will raise an error if the element
|
8
|
-
# is not found.
|
8
|
+
# is not found.
|
9
9
|
#
|
10
10
|
# If the driver is capable of executing JavaScript, +find+ will wait for a set amount of time
|
11
11
|
# and continuously retry finding the element until either the element is found or the time
|
@@ -19,7 +19,6 @@ module Capybara
|
|
19
19
|
# page.find('li', :text => 'Quox').click_link('Delete')
|
20
20
|
#
|
21
21
|
# @param (see Capybara::Node::Finders#all)
|
22
|
-
# @option options [String] :message An error message in case the element can't be found
|
23
22
|
# @return [Capybara::Element] The found element
|
24
23
|
# @raise [Capybara::ElementNotFound] If the element can't be found before time expires
|
25
24
|
#
|
@@ -76,19 +76,15 @@ class Capybara::RackTest::Browser
|
|
76
76
|
@dom = nil
|
77
77
|
end
|
78
78
|
|
79
|
-
def html
|
80
|
-
dom.to_xml
|
81
|
-
end
|
82
|
-
|
83
79
|
def dom
|
84
|
-
@dom ||= Nokogiri::HTML(
|
80
|
+
@dom ||= Nokogiri::HTML(html)
|
85
81
|
end
|
86
82
|
|
87
83
|
def find(selector)
|
88
84
|
dom.xpath(selector).map { |node| Capybara::RackTest::Node.new(self, node) }
|
89
85
|
end
|
90
86
|
|
91
|
-
def
|
87
|
+
def html
|
92
88
|
last_response.body
|
93
89
|
rescue Rack::Test::Error
|
94
90
|
""
|
data/lib/capybara/rails.rb
CHANGED
@@ -4,7 +4,7 @@ require 'capybara/dsl'
|
|
4
4
|
Capybara.app = Rack::Builder.new do
|
5
5
|
map "/" do
|
6
6
|
if Rails.version.to_f >= 3.0
|
7
|
-
run Rails.application
|
7
|
+
run Rails.application
|
8
8
|
else # Rails 2
|
9
9
|
use Rails::Rack::Static
|
10
10
|
run ActionController::Dispatcher.new
|
@@ -15,3 +15,7 @@ end.to_app
|
|
15
15
|
Capybara.asset_root = Rails.root.join('public')
|
16
16
|
Capybara.save_and_open_page_path = Rails.root.join('tmp/capybara')
|
17
17
|
|
18
|
+
# Override default rack_test driver to respect data-method attributes.
|
19
|
+
Capybara.register_driver :rack_test do |app|
|
20
|
+
Capybara::RackTest::Driver.new(app, :respect_data_method => true)
|
21
|
+
end
|
data/lib/capybara/rspec.rb
CHANGED
@@ -32,7 +32,8 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
|
32
32
|
path_names = value.to_s.empty? ? [] : value
|
33
33
|
native.send_keys(*path_names)
|
34
34
|
elsif tag_name == 'textarea' or tag_name == 'input'
|
35
|
-
|
35
|
+
driver.browser.execute_script "arguments[0].value = ''", native
|
36
|
+
native.send_keys(value.to_s)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -75,6 +76,10 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
|
75
76
|
native.find_elements(:xpath, locator).map { |n| self.class.new(driver, n) }
|
76
77
|
end
|
77
78
|
|
79
|
+
def ==(other)
|
80
|
+
native == other.native
|
81
|
+
end
|
82
|
+
|
78
83
|
private
|
79
84
|
|
80
85
|
# a reference to the select node if this is an option node
|
data/lib/capybara/session.rb
CHANGED
@@ -105,15 +105,8 @@ module Capybara
|
|
105
105
|
def html
|
106
106
|
driver.html
|
107
107
|
end
|
108
|
-
|
109
|
-
|
110
|
-
#
|
111
|
-
# @return [String] HTML source of the document, before being modified by JavaScript.
|
112
|
-
#
|
113
|
-
def source
|
114
|
-
driver.source
|
115
|
-
end
|
116
|
-
alias_method :body, :source
|
108
|
+
alias_method :body, :html
|
109
|
+
alias_method :source, :html
|
117
110
|
|
118
111
|
##
|
119
112
|
#
|
@@ -170,10 +163,12 @@ module Capybara
|
|
170
163
|
def visit(url)
|
171
164
|
@touched = true
|
172
165
|
|
166
|
+
if url !~ /^http/ and Capybara.app_host
|
167
|
+
url = Capybara.app_host + url.to_s
|
168
|
+
end
|
169
|
+
|
173
170
|
if @server
|
174
|
-
unless url =~ /^http/
|
175
|
-
url = (Capybara.app_host || "http://#{@server.host}:#{@server.port}") + url.to_s
|
176
|
-
end
|
171
|
+
url = "http://#{@server.host}:#{@server.port}" + url.to_s unless url =~ /^http/
|
177
172
|
|
178
173
|
if Capybara.always_include_port
|
179
174
|
uri = URI.parse(url)
|
@@ -1,8 +1,5 @@
|
|
1
1
|
Capybara::SpecHelper.spec '#html' do
|
2
2
|
it "should return the unmodified page body" do
|
3
|
-
# html and body should be aliased, but we can't just check for
|
4
|
-
# method(:html) == method(:body) because these shared examples get run
|
5
|
-
# against the DSL, which uses forwarding methods. So we test behavior.
|
6
3
|
@session.visit('/')
|
7
4
|
@session.html.should include('Hello world!')
|
8
5
|
end
|
@@ -13,3 +10,29 @@ Capybara::SpecHelper.spec '#html' do
|
|
13
10
|
@session.html.should_not include('This is text')
|
14
11
|
end
|
15
12
|
end
|
13
|
+
|
14
|
+
Capybara::SpecHelper.spec '#source' do
|
15
|
+
it "should return the unmodified page source" do
|
16
|
+
@session.visit('/')
|
17
|
+
@session.source.should include('Hello world!')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return the current state of the page", :requires => [:js] do
|
21
|
+
@session.visit('/with_js')
|
22
|
+
@session.source.should include('I changed it')
|
23
|
+
@session.source.should_not include('This is text')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Capybara::SpecHelper.spec '#body' do
|
28
|
+
it "should return the unmodified page source" do
|
29
|
+
@session.visit('/')
|
30
|
+
@session.body.should include('Hello world!')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return the current state of the page", :requires => [:js] do
|
34
|
+
@session.visit('/with_js')
|
35
|
+
@session.body.should include('I changed it')
|
36
|
+
@session.body.should_not include('This is text')
|
37
|
+
end
|
38
|
+
end
|
@@ -65,6 +65,12 @@ Capybara::SpecHelper.spec "node" do
|
|
65
65
|
@session.first('//input').set('gorilla')
|
66
66
|
@session.first('//input').value.should == 'gorilla'
|
67
67
|
end
|
68
|
+
|
69
|
+
it "should fill the field even if the caret was not at the end", :requires => [:js] do
|
70
|
+
@session.execute_script("var el = document.getElementById('test_field'); el.focus(); el.setSelectionRange(0, 0);")
|
71
|
+
@session.first('//input').set('')
|
72
|
+
@session.first('//input').value.should == ''
|
73
|
+
end
|
68
74
|
end
|
69
75
|
|
70
76
|
describe "#tag_name" do
|
@@ -1,12 +0,0 @@
|
|
1
|
-
Capybara::SpecHelper.spec '#source' do
|
2
|
-
it "should return the unmodified page source" do
|
3
|
-
@session.visit('/')
|
4
|
-
@session.source.should include('Hello world!')
|
5
|
-
end
|
6
|
-
|
7
|
-
it "should return the original, unmodified source of the page", :requires => [:js, :source] do
|
8
|
-
@session.visit('/with_js')
|
9
|
-
@session.send(method).should include('This is text')
|
10
|
-
@session.send(method).should_not include('I changed it')
|
11
|
-
end
|
12
|
-
end
|
@@ -43,6 +43,21 @@ Capybara::SpecHelper.spec '#visit' do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
context "without a server", :requires => [:server] do
|
47
|
+
it "should respect `app_host`" do
|
48
|
+
serverless_session = Capybara::Session.new(@session.mode, nil)
|
49
|
+
Capybara.app_host = "http://#{@session.server.host}:#{@session.server.port}"
|
50
|
+
serverless_session.visit("/foo")
|
51
|
+
serverless_session.should have_content("Another World")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should visit a fully qualified URL" do
|
55
|
+
serverless_session = Capybara::Session.new(@session.mode, nil)
|
56
|
+
serverless_session.visit("http://#{@session.server.host}:#{@session.server.port}/foo")
|
57
|
+
serverless_session.should have_content("Another World")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
46
61
|
it "should send no referer when visiting a page" do
|
47
62
|
@session.visit '/get_referer'
|
48
63
|
@session.should have_content 'No referer'
|
data/lib/capybara/version.rb
CHANGED
data/spec/dsl_spec.rb
CHANGED
data/spec/rack_test_spec.rb
CHANGED
data/spec/selenium_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|