2017. 4. 1. 02:14ㆍ개발/팁
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
# 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
'개발 > 팁' 카테고리의 다른 글
html5sec (0) | 2017.04.01 |
---|---|
페이스북 컬러 (0) | 2017.01.04 |
워드 프레스 암호 방식과 업데이트 (0) | 2015.09.28 |
CSS Wishlist (0) | 2011.12.21 |
Internet Explorer 8 검색 상자 제거하기 (0) | 2011.12.17 |