From 216bfdc4852aa860f060df2d1d0891695d4f1e39 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 27 Oct 2017 21:49:39 +1100 Subject: [PATCH] feat(can-i-deploy): include full response body in json output --- lib/pact_broker/client/can_i_deploy.rb | 2 +- lib/pact_broker/client/matrix/json_formatter.rb | 4 ++-- lib/pact_broker/client/matrix/text_formatter.rb | 4 ++-- spec/lib/pact_broker/client/matrix/text_formatter_spec.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pact_broker/client/can_i_deploy.rb b/lib/pact_broker/client/can_i_deploy.rb index 8b478b7b..d5655b85 100644 --- a/lib/pact_broker/client/can_i_deploy.rb +++ b/lib/pact_broker/client/can_i_deploy.rb @@ -53,7 +53,7 @@ def success_message(matrix) end def failure_message(matrix) - message = format_matrix(matrix[:matrix]) + message = format_matrix(matrix) if format != 'json' message = 'Computer says no ¯\_(ツ)_/¯' + "\n\n" + message end diff --git a/lib/pact_broker/client/matrix/json_formatter.rb b/lib/pact_broker/client/matrix/json_formatter.rb index 54b78f5b..2f23d34a 100644 --- a/lib/pact_broker/client/matrix/json_formatter.rb +++ b/lib/pact_broker/client/matrix/json_formatter.rb @@ -4,8 +4,8 @@ module PactBroker module Client class Matrix class JsonFormatter - def self.call(matrix_lines) - JSON.pretty_generate(matrix: matrix_lines) + def self.call(matrix) + JSON.pretty_generate(matrix) end end end diff --git a/lib/pact_broker/client/matrix/text_formatter.rb b/lib/pact_broker/client/matrix/text_formatter.rb index 63f8f73d..8d0d2057 100644 --- a/lib/pact_broker/client/matrix/text_formatter.rb +++ b/lib/pact_broker/client/matrix/text_formatter.rb @@ -7,8 +7,8 @@ class TextFormatter Line = Struct.new(:consumer, :consumer_version, :provider, :provider_version, :success) - def self.call(matrix_lines) - data = matrix_lines.collect do | line | + def self.call(matrix) + data = matrix[:matrix].collect do | line | Line.new( lookup(line, :consumer, :name), lookup(line, :consumer, :version, :number), diff --git a/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb b/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb index d49e329f..59c791b7 100644 --- a/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb +++ b/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb @@ -8,7 +8,7 @@ module Client # SublimeText removes whitespace from the end of files when you save them, # so removing trailing whitespace before comparing - subject { Matrix::TextFormatter.call(matrix_lines).split("\n").collect(&:strip).join("\n") } + subject { Matrix::TextFormatter.call(matrix: matrix_lines).split("\n").collect(&:strip).join("\n") } context "with valid data" do it "it has the right text" do