如何使用rspec2測試登錄到使用http basic認證的rails 3.1應用程序& capybara?rails rspec http基本認證測試
我正在使用這個;
describe "GET 'index'" do
it "should be successful" do
request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
get 'index'
response.should be_success
end
end
但它給了我這個錯誤;
NoMethodError:
undefined method `env' for nil:NilClass
看到http://stackoverflow.com/questions/4329985/http-basic-auth-for-capybara – zetetic