我有一个user_controller_spec.rb失败,我不知道为什么。帮助追踪控制器规格失败的原因
require 'spec_helper'
describe UsersController do
describe "GET 'index'" do
it "should be successful" do
get 'index'
response.should be_success
end
end
end
当我运行rspec的,它说:
Failures:
1) UsersController GET 'index' should be successful
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/users_controller_spec.rb:8
Finished in 0.17047 seconds
1 example, 1 failure
要在浏览器中的/ home /页工作正常。
有没有办法得到更详细的原因为什么它失败?
注:
这是Rails3中,和我使用RSpec的。
我也有水豚宝石,并搜索我的解决方案显示只有参考水豚是在我的宝石和gem.lock文件。
确定它现在工作谢谢(固定的东西,这是重定向),但总是失败,如果我做response.should == 1它是做什么的? – Blankman 2011-05-18 21:31:39
是的,这个失败的目的:)你只是用它来检查你得到的实际价值是什么(它会说像预期的东西:成功,得到了:重定向。 – Spyros 2011-05-18 21:36:45