Sha256: 32995b375777d81d6b491610b81771a92dc980781b3ed9cc369575054b7fd265

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require 'pact/doc/generate'
require 'pact/consumer/world'

module Pact
  module Consumer
    class SpecHooks

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

      def before_each example_description
        Pact.configuration.logger.info "Clearing all expectations"
        Pact::Consumer::AppManager.instance.ports_of_mock_services.each do | port |
          Pact::Consumer::MockServiceClient.clear_interactions port, example_description
        end
      end

      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

      def after_suite
        Pact.consumer_world.consumer_contract_builders.each { | c | c.write_pact }
        Pact::Doc::Generate.call
        Pact::Consumer::AppManager.instance.kill_all
        Pact::Consumer::AppManager.instance.clear_all
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pact-1.3.0 lib/pact/consumer/spec_hooks.rb
pact-1.2.1.rc2 lib/pact/consumer/spec_hooks.rb
pact-1.2.1.rc1 lib/pact/consumer/spec_hooks.rb