RSPEC 失败并获取
这是失败的 rspec 代码:
require 'spec_helper'
describe MainMenuController do
describe "GET 'first_page'" do
it "should be successful" do
get 'first_page'
response.should be_success
end
end
end
这是控制器代码:
class MainMenuController < ApplicationController
def first_page
session[:page_step] = 1
redirect_to session[:page1]
end
end
规范错误是:
MainMenuController GET 'first_page' should be successful
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/main_menu_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
应用程序运行良好,没有问题,该错误可能是由 Rails 自动生成的 rspec 代码引起的。对这个问题有什么想法吗?谢谢。
Here is the failed rspec code:
require 'spec_helper'
describe MainMenuController do
describe "GET 'first_page'" do
it "should be successful" do
get 'first_page'
response.should be_success
end
end
end
Here is the controller code:
class MainMenuController < ApplicationController
def first_page
session[:page_step] = 1
redirect_to session[:page1]
end
end
The spec error is:
MainMenuController GET 'first_page' should be successful
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/main_menu_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
The app runs fine without problem and the error may be caused by the rspec code which is automatically generated by the rails. Any idea about the problem? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜匹配器正在寻找状态 200。
但是由于您重定向,它得到 301。
因此它失败了。
尝试:
你会有更多细节。
I guess the matcher is looking for a status 200.
But since you redirect, it gets 301.
Thus it fails.
Try:
You'd have some more details.