この次の Controller テストは失敗しており、その理由がわかりません。
describe "GET 'index'" do
before(:each) do
@outings = FactoryGirl.create_list(:outing, 30)
@user = FactoryGirl.create(:user)
end
it "should be successful" do
get :index
response.should be_success
end
end
Rspec は (あまり役に立たない) エラーを出します:
Failure/Error: response.should be_success
expected success? to return true, got false
実際のコントローラーのコードも次のとおりです。
def index
if @user
@outings = Outing.where(:user_id => @user.id)
@outing_invites = OutingGuest.where(:user_id => @user.id)
else
flash[:warning] = "You must log in to view your Outings!"
redirect_to root_path
end
end
テストが失敗する原因を知っている人はいますか? Outing Controller の条件と関係があるのではないかと思いますが、パスするテストがどのようになるかはわかりません...