[rspec-users] Arrange Act Assert (AAA) style syntax for rspec2

David Chelimsky dchelimsky at gmail.com
Sat Jan 22 11:07:11 EST 2011

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

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.


More information about the rspec-users mailing list