require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
describe "clicks_area" do
before do
@session = Webrat::TestSession.new
end
it "should use get by default" do
@session.response_body = <<-EOS
EOS
@session.should_receive(:get).with("/page", {})
@session.clicks_area "Berlin"
end
it "should assert valid response" do
@session.response_body = <<-EOS
EOS
@session.response_code = 404
lambda { @session.clicks_area "Berlin" }.should raise_error
end
it "should fail if the area doesn't exist" do
@session.response_body = <<-EOS
EOS
lambda {
@session.clicks_area "Missing area"
}.should raise_error
end
it "should not be case sensitive" do
@session.response_body = <<-EOS
EOS
@session.should_receive(:get).with("/page", {})
@session.clicks_area "berlin"
end
it "should follow relative links" do
@session.stub!(:current_url).and_return("/page")
@session.response_body = <<-EOS
EOS
@session.should_receive(:get).with("/page/sub", {})
@session.clicks_area "Berlin"
end
it "should follow fully qualified local links" do
@session.response_body = <<-EOS
EOS
@session.should_receive(:get).with("http://www.example.com/page", {})
@session.clicks_area "Berlin"
end
it "should follow query parameters" do
@session.response_body = <<-EOS
EOS
@session.should_receive(:get).with("/page?foo=bar", {})
@session.clicks_area "Berlin"
end
end