What do you guys think of this: if someone calls should_receive outside of an "it" block, it warns you. before(:each) do @foo = Foo.new @foo.should_receive(:monkeys) end would warn you that you''re setting an expectation in the wrong place, and that "stub" is correct when setting up objects. Opinions? courtenay
Lance Carlson
2007-Aug-17 21:34 UTC
[rspec-users] should_receive, used in the wrong place?
what about template.should_receive(:current_user)? I don''t know if that''s a bad idea to do that in the before(:each) but it''s more convenient.. On 8/17/07, Courtenay <court3nay at gmail.com> wrote:> What do you guys think of this: if someone calls should_receive > outside of an "it" block, it warns you. > > before(:each) do > @foo = Foo.new > @foo.should_receive(:monkeys) > end > > would warn you that you''re setting an expectation in the wrong place, > and that "stub" is correct when setting up objects. > > Opinions? > > > courtenay > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
That''s exactly my point; enforcing the difference between should_receive vs stub! On 8/17/07, Lance Carlson <lancecarlson at gmail.com> wrote:> what about template.should_receive(:current_user)? > > I don''t know if that''s a bad idea to do that in the before(:each) but > it''s more convenient.. > > On 8/17/07, Courtenay <court3nay at gmail.com> wrote: > > What do you guys think of this: if someone calls should_receive > > outside of an "it" block, it warns you. > > > > before(:each) do > > @foo = Foo.new > > @foo.should_receive(:monkeys) > > end > > > > would warn you that you''re setting an expectation in the wrong place, > > and that "stub" is correct when setting up objects. > > > > Opinions? > > > > > > courtenay > > _______________________________________________ > > 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 >
Lance Carlson
2007-Aug-17 21:48 UTC
[rspec-users] should_receive, used in the wrong place?
I agree :) On 8/17/07, Courtenay <court3nay at gmail.com> wrote:> That''s exactly my point; enforcing the difference between > should_receive vs stub! > > On 8/17/07, Lance Carlson <lancecarlson at gmail.com> wrote: > > what about template.should_receive(:current_user)? > > > > I don''t know if that''s a bad idea to do that in the before(:each) but > > it''s more convenient.. > > > > On 8/17/07, Courtenay <court3nay at gmail.com> wrote: > > > What do you guys think of this: if someone calls should_receive > > > outside of an "it" block, it warns you. > > > > > > before(:each) do > > > @foo = Foo.new > > > @foo.should_receive(:monkeys) > > > end > > > > > > would warn you that you''re setting an expectation in the wrong place, > > > and that "stub" is correct when setting up objects. > > > > > > Opinions? > > > > > > > > > courtenay > > > _______________________________________________ > > > 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-Aug-18 06:02 UTC
[rspec-users] should_receive, used in the wrong place?
On 8/17/07, Courtenay <court3nay at gmail.com> wrote:> That''s exactly my point; enforcing the difference between > should_receive vs stub!Great convention, but I think making the tool enforce it is a bit restrictive.> On 8/17/07, Lance Carlson <lancecarlson at gmail.com> wrote: > > what about template.should_receive(:current_user)? > > > > I don''t know if that''s a bad idea to do that in the before(:each) but > > it''s more convenient.. > > > > On 8/17/07, Courtenay <court3nay at gmail.com> wrote: > > > What do you guys think of this: if someone calls should_receive > > > outside of an "it" block, it warns you. > > > > > > before(:each) do > > > @foo = Foo.new > > > @foo.should_receive(:monkeys) > > > end > > > > > > would warn you that you''re setting an expectation in the wrong place, > > > and that "stub" is correct when setting up objects. > > > > > > Opinions? > > > > > > > > > courtenay > > > _______________________________________________ > > > 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >