Class: Pact::Consumer::SpecHooks

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/consumer/spec_hooks.rb

Instance Method Summary collapse

Instance Method Details

#after_each(example_description) ⇒ Object



23
24
25
26
27
28
# File 'lib/pact/consumer/spec_hooks.rb', line 23

def after_each example_description
  Pact.configuration.logger.info "Verifying interactions for #{example_description}"
  Pact.configuration.provider_verifications.each do | provider_verification |
    provider_verification.call example_description
  end
end

#after_suiteObject



30
31
32
33
34
35
36
37
# File 'lib/pact/consumer/spec_hooks.rb', line 30

def after_suite
  if Pact.consumer_world.any_pact_examples_ran?
    Pact.consumer_world.consumer_contract_builders.each(&:write_pact)
    Pact::Doc::Generate.call
    Pact::MockService::AppManager.instance.kill_all
    Pact::MockService::AppManager.instance.clear_all
  end
end

#before_allObject



10
11
12
13
# File 'lib/pact/consumer/spec_hooks.rb', line 10

def before_all
  Pact::MockService::AppManager.instance.spawn_all
  FileUtils.mkdir_p Pact.configuration.pact_dir
end

#before_each(example_description) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/pact/consumer/spec_hooks.rb', line 15

def before_each example_description
  Pact.consumer_world.register_pact_example_ran
  Pact.configuration.logger.info "Clearing all expectations"
  Pact::MockService::AppManager.instance.urls_of_mock_services.each do | url |
    Pact::MockService::Client.clear_interactions url, example_description
  end
end