这是我的应用控制器文件(application_controller.rb)中的HTTP基本身份验证。
测试无法运行是因为身份验证方法的问题。我可以注释掉"before_filter :authenticate"来运行它们,但我想知道是否有办法让它们与该方法一起工作。
谢谢!
before_filter :authenticate
protected
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "username" && password == "password"
end
end
和我的主页控制器的索引操作的默认测试(spec/controllers/home_controller_spec.rb)
require 'spec_helper'
describe HomeController do
describe "GET 'index'" do
it "should be successful" do
get 'index'
response.should be_success
end
end
测试无法运行是因为身份验证方法的问题。我可以注释掉"before_filter :authenticate"来运行它们,但我想知道是否有办法让它们与该方法一起工作。
谢谢!