Around(:each) overriding before(:each) behaviour

11 views
Skip to first unread message

siva

unread,
Jan 15, 2014, 8:54:53 AM1/15/14
to rs...@googlegroups.com

  Hi all

   I am doing some stunts using around each. I found some different odd with around(:each). When I run below example it gives output as:

   describe "AroundSpec" do
       before(:each) do
          p "On before each block"
        end

        around(:each) do
            p "On around each block"
        end

         it "1+1 = 2" do
            expect(1+1).to eq(2)
         end
   end
 
   output:
      "On around each block"
     .

      Finished in 0.00038 seconds
      1 example, 0 failures


     If you notice it doesn't executing before each block. Is this way suppose to be it work or is it a bug? Could you help out. Thanks in advance



Myron Marston

unread,
Jan 15, 2014, 2:54:04 PM1/15/14
to rs...@googlegroups.com
That's working as expected.  In `around(:each)` you have to call `run` on the yielded arg, as documented:


If you do not do this, the example will not run.  Given that it is an around hook, you are responsible for telling rspec when to run the example, so you can wrap it however you like.

Myron 
Reply all
Reply to author
Forward
0 new messages