[rspec-users] getting controller specs to work on edge

Jeff Dean jeff at jefdean.com
Fri Apr 20 03:12:29 EDT 2007


I'm using edge spec, edge rspec_on_rails, edge rails.  I just switched to
edge and ran the translator tool and I'm trying to get everything to pass
again.  One of my issues is getting render back up and working for my
controller specs, here's an example:

describe "Requesting /users using GET" do
  controller_name :users

  setup do
    @user = mock_model(User)
    User.stub!(:find).and_return(@user)
  end

  it "should render index.rhtml" do
    response.should render_template('index')
    do_get
  end
end

When I run that via rake spec:controllers I get:

NoMethodError in 'Requesting /users using GET should render index.rhtml'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.first_render
.../vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb:12:in
`matches?'

Originally, after the translator, the "it" section was:

  it "should render index.rhtml" do
    controller.should render_template('index')
    do_get
  end

But that gave me

NoMethodError in 'Requesting /users using GET should render index.rhtml'
undefined method `rendered_file' for #<UsersController:0x31d93b0>
.../vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb:12:in
`matches?'

Can anyone see what I'm doing wrong??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070420/12e750eb/attachment.html 


More information about the rspec-users mailing list