README.rdoc in capybara-0.3.0 vs README.rdoc in capybara-0.3.5

- old
+ new

@@ -10,21 +10,27 @@ running your tests and currently comes bundled with rack-test, Culerity, Celerity and Selenium support built in. == Install: -Capybara is hosted on Gemcutter, install it with: +Install as a gem: sudo gem install capybara +On OSX you may have to install libffi, you can install it via MacPorts with: + + sudo port install libffi + == Development: * Source hosted at {GitHub}[http://github.com/jnicklas/capybara]. * Please direct questions, discussions at the {mailing list}[http://groups.google.com/group/ruby-capybara]. * Report issues on {GitHub Issues}[http://github.com/jnicklas/capybara/issues] -* Pull requests are very welcome! +Pull requests are very welcome! Make sure your patches are well tested, Capybara is +a testing tool after all. + == 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: @@ -108,11 +114,11 @@ Install celerity as noted above, make sure JRuby is in your path. Note that Culerity doesn't seem to be working under Ruby 1.9 at the moment. == The DSL -Capybara's DSL is inspired by Webrat. While backwards compatibility is retained +Capybara's DSL is inspired by Webrat. While backwards compatibility is retained in a lot of cases, there are certain important differences. Unlike in Webrat, all searches in Capybara are *case sensitive*. This is because Capybara heavily uses XPath, which doesn't support case insensitivity. @@ -187,11 +193,11 @@ certain elements, and working with and manipulating those elements. page.has_xpath?('//table/tr') page.has_css?('table tr.foo') page.has_content?('foo') - + You can use with RSpecs magic matchers: page.should have_xpath('//table/tr') page.should have_css('table tr.foo') page.should have_content('foo') @@ -204,11 +210,11 @@ You can also find specific elements, in order to manipulate them: find_field('First Name').value find_link('Hello').visible? find_button('Send').click - + find('//table/tr').click wait_for("//*[@id='overlay'").find("//h1").click all('a').each { |a| a[:href] } === Scripting @@ -274,10 +280,31 @@ fill_in 'Login', :with => 'user@example.com' fill_in 'Password', :with => 'password' end click_link 'Sign in' +== 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: + + require 'capybara' + require 'capybara/dsl' + + include Capybara + 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: + + 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: + + Capybara.run_server = false + == Using the sessions manually For ultimate control, you can instantiate and use a session manually. require 'capybara' @@ -294,16 +321,20 @@ Capybara does not try to guess what kind of selector you are going to give it, if you want to use CSS with your 'within' declarations for example, you'll need to do: within(:css, 'ul li') { ... } + find(:css, 'ul li').text + locate(:css, 'input#name').value Alternatively you can set the default selector to CSS, which may help if you are moving from Webrat and used CSS a lot, or simply generally prefer CSS: Capybara.default_selector = :css within('ul li') { ... } + find('ul li').text + locate('input#name').value == Gotchas: * Domain names (including subdomains) don't work under rack-test. Since it's a pain to set up subdomains for the other drivers anyway, you should consider an @@ -336,9 +367,18 @@ * Lenny Marks * Aaron Patterson * Dan Dofter * Thorbjørn Hermansen * Louis T. +* Stephan Hagemann +* Graham Ashton +* Joseph Wilk +* Matt Wynne +* Piotr Sarnacki +* Pavel Gabriel +* Bodaniel Jeanes +* Carl Porth +* Darrin Holst == License: (The MIT License)