« Return to Thread: rspec_on_rails: controller method not getting called

Re: rspec_on_rails: controller method not getting called

by cnantais :: Rate this Message:

Reply to Author | View in Thread

I figured it out.  

By doing this session sanity check in the spec (as recommended by dchelimsky):
    sess = session
    get 'index'
    sess.should equal(session)

I was able to see that a 'Please log in' redirect was preventing index from getting called.

Chad

cnantais wrote:
In my rspec_on_rails controlle rspec, I have this:

require File.dirname(__FILE__) + '/../spec_helper'

describe FooController, "with a foo" do
  it "should be false" do
    get 'index'
    assigns[:foo].should be_false
  end
end

In my controller I have this:

class FooController < ApplicationController
  def index
    @foo = FALSE
  end
end

But the result of running the spec is:
1)
'FooController should be false' FAILED
expected false, got nil

It seems I can give any argument to `get`in the description and it won't complain that the method is missing, so I suppose this means that the `get` in the description is not calling my 'index' method.  Any advice?

I'm using the latest RSpec and rspec_on_rails, ruby 1.8.6, Rails 1.2.3.
 
Thanks,

Chad

 « Return to Thread: rspec_on_rails: controller method not getting called