I''m looking for a working example of a put :update on a controller. The documentation online avoids the update function. Any help pointing to this example would be great. Trying to get to 100% coverage...can''t make it without update :) Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080204/71f37d1d/attachment.html
David Chelimsky
2008-Feb-05 07:02 UTC
[rspec-users] rspec - rails put :update any examples
On Feb 4, 2008 9:44 PM, Brian Rowe <brianmrowe at 7effect.com> wrote:> I''m looking for a working example of a put :update on a controller. The > documentation online avoids the update function. > > Any help pointing to this example would be great. Trying to get to 100% > coverage...can''t make it without update :)This is what I do: it "should replace foo with bar partial" do page = mock("page") page.should_receive(:replace_html).with(''foo'', :partial => ''bar'') controller.expect_render(:update).and_yield(page) do_post end HTH, David> > Brian > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David, I tried doing this, and I get an exception. Here''s a pastie of the error, controller, controller_spec: http://pastie.caboo.se/148021 On Feb 5, 2008 2:02 AM, David Chelimsky <dchelimsky at gmail.com> wrote:> it "should replace foo with bar partial" do > page = mock("page") > page.should_receive(:replace_html).with(''foo'', :partial => ''bar'') > controller.expect_render(:update).and_yield(page) > do_post > end > > HTH, > David > > > > > Brian > > > > > > _______________________________________________ > > 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 >-- http://www.coreyhaines.com The Internet''s Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080205/91031d1a/attachment.html
And, of course, here are my versions: Ruby 1.8.6 Rails 2.0.2 Zentest 3.8 RSpec (I believe 1.1.2) On Feb 5, 2008 7:42 PM, Corey Haines <coreyhaines at gmail.com> wrote:> David, I tried doing this, and I get an exception. Here''s a pastie of the > error, controller, controller_spec: http://pastie.caboo.se/148021 > > > On Feb 5, 2008 2:02 AM, David Chelimsky <dchelimsky at gmail.com> wrote: > > > it "should replace foo with bar partial" do > > page = mock("page") > > page.should_receive(:replace_html).with(''foo'', :partial => ''bar'') > > controller.expect_render(:update).and_yield(page) > > do_post > > end > > > > HTH, > > David > > > > > > > > Brian > > > > > > > > > _______________________________________________ > > > 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 > > > > > > -- > http://www.coreyhaines.com > The Internet''s Premiere source of information about Corey Haines-- http://www.coreyhaines.com The Internet''s Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080205/f6bd8800/attachment.html
David Chelimsky
2008-Feb-06 02:30 UTC
[rspec-users] rspec - rails put :update any examples
On Feb 5, 2008 6:42 PM, Corey Haines <coreyhaines at gmail.com> wrote:> David, I tried doing this, and I get an exception. Here''s a pastie of the > error, controller, controller_spec: http://pastie.caboo.se/148021You''ve got page[:coupon_list], not just page. So what you need to mock is this: page = mock("page") page.should_receive(:[]).with(:coupon_list).and_return(page) page.should_receive(:replace_html).with(:partial => "coupon_list") That''s starting to get a bit brittle, but that''s what you get for mixing all that view logic in your controllers. It''s the Rails Way, but it comes with a price if you want this level of coverage and isolation. FWIW, David> > > > On Feb 5, 2008 2:02 AM, David Chelimsky <dchelimsky at gmail.com> wrote: > > > it "should replace foo with bar partial" do > > page = mock("page") > > page.should_receive(:replace_html).with(''foo'', :partial => ''bar'') > > controller.expect_render(:update).and_yield(page) > > do_post > > end > > > > HTH, > > David > > > > > > > > Brian > > > > > > > > > _______________________________________________ > > > 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 > > > > > > -- > http://www.coreyhaines.com > The Internet''s Premiere source of information about Corey Haines > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Okay, I''ll try that. Thanks. I don''t really like all the view stuff in the controllers, and I intend to eventually move them into RJS, but, while I''m learning, I''m keeping it there. :) -Corey On Feb 5, 2008 9:30 PM, David Chelimsky <dchelimsky at gmail.com> wrote:> On Feb 5, 2008 6:42 PM, Corey Haines <coreyhaines at gmail.com> wrote: > > David, I tried doing this, and I get an exception. Here''s a pastie of > the > > error, controller, controller_spec: http://pastie.caboo.se/148021 > > You''ve got page[:coupon_list], not just page. So what you need to mock is > this: > > page = mock("page") > page.should_receive(:[]).with(:coupon_list).and_return(page) > page.should_receive(:replace_html).with(:partial => "coupon_list") > > That''s starting to get a bit brittle, but that''s what you get for > mixing all that view logic in your controllers. It''s the Rails Way, > but it comes with a price if you want this level of coverage and > isolation. > > FWIW, > David > > > > > > > > > On Feb 5, 2008 2:02 AM, David Chelimsky <dchelimsky at gmail.com> wrote: > > > > > it "should replace foo with bar partial" do > > > page = mock("page") > > > page.should_receive(:replace_html).with(''foo'', :partial => ''bar'') > > > controller.expect_render(:update).and_yield(page) > > > do_post > > > end > > > > > > HTH, > > > David > > > > > > > > > > > Brian > > > > > > > > > > > > _______________________________________________ > > > > 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 > > > > > > > > > > > -- > > http://www.coreyhaines.com > > The Internet''s Premiere source of information about Corey Haines > > _______________________________________________ > > 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 >-- http://www.coreyhaines.com The Internet''s Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080210/4768d218/attachment-0001.html