Andrew WC Brown
2007-Oct-08 17:07 UTC
[rspec-users] spec''in controllers request for nested routes
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
David Chelimsky
2007-Oct-08 17:11 UTC
[rspec-users] spec''in controllers request for nested routes
On 10/8/07, Andrew WC Brown <omen.king at gmail.com> wrote:> 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 => @gameRails will turn @game into an id internally, but not in a spec (or in a rails test). So this should work: get :index, :game_id => 1> 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? > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Andrew WC Brown
2007-Oct-08 17:24 UTC
[rspec-users] spec''in controllers request for nested routes
I had originally done so but I was getting the following: 1) ActiveRecord::RecordNotFound in ''PlayersController handling GET /saltmines/games/1/players should be successful'' Couldn''t find Game with ID=1 /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: On 10/8/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > On 10/8/07, Andrew WC Brown <omen.king at gmail.com> wrote: > > 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 > > Rails will turn @game into an id internally, but not in a spec (or in > a rails test). So this should work: > > get :index, :game_id => 1 > > > > 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? > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Monsterbox Productions putting small businesses on-line 1319 Victoria Avenue East Thunder Bay, Ontario P7C 1C3 Canada Andrew WC Brown web-developer and owner andrew at monsterboxpro.com P: 807-626-9009 F: 807-624-2705 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071008/c6f670bf/attachment.html
David Chelimsky
2007-Oct-08 17:26 UTC
[rspec-users] spec''in controllers request for nested routes
On 10/8/07, Andrew WC Brown <omen.king at gmail.com> wrote:> I had originally done so but I was getting the following: > > 1) > ActiveRecord::RecordNotFound in ''PlayersController handling GET > /saltmines/games/1/players should be successful'' > Couldn''t find Game with ID=1There''s something that your code is doing that is not being addressed in the spec. What do you suppose it might be, given this error.> /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: > > > On 10/8/07, David Chelimsky < dchelimsky at gmail.com> wrote: > > On 10/8/07, Andrew WC Brown < omen.king at gmail.com> wrote: > > > 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 > > > > Rails will turn @game into an id internally, but not in a spec (or in > > a rails test). So this should work: > > > > get :index, :game_id => 1 > > > > > > > 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? > > > > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Monsterbox Productions > putting small businesses on-line > > 1319 Victoria Avenue East > Thunder Bay, Ontario P7C 1C3 > Canada > > Andrew WC Brown > web-developer and owner > andrew at monsterboxpro.com > P: 807-626-9009 > F: 807-624-2705 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-Oct-08 17:26 UTC
[rspec-users] spec''in controllers request for nested routes
On 10/8/07, Andrew WC Brown <omen.king at gmail.com> wrote:> I had originally done so but I was getting the following: > > 1) > ActiveRecord::RecordNotFound in ''PlayersController handling GET > /saltmines/games/1/players should be successful'' > Couldn''t find Game with ID=1There''s something that your code is doing that is not being addressed in the spec. What do you suppose it might be, given this error.> /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: > > > On 10/8/07, David Chelimsky < dchelimsky at gmail.com> wrote: > > On 10/8/07, Andrew WC Brown < omen.king at gmail.com> wrote: > > > 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 > > > > Rails will turn @game into an id internally, but not in a spec (or in > > a rails test). So this should work: > > > > get :index, :game_id => 1 > > > > > > > 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? > > > > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Monsterbox Productions > putting small businesses on-line > > 1319 Victoria Avenue East > Thunder Bay, Ontario P7C 1C3 > Canada > > Andrew WC Brown > web-developer and owner > andrew at monsterboxpro.com > P: 807-626-9009 > F: 807-624-2705 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Andrew WC Brown
2007-Oct-08 17:43 UTC
[rspec-users] spec''in controllers request for nested routes
Ohhhhh.... Game.stub!(:find).and_return(@game) Of Course! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071008/491b6b69/attachment.html
David Chelimsky
2007-Oct-08 17:44 UTC
[rspec-users] spec''in controllers request for nested routes
On 10/8/07, Andrew WC Brown <omen.king at gmail.com> wrote:> Ohhhhh.... > > Game.stub!(:find).and_return(@game) > > Of Course!By George, I think he''s got it. Cheers, David> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >