Multiple before(:each)?

16 views
Skip to first unread message

David Kahn

unread,
Feb 17, 2011, 12:51:08 PM2/17/11
to ste...@googlegroups.com
I am wondering if multiple contexts and before(:each) can be nested, and the first before(:each) still runs on the nested scenario:

context "one" do
  before(:each) do
    @something = 1
  end

  scenario "should x" do
    ...
  end

  context "two" do
     before(:each) do
        @something_else = 3
     end

     scenario "something plus something else should be four" do
        (@something + @something_else).should == 4
     end
  end

end

Luismi Cavallé

unread,
Feb 18, 2011, 6:41:24 AM2/18/11
to ste...@googlegroups.com
Hi David:

The answer is there, waiting for you. You just need to run your own example :P

-- Luismi

David Kahn

unread,
Feb 18, 2011, 10:01:10 AM2/18/11
to ste...@googlegroups.com
Yeah, sorry, was being very lazy.... and the answer is yes! :)
Reply all
Reply to author
Forward
0 new messages