Skip to content

Commit

Permalink
Add Capybara example to Test Framework Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hardbap authored and cypher committed May 17, 2010
1 parent 1ff1c30 commit 82006c7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions testing.markdown
Expand Up @@ -301,6 +301,30 @@ From `Webrat`'s wiki where you'll find more [examples][].
end
end

### [Capybara][]

`Capybara` will use `Rack::Test` by default. You can use another driver, like
`Selenium`, by setting the default_driver.

require 'hello_world' # <-- your sinatra app
require 'capybara'
require 'capybara/dsl'
require 'test/unit'

class HelloWorldTest < Test::Unit::TestCase
include Capybara
# Capybara.default_driver = :selenium # <-- use Selenium driver

def setup
Capybara.app = Sinatra::Application.new
end

def test_it_works
visit '/'
assert page.has_content?('Hello World')
end
end

See Also
--------

Expand All @@ -320,3 +344,4 @@ more information on `get`, `post`, `put`, `delete` and friends.
[Rack::MockResponse]: http://rack.rubyforge.org/doc/classes/Rack/MockResponse.html
[Webrat]: http://github.com/brynary/webrat
[examples]: http://wiki.github.com/brynary/webrat/sinatra
[Capybara]: http://github.com/jnicklas/capybara

0 comments on commit 82006c7

Please sign in to comment.