这里是应用程序控制器文件(application_controller.rb)中的http基本身份验证
before_filter :authenticate
protected
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "username" && password == "password"
end
end
以及my home控制器索引操作的默认测试(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
由于身份验证方法,测试未运行.我可以 comments "before_filter:authenticate"来运行它们,但我想知道是否有办法让它们使用该方法.
非常感谢.