ここでは、アプリケーション コントローラー ファイル (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
私のホームコントローラーのインデックスアクションのデフォルトテスト(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」とコメントして実行することもできますが、メソッドでそれらを機能させる方法があるかどうか知りたいです。
ありがとうございました!