[rspec-users] Does rspec support something like Assumptions in JUnit 4.4?

Matt Wynne matt at mattwynne.net
Mon Jun 1 16:56:07 EDT 2009


On 1 Jun 2009, at 20:52, Pat Maddox wrote:

> You can do
>
> it "should do something" do
>  some_precondition.should be_met
>  an_object.do_something
>  some_postcondition.should be_met
> end

Also, more verbosely...

describe "when there is some precondition"
   before(:each) do
     do_stuff_which_attempts_to_set_up_some_precondition
     some_precondition.should be_met
   end

   it "should do something"
     an_object.do_something
     some_postcondition.should be_met
   end
end

Which, can often make your specs read nicely. I also offers an obvious  
space to think of a few more examples to throw in there.

cheers,
Matt


More information about the rspec-users mailing list