Merge remote branch 'upstream/master'

This commit is contained in:
bodhi 2010-10-07 12:22:34 +11:00
commit 7322537335
7 changed files with 67 additions and 127 deletions

16
Gemfile
View File

@ -1,14 +1,4 @@
source 'http://gemcutter.org'
source :rubygems
gem 'rails', '3.0.0'
group :development, :test do
gem 'nokogiri'
gem 'xpath'
gem 'sinatra'
gem 'culerity'
gem 'selenium-webdriver'
gem 'launchy'
gem 'rspec-rails', '>= 2.0.0.beta.20'
gem 'cucumber-rails'
end
gem 'bundler', '~> 1.0'
gemspec

View File

@ -1,92 +1,37 @@
GEM
remote: http://gemcutter.org/
PATH
remote: .
specs:
abstract (1.0.0)
actionmailer (3.0.0)
actionpack (= 3.0.0)
mail (~> 2.2.5)
actionpack (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-mount (~> 0.6.12)
rack-test (~> 0.5.4)
tzinfo (~> 0.3.23)
activemodel (3.0.0)
activesupport (= 3.0.0)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
arel (~> 1.0.0)
tzinfo (~> 0.3.23)
activeresource (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
activesupport (3.0.0)
arel (1.0.1)
activesupport (~> 3.0.0)
builder (2.1.2)
capybara (0.3.9)
celerity (>= 0.7.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.27)
xpath (~> 0.1.1)
GEM
remote: http://rubygems.org/
specs:
celerity (0.8.2)
configuration (1.1.0)
cucumber (0.9.2)
builder (~> 2.1.2)
diff-lcs (~> 1.1.2)
gherkin (~> 2.2.5)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
cucumber-rails (0.3.2)
cucumber (>= 0.8.0)
culerity (0.2.12)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
ffi (0.6.3)
rake (>= 0.8.7)
ffi (0.6.3-java)
gherkin (2.2.8)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
gherkin (2.2.8-java)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
i18n (0.4.1)
json (1.4.6)
json (1.4.6-java)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
mail (2.2.6.1)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
mime-types (1.16)
nokogiri (1.4.3.1)
nokogiri (1.4.3.1-java)
weakling (>= 0.0.3)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
actionpack (= 3.0.0)
activerecord (= 3.0.0)
activeresource (= 3.0.0)
activesupport (= 3.0.0)
bundler (~> 1.0.0)
railties (= 3.0.0)
railties (3.0.0)
actionpack (= 3.0.0)
activesupport (= 3.0.0)
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
rspec (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
@ -98,8 +43,6 @@ GEM
rspec-mocks (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
rspec-rails (2.0.0.beta.22)
rspec (= 2.0.0.beta.22)
rubyzip (0.9.4)
selenium-webdriver (0.0.28)
ffi (>= 0.6.1)
@ -107,25 +50,27 @@ GEM
rubyzip
sinatra (1.0)
rack (>= 1.0)
term-ansicolor (1.0.5)
thor (0.14.3)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
weakling (0.0.4-java)
xpath (0.1.0)
xpath (0.1.1)
nokogiri (~> 1.3)
yard (0.6.1)
PLATFORMS
java
ruby
DEPENDENCIES
cucumber-rails
culerity
launchy
nokogiri
rails (= 3.0.0)
rspec-rails (>= 2.0.0.beta.20)
selenium-webdriver
sinatra
xpath
bundler (~> 1.0)
capybara!
celerity (>= 0.7.9)
culerity (>= 0.2.4)
launchy (>= 0.3.5)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
rspec (>= 2.0.0.beta.22)
selenium-webdriver (>= 0.0.27)
sinatra (>= 0.9.4)
xpath (~> 0.1.1)
yard (>= 0.5.8)

View File

@ -5,10 +5,10 @@
== Description:
Capybara aims to simplify the process of integration testing Rack applications,
such as Rails, Sinatra or Merb. It is inspired by and aims to replace Webrat as
a DSL for interacting with a web application. It is agnostic about the driver
running your tests and currently comes bundled with rack-test, Culerity,
Celerity and Selenium support built in. env.js support is available as the
such as Rails, Sinatra or Merb. Capybara simulates how a real user would
interact with a web application. It is agnostic about the driver running your
tests and currently comes bundled with rack-test, Culerity, Celerity and Selenium
support built in. env.js support is available as the
{capybara-envjs gem}[http://github.com/smparkes/capybara-envjs].
Online documentation is availbable
@ -41,11 +41,10 @@ Capybara uses bundler in development. To set up a development environment, simpl
== Using Capybara with Cucumber
Capybara is built to work nicely with Cucumber. The API is very similar to
Webrat, so if you know Webrat you should feel right at home. Support for
Capybara is built into cucumber-rails 0.2. In your Rails app, just run:
Capybara is built to work nicely with Cucumber. Support for Capybara is built into
cucumber-rails. In your Rails app, just run:
script/generate cucumber --capybara
rails generate cucumber:install --capybara
And everything should be set up and ready to go.
@ -225,19 +224,16 @@ to specific parts of the page:
Capybara makes it possible to restrict certain actions, such as interacting with
forms or clicking links and buttons, to within a specific area of the page. For
this purpose you can use the generic <tt>within</tt> method. Optionally you can
specify which kind of selector (CSS or XPath to use).
specify which kind of selector to use.
within("//li[@id='employee']") do
within("li#employee") do
fill_in 'Name', :with => 'Jimmy'
end
within(:css, "li#employee") do
within(:xpath, "//li[@id='employee']") do
fill_in 'Name', :with => 'Jimmy'
end
You can choose which kind of selector Capybara uses by default, by setting
<tt>Capybara.default_selector</tt>.
There are special methods for restricting the scope to a specific fieldset,
identified by either an id or the text of the fieldet's legend tag, and to a
specific table, identified by either id or text of the table's caption tag.
@ -295,8 +291,8 @@ is (the default is 2 seconds):
Be aware that because of this behaviour, the following two statements are *not*
equivalent, and you should *always* use the latter!
page.should_not have_xpath('//a')
page.should have_no_xpath('//a')
page.should_not have_xpath('a')
page.should have_no_xpath('a')
The former would incorrectly wait for the content to appear, since the
asynchronous process has not yet removed the element from the page, it would
@ -327,18 +323,23 @@ examples. Just load the DSL and include it anywhere:
== Calling remote servers
Normally Capybara expects to be testing an in-process Rack application, but you can also use it to talk to a web server running anywhere on the internets, by setting app_host:
Normally Capybara expects to be testing an in-process Rack application, but you
can also use it to talk to a web server running anywhere on the internets, by
setting app_host:
Capybara.current_driver = :selenium
Capybara.app_host = 'http://www.google.com'
...
visit('/')
Note that rack-test does not support running against a remote server. With drivers that support it, you can also visit any URL directly:
Note that rack-test does not support running against a remote server. With
drivers that support it, you can also visit any URL directly:
visit('http://www.google.com')
By default Capybara will try to boot a rack application automatically. You might want to switch off Capybara's rack server if you are running against a remote application:
By default Capybara will try to boot a rack application automatically. You
might want to switch off Capybara's rack server if you are running against a
remote application:
Capybara.run_server = false

View File

@ -29,7 +29,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("selenium-webdriver", [">= 0.0.27"])
s.add_runtime_dependency("rack", [">= 1.0.0"])
s.add_runtime_dependency("rack-test", [">= 0.5.4"])
s.add_runtime_dependency("xpath", [">= 0.1.0"])
s.add_runtime_dependency("xpath", ["~> 0.1.1"])
s.add_development_dependency("sinatra", [">= 0.9.4"])
s.add_development_dependency("rspec", [">= 2.0.0.beta.22"])

View File

@ -122,8 +122,7 @@ module Capybara
def all(*args)
options = if args.last.is_a?(Hash) then args.pop else {} end
selector = Capybara::Selector.normalize(*args)
results = XPath::HTML.wrap(selector).map do |path|
results = Capybara::Selector.normalize(*args).map do |path|
base.find(path)
end.flatten

View File

@ -91,7 +91,7 @@ module Capybara
# @return [Boolean] If the selector exists
#
def has_css?(path, options={})
has_xpath?(XPath::HTML.from_css(path), options)
has_xpath?(XPath.css(path), options)
end
##
@ -103,7 +103,7 @@ module Capybara
# @return [Boolean]
#
def has_no_css?(path, options={})
has_no_xpath?(XPath::HTML.from_css(path), options)
has_no_xpath?(XPath.css(path), options)
end
##

View File

@ -16,13 +16,18 @@ module Capybara
end
def normalize(name_or_locator, locator=nil)
if locator
xpath = if locator
all[name_or_locator.to_sym].call(locator)
else
selector = all.values.find { |s| s.match?(name_or_locator) }
selector ||= all[Capybara.default_selector]
selector.call(name_or_locator)
end
if xpath.respond_to?(:to_xpaths)
xpath.to_xpaths
else
[xpath.to_s].flatten
end
end
end
@ -43,5 +48,5 @@ module Capybara
end
Capybara::Selector.add(:xpath) { |xpath| xpath }
Capybara::Selector.add(:css) { |css| XPath::HTML.from_css(css) }
Capybara::Selector.add(:css) { |css| XPath.css(css) }
Capybara::Selector.add(:id, :for => Symbol) { |id| XPath.descendant(:*)[XPath.attr(:id) == id.to_s] }