Class: Pact::Provider::RSpec::InteractionContext
- Inherits:
-
Object
- Object
- Pact::Provider::RSpec::InteractionContext
- Defined in:
- lib/pact/provider/rspec.rb
Overview
The “arrange” and “act” parts of the test really only need to be run once, however, stubbing is not supported in before :all, so this is a wee hack to enable before :all like functionality using before :each. In an ideal world, the test setup and execution should be quick enough for the difference between :all and :each to be unnoticable, but the annoying reality is, sometimes it does make a difference. This is for you, V!
Instance Attribute Summary collapse
-
#last_response ⇒ Object
Returns the value of attribute last_response.
Instance Method Summary collapse
-
#initialize ⇒ InteractionContext
constructor
A new instance of InteractionContext.
- #run_once(hook) ⇒ Object
Constructor Details
#initialize ⇒ InteractionContext
Returns a new instance of InteractionContext.
217 218 219 |
# File 'lib/pact/provider/rspec.rb', line 217 def initialize @already_run = [] end |
Instance Attribute Details
#last_response ⇒ Object
Returns the value of attribute last_response.
215 216 217 |
# File 'lib/pact/provider/rspec.rb', line 215 def last_response @last_response end |
Instance Method Details
#run_once(hook) ⇒ Object
221 222 223 224 225 226 |
# File 'lib/pact/provider/rspec.rb', line 221 def run_once hook unless @already_run.include?(hook) yield @already_run << hook end end |