[rspec-users] Need some help with a simple

chris anderson lists at ruby-forum.com
Mon Apr 7 17:14:06 EDT 2008


I can't figure out why this is failing.  It seems to have a hard time
assigning the @account.  I have spent way too long trying to figure this
out.

Thanks for any help.

-------
NoMethodError in 'StaffMembersController GET index should allow
anonymous users'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.staff_members
-------

++++++++++++++++
describe StaffMembersController do

  describe "GET index" do

    before :each do
      @account = mock_model(Account, :staff_members =>
[mock_model(StaffMember)])
      controller.stub!(:find_account_by_subdomain_or_url).and_return(@account)
    end

    # Authorization
    it "should allow anonymous users" do
      get :index
      response.should render_template(:index)
    end

  end
end
++++++++++++++++

StaffMembersController
++++++++++++++++
class StaffMembersController < ApplicationController
  before_filter :find_account_by_subdomain_or_url

  def index
    @staff_members = @account.staff_members
  end

end
+++++++++++++++
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list