Sha256: 0ab983ad4f6be21bb339848bf9eb947da22a2b5ee04f8c9d704e7ae02e83a6ef

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
require 'pact/provider/test_methods'

module Pact::Provider
  describe TestMethods do

    class TestHelper
      include TestMethods
    end

    subject { TestHelper.new }

    describe "get_provider_state" do
      it "raises a descriptive error if the provider state is not found" do
        ProviderState.stub(:get).and_return(nil)
        expect{ subject.send(:get_provider_state, 'some state', 'consumer') }.to raise_error /Could not find.*some state.*consumer.*/
      end
    end

    describe 'request path' do

      let(:request) { OpenStruct.new(:path => 'path', :query => query)}

      before do
        @path = subject.send(:request_path, request)
      end

      describe 'query' do

        context 'string query' do

          let(:query) { 'query' }

          it 'gets appended to the path' do
            expect(@path).to eq('path?query')
          end
        end

        context 'Term query' do

          let(:query) { Pact::Term.new(generate: 'query', matcher: /q/) }

          it 'appends the Term\'s generate to the path' do
            expect(@path).to eq('path?query')
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact-1.0.9 spec/lib/pact/provider/test_methods_spec.rb
pact-1.0.8 spec/lib/pact/provider/test_methods_spec.rb