capybara-webkit/spec/driver_spec.rb

35 lines
823 B
Ruby
Raw Normal View History

2011-02-19 03:53:06 +00:00
require 'spec_helper'
require 'capybara/driver/webkit'
describe Capybara::Driver::Webkit do
let(:hello_app) do
lambda do |env|
body = <<-HTML
<html><body>
<script type="text/javascript">
document.write("he" + "llo");
</script>
</body></html>
HTML
[200,
{ 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
[body]]
end
end
subject { Capybara::Driver::Webkit.new(hello_app) }
after { subject.reset! }
it "finds content after loading a URL" do
subject.visit("/hello")
subject.find("//*[contains(., 'hello')]").should_not be_empty
end
it "has an empty page after reseting" do
subject.visit("/")
subject.reset!
subject.find("//*[contains(., 'hello')]").should be_empty
end
end