1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00
capybara-webkit/spec/driver_spec.rb

43 lines
1.1 KiB
Ruby
Raw Normal View History

2011-02-18 22:53:06 -05: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">
2011-02-25 00:15:08 -05:00
document.write("<p id='greeting'>he" + "llo</p>");
2011-02-18 22:53:06 -05:00
</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) }
before { subject.visit("/hello") }
2011-02-18 22:53:06 -05:00
after { subject.reset! }
it "finds content after loading a URL" do
subject.find("//*[contains(., 'hello')]").should_not be_empty
end
it "has an empty page after reseting" do
subject.reset!
subject.find("//*[contains(., 'hello')]").should be_empty
end
it "raises an error for an invalid xpath query" do
expect { subject.find("totally invalid salad") }.
to raise_error(Capybara::Driver::Webkit::WebkitError, /xpath/i)
end
2011-02-25 00:15:08 -05:00
it "returns an attribute's value" do
subject.find("//p").first["id"].should == "greeting"
end
2011-02-18 22:53:06 -05:00
end