Where to put RSpec After block

14 views
Skip to first unread message

Andrew P

unread,
Mar 11, 2016, 11:33:51 AM3/11/16
to Turnip
So I'd like to have a global step that, when used as part of a Background block, will reset the state of the system under test after each scenario has finished. I thought to add an RSpec after block to the step, but this fails because:

`after` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).

Is there a proper way to do this within Turnip? I like the readability of using steps to define this, and would like to avoid having to tag every scenario.

Wataru MIYAGUNI

unread,
Mar 12, 2016, 5:38:58 AM3/12/16
to Turnip
Hi andrew.

Please try the following code:

RSpec.configure do |config|
  config
.after type: :feature do
    p
'after step'
 
end
end

Example codes:

https://gist.github.com/gongo/97eda04fbb4cd01cbd73


2016年3月12日土曜日 1時33分51秒 UTC+9 Andrew P:
Reply all
Reply to author
Forward
0 new messages