spec/unit/pacto/contract_validator_spec.rb in pacto-0.3.0 vs spec/unit/pacto/contract_validator_spec.rb in pacto-0.3.1

- old
+ new

@@ -40,17 +40,17 @@ let(:opts) { {} } describe '.validate' do before do - allow(Pacto::Validators::RequestBodyValidator).to receive(:validate).with(expected_request.schema, actual_request).and_return([]) - allow(Pacto::Validators::ResponseBodyValidator).to receive(:validate).with(expected_response.schema, actual_response).and_return([]) + allow(Pacto::Validators::RequestBodyValidator).to receive(:validate).with(contract, actual_request).and_return([]) + allow(Pacto::Validators::ResponseBodyValidator).to receive(:validate).with(contract, actual_response).and_return([]) end context 'default validator stack' do it 'calls the RequestBodyValidator' do - expect(Pacto::Validators::RequestBodyValidator).to receive(:validate).with(expected_request.schema, actual_request).and_return(validation_errors) + expect(Pacto::Validators::RequestBodyValidator).to receive(:validate).with(contract, actual_request).and_return(validation_errors) expect(ContractValidator.validate contract, actual_request, actual_response, opts).to eq(validation_errors) end it 'calls the ResponseStatusValidator' do expect(Pacto::Validators::ResponseStatusValidator).to receive(:validate).with(expected_response.status, actual_response.status).and_return(validation_errors) @@ -61,23 +61,23 @@ expect(Pacto::Validators::ResponseHeaderValidator).to receive(:validate).with(expected_response.headers, actual_response.headers).and_return(validation_errors) expect(ContractValidator.validate contract, actual_request, actual_response, opts).to eq(validation_errors) end it 'calls the ResponseBodyValidator' do - expect(Pacto::Validators::ResponseBodyValidator).to receive(:validate).with(expected_response.schema, actual_response).and_return(validation_errors) + expect(Pacto::Validators::ResponseBodyValidator).to receive(:validate).with(contract, actual_response).and_return(validation_errors) expect(ContractValidator.validate contract, actual_request, actual_response, opts).to eq(validation_errors) end end context 'when headers and body match and the ResponseStatusValidator reports no errors' do it 'does not return any errors' do # JSON::Validator.should_receive(:fully_validate). # with(definition['body'], fake_response.body, :version => :draft3). # and_return([]) - expect(Pacto::Validators::RequestBodyValidator).to receive(:validate).with(expected_request.schema, actual_request).and_return([]) + expect(Pacto::Validators::RequestBodyValidator).to receive(:validate).with(contract, actual_request).and_return([]) expect(Pacto::Validators::ResponseStatusValidator).to receive(:validate).with(expected_response.status, actual_response.status).and_return([]) expect(Pacto::Validators::ResponseHeaderValidator).to receive(:validate).with(expected_response.headers, actual_response.headers).and_return([]) - expect(Pacto::Validators::ResponseBodyValidator).to receive(:validate).with(expected_response.schema, actual_response).and_return([]) + expect(Pacto::Validators::ResponseBodyValidator).to receive(:validate).with(contract, actual_response).and_return([]) expect(ContractValidator.validate contract, actual_request, actual_response, opts).to be_empty end end end end