Created
November 28, 2012 04:04
Revisions
-
mattconnolly revised this gist
Nov 28, 2012 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,3 +27,10 @@ def http_login config.include AuthRequestHelper, :type => :request config.include AuthHelper, :type => :controller end # request specs need to explicitly pass the @env parameter along, eg: describe "some request" do http_login # or put this in a before :all GET '/path', {}, @env end -
mattconnolly created this gist
Nov 28, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ module AuthHelper def http_login user = 'username' pw = 'password' request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw) end end module AuthRequestHelper # # pass the @env along with your request, eg: # # GET '/labels', {}, @env # def http_login @env ||= {} user = 'username' pw = 'password' @env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw) end end # then in Rspec support: RSpec.configure do |config| config.include AuthRequestHelper, :type => :request config.include AuthHelper, :type => :controller end