bakineggs (owner)

Revisions

gist: 75044 Download_button fork
public
Public Clone URL: git://gist.github.com/75044.git
Embed All Files: show embed
spec/public/basic_auth_spec.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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_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("/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"})
    click_button
  end
 
  it "should be present in GET requests" do
    webrat_session.should_receive(:get).with("/", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"})
    get("/")
  end
end