cnantais
2007-Sep-27 18:47 UTC
[rspec-users] rspec_on_rails: controller method not getting called
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
--
View this message in context:
http://www.nabble.com/rspec_on_rails%3A-controller-method-not-getting-called-tf4530269.html#a12927783
Sent from the rspec-users mailing list archive at Nabble.com.
cnantais
2007-Sep-27 19:29 UTC
[rspec-users] rspec_on_rails: controller method not getting called
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
>
>
--
View this message in context:
http://www.nabble.com/rspec_on_rails%3A-controller-method-not-getting-called-tf4530269.html#a12928446
Sent from the rspec-users mailing list archive at Nabble.com.
Apparently Analagous Threads
- How to write a test for validates_uniqueness_of
- reusable specs - almost there
- Failure trying to test ApplicationController
- reloading include-modules inside controller not working
- (BUG in svn/trunk?) - superclass mismatch for any subclass of ApplicationController