Groups
Groups
Sign in
Groups
Groups
rspec
Conversations
About
Send feedback
Help
Around(:each) overriding before(:each) behaviour
11 views
Skip to first unread message
siva
unread,
Jan 15, 2014, 8:54:53 AM
1/15/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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 PM
1/15/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rs...@googlegroups.com
That's working as expected. In `around(:each)` you have to call `run` on the yielded arg, as documented:
http://rubydoc.info/gems/rspec-core/RSpec/Core/Hooks#around-instance_method
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