Skip to content

Instantly share code, notes, and snippets.

@bernd
Created October 6, 2011 14:55
Show Gist options
  • Save bernd/1267601 to your computer and use it in GitHub Desktop.
Save bernd/1267601 to your computer and use it in GitHub Desktop.
Simple test with a capybara server.
require 'open-uri'
require 'capybara/rspec'
app = lambda do |env|
[200, {'Content-Type' => 'text/plain'}, ['Hello rat!']]
end
Capybara.app = app
server = Capybara::Server.new(Capybara.app).boot
url = "http://#{server.host}:#{server.port}"
puts "Server started. (#{url})"
describe "test local server" do
it "returns 'Hello rat!'" do
open(url).read.should =~ %r{Hello rat!}
end
end
@bernd
Copy link
Author

bernd commented Oct 6, 2011

Execute with 'rspec capy-test.rb'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment