Sha256: 90b6def27433c02481a092831f695d5c9d0bddc0ff13ff7b27e0f128c112960f
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
describe Pacto::Hooks::ERBHook do describe '#process' do let(:req) do OpenStruct.new(:headers => {'User-Agent' => 'abcd'}) end let(:converted_req) do {'HEADERS' => {'User-Agent' => 'abcd'}} end let(:res) do OpenStruct.new(:body => 'before') end before do end context 'no matching contracts' do it 'binds the request' do contracts = Set.new mock_erb(:req => converted_req) described_class.new.process contracts, req, res expect(res.body).to eq('after') end end context 'one matching contract' do it 'binds the request and the contract\'s values' do contract = OpenStruct.new(:values => {:max => 'test'}) contracts = Set.new([contract]) mock_erb(:req => converted_req, :max => 'test') described_class.new.process contracts, req, res expect(res.body).to eq('after') end end context 'multiple matching contracts' do it 'binds the request and the first contract\'s values' do contract1 = OpenStruct.new(:values => {:max => 'test'}) contract2 = OpenStruct.new(:values => {:mob => 'team'}) res = OpenStruct.new(:body => 'before') mock_erb(:req => converted_req, :max => 'test') contracts = Set.new([contract1, contract2]) described_class.new.process contracts, req, res expect(res.body).to eq('after') end end end def mock_erb(hash) Pacto::ERBProcessor.any_instance.should_receive(:process).with('before', hash).and_return('after') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.3.1 | spec/unit/hooks/erb_hook_spec.rb |
pacto-0.3.0 | spec/unit/hooks/erb_hook_spec.rb |