Sha256: ec99b2399f44b7c4ce5a973dd2cf35f775ae84fe693478e1d852e1aa9ed74e51
Contents?: true
Size: 1.46 KB
Versions: 12
Compression:
Stored size: 1.46 KB
Contents
require "pact_broker/api/resources/matrix" require "pact_broker/matrix/service" module PactBroker module Api module Resources describe Matrix do before do allow(PactBroker::Matrix::Service).to receive(:validate_selectors).and_return(error_messages) allow(PactBroker::Matrix::Service).to receive(:can_i_deploy).and_return([]) allow(PactBroker::Matrix::ParseQuery).to receive(:call).and_return([selectors, options]) end let(:td) { TestDataBuilder.new } let(:path) { "/matrix" } let(:json_response_body) { JSON.parse(subject.body, symbolize_names: true) } let(:params) { {q: [{pacticipant: "Foo", version: "1"}, {pacticipant: "Bar", version: "2"}]} } let(:error_messages) { [] } let(:selectors) { double("selectors") } let(:options) { double("options") } subject { get path, params, {"Content-Type" => "application/hal+json"}; last_response } it "validates the selectors" do expect(PactBroker::Matrix::Service).to receive(:validate_selectors).with(selectors, options) subject end context "when a validation error occurs" do let(:error_messages) { ["foo"] } it "returns a 400 status" do expect(subject.status).to eq 400 end it "returns error messages" do expect(json_response_body[:errors]).to eq ["foo"] end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems