[rspec-users] spec'in controllers request for nested routes

Andrew WC Brown omen.king at gmail.com
Mon Oct 8 13:07:51 EDT 2007


describe PlayersController, "handling GET /saltmines/games/1/players" do

  before do
    @game = mock_model(Game, :to_param => "1")
    @game.stub_association!(:players, :find => mock_model(Player))
  end

  def do_get
    get :index, :game_id => @game
  end

  it "should be successful" do
    do_get
    response.should be_success
  end

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


1)
ActiveRecord::RecordNotFound in 'PlayersController handling GET
/saltmines/games/1/players should be successful'
Couldn't find Game with ID=#<Spec::Mocks::Mock:0x2ffcde4>
/Volumes/EXTERNAL/web/omenking.ca/config/../app/controllers/players_controller.rb:5:in
`index'
/Volumes/EXTERNAL/web/omenking.ca/spec/controllers/players_controller_spec.rb:71:in
`do_get'
/Volumes/EXTERNAL/web/omenking.ca/spec/controllers/players_controller_spec.rb:75:
/Volumes/EXTERNAL/web/omenking.ca/spec/controllers/players_controller_spec.rb:63:

I'm passing teh game_id in the request shouldn't this be enough?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071008/92a66b9d/attachment.html 


More information about the rspec-users mailing list