JDeville
2011-Jan-21 15:32 UTC
[rspec-users] Arrange Act Assert (AAA) style syntax for rspec2
I''d like to be able to test w/ this methodology, and i''m having trouble figuring out where to hook in to rspec to do it. Near as I can tell, the flow is this: run all of the before filters in the order of highest to lowest context <<-- I need to run something right here run tests run all of the after filters in the order of highest to lowest context Is there any way to create a before filter that is always run after all of the others?
David Chelimsky
2011-Jan-22 16:07 UTC
[rspec-users] Arrange Act Assert (AAA) style syntax for rspec2
On Jan 21, 2011, at 10:32 AM, JDeville wrote:> I''d like to be able to test w/ this methodology, and i''m having > trouble figuring out where to hook in to rspec to do it. Near as I > can tell, the flow is this: > > run all of the before filters in the order of highest to lowest > context > > <<-- I need to run something right here > > run tests > > run all of the after filters in the order of highest to lowest context > > Is there any way to create a before filter that is always run after > all of the others?This sounds complicated. In BDD, we use Given/When/Then to mean what you mean by AAA. You can do this all right in the example: it "does something" do # given # when # then end You can use before hooks to set up the givens if you want (though be careful, as this is widely abused leading to less readability), but the when and then should be right in the example. HTH, David
JDeville
2011-Jan-23 02:02 UTC
[rspec-users] Arrange Act Assert (AAA) style syntax for rspec2
Thanks David, What I really need is an explicit way of calling ''when''. You helped me find the rspec-given gem, so I''ll try that. I think that, and the spies support from the Bourne gem will give me what I''ve been hoping for. Thanks for everything David. On Jan 22, 11:07?am, David Chelimsky <dchelim... at gmail.com> wrote:> On Jan 21, 2011, at 10:32 AM, JDeville wrote: > > > I''d like to be able to test w/ this methodology, and i''m having > > trouble figuring out where to hook in to rspec to do it. ?Near as I > > can tell, the flow is this: > > > run all of the before filters in the order of highest to lowest > > context > > > <<-- ?I need to run something right here > > > run tests > > > run all of the after filters in the order of highest to lowest context > > > Is there any way to create a before filter that is always run after > > all of the others? > > This sounds complicated. > > In BDD, we use Given/When/Then to mean what you mean by AAA. You can do this all right in the example: > > it "does something" do > ? # given > ? # when > ? # then > end > > You can use before hooks to set up the givens if you want (though be careful, as this is widely abused leading to less readability), but the when and then should be right in the example. > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users