Bla*_*man 6 controller rspec ruby-on-rails
我有一个失败的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
Run Code Online (Sandbox Code Playgroud)
当我运行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
Run Code Online (Sandbox Code Playgroud)
转到浏览器中的/ home /页面可以正常工作.
有没有办法找到失败的更详细的原因?
注意:
这是rails3,我使用的是rspec.
我也有capybara gem,并且搜索我的解决方案显示了对capybara的唯一引用是在我的gem和gem.lock文件中.
您可能不只是渲染页面,而是重定向。为了检查可能出了什么问题,我会在我的规范中做类似的事情:
response.should == 1
Run Code Online (Sandbox Code Playgroud)
以查看实际响应是什么。这将为您提供有关正在发生的事情的良好线索。
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           1846 次  |  
        
|   最近记录:  |