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.
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.