[rspec-users] new syntax question and mocking HTTP_AUTHORIZATION

oren orengolan at gmail.com
Wed Oct 20 22:56:04 EDT 2010

I am specing a sinatra app.

it "should send non-valid user to /login" do
  get '/'
  last_response.headers['Location'].should == '/reports'

this is working fine but I would like to know how to convert it to the
new syntax or if there is a better way to do that.

before(:each) { get '/' }
subject { last_response }

its(:status) {should == 302}
require 'ap'
its(:headers) {should include('/login')}

another question:

   it "should send valid user to /reports" do
        get '/', { 'HTTP_AUTHORIZATION' => 'Basic
c2cvbGFuOmFBITExMQ==' }
        last_response.headers['Location'].should == '/reports'

when i debug my method I see that request.env["HTTP_AUTHORIZATION"] is
so the header was not sent with it. how to mock it?


More information about the rspec-users mailing list