Sha256: bd32ac9b437b872c6787c010091d20eb865cf313b14749a72c3d8766337b994b

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

describe 'Pacto' do
  let(:contract_path) { 'spec/integration/data/simple_contract.json' }

  before :all do
    WebMock.allow_net_connect!
  end

  context 'Contract validation' do
    before :all do
      @server = DummyServer.new 8000, '/hello', '{"message": "Hello World!"}'
      @server.start
    end

    after :all do
      @server.terminate
    end

    it 'verifies the contract against a producer' do
      contract = Pacto.build_from_file(contract_path, 'http://localhost:8000')
      contract.validate.should == []
    end
  end

  context 'Stub generation' do
    it 'generates a stub to be used by a consumer' do
      contract = Pacto.build_from_file(contract_path, 'http://dummyprovider.com')
      Pacto.register('my_contract', contract)
      Pacto.use('my_contract')
      response.keys.should == ['message']
      response['message'].should be_kind_of(String)
    end

    let :response do
      raw_response = HTTParty.get('http://dummyprovider.com/hello', headers: {'Accept' => 'application/json' })
      JSON.parse(raw_response.body)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pacto-0.2.5 spec/integration/e2e_spec.rb
pacto-0.2.4 spec/integration/e2e_spec.rb
pacto-0.2.3 spec/integration/e2e_spec.rb
pacto-0.2.2 spec/integration/e2e_spec.rb