Sha256: de500e2f25a8b22802c261b83bc49db0a2133b0a239704c1325d5a65b9622b80
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
# -*- encoding : utf-8 -*- require 'securerandom' describe 'Templating' do let(:contract_path) { contract_file 'templating_contract' } let(:contracts) { Pacto.load_contracts(contract_path, 'http://dummyprovider.com') } let(:key) { SecureRandom.hex } let(:auth_token) { SecureRandom.hex } let :response do contracts.stub_providers(key: key, auth_token: auth_token) raw_response = Faraday.get('http://dummyprovider.com/echo') do |req| req.headers = { 'Accept' => 'application/json', 'Custom-Auth-Token' => "#{auth_token}", 'X-Message' => "#{key}" } end MultiJson.load(raw_response.body) end before :each do Pacto.clear! end context 'No processing' do it 'does not proccess erb tag' do Pacto.configure do |c| c.strict_matchers = false c.register_hook do |_contracts, _req, res| res end end expect(response.keys).to eq ['message'] expect(response['message']).to eq("<%= req['HEADERS']['X-Message'].reverse %>") end end context 'Post processing' do it 'processes erb on each request' do Pacto.configure do |c| c.strict_matchers = false c.register_hook Pacto::Hooks::ERBHook.new end expect(response.keys).to eq ['message'] expect(response['message']).to eq(key.reverse) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc3 | spec/integration/templating_spec.rb |
pacto-0.4.0.rc2 | spec/integration/templating_spec.rb |