Sha256: b8c762f08452f835939c91cda37caa5d8edb342b28ad1623af000c114944a599
Contents?: true
Size: 1.45 KB
Versions: 12
Compression:
Stored size: 1.45 KB
Contents
require "support/test_data_builder" require "webmock/rspec" require "rack/pact_broker/database_transaction" describe "Execute a webhook" do before do td.create_pact_with_hierarchy("Foo", "1", "Bar") allow(PactBroker.configuration).to receive(:webhook_scheme_whitelist).and_return(%w[http]) end let(:params) do { request: { method: "POST", url: "http://example.org", headers: {"Content-Type" => "application/json"}, body: "${pactbroker.pactUrl}" } } end let(:rack_headers) { { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/hal+json" } } let(:path) { "/webhooks/execute" } let(:response_body) { JSON.parse(last_response.body, symbolize_names: true)} subject { post(path, params.to_json, rack_headers) } context "when the execution is successful" do let!(:request) do stub_request(:post, /http/).with(body: expected_webhook_url).to_return(:status => 200, body: response_body) end let(:expected_webhook_url) { %r{http://example.org/pacts/provider/Bar/consumer/Foo.*} } let(:response_body) { "webhook-response-body" } it "performs the HTTP request" do subject expect(request).to have_been_made end it "returns a 200 response" do expect(subject.status).to be 200 end end context "when there is a validation error" do let(:params) { {} } it "returns a 400" do expect(subject.status).to be 400 end end end
Version data entries
12 entries across 12 versions & 1 rubygems