webrat/spec/public/basic_auth_spec.rb

25 lines
703 B
Ruby

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
describe "Basic Auth HTTP headers" do
before do
basic_auth('user', 'secret')
end
it "should be present in visit" do
webrat_session.should_receive(:get).with("http://www.example.com/", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"})
visit("/")
end
it "should be present in form submits" do
with_html <<-HTML
<html>
<form method="post" action="/form1">
<input type="submit" />
</form>
</html>
HTML
webrat_session.should_receive(:post).with("http://www.example.com/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"})
click_button
end
end