ruby-on-rails-3 – rails rspec http基本认证测试
发布时间:2020-12-17 04:05:24 所属栏目:百科 来源:网络整理
导读:如何使用rspec2 amp ;;使用http basic auth测试登录到rails 3.1 app水豚? 我正在使用这个; describe "GET 'index'" do it "should be successful" do request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password") get 'index' r
如何使用rspec2& amp ;;使用http basic auth测试登录到rails 3.1 app水豚?
我正在使用这个; 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 解决方法
Capybara内置
Rack::Test.
因此,您可以在发出请求之前使用 basic_authorize 'username','password' get 'index' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |