class Pact::Matchers::MultipartFormDiffFormatter

Public Class Methods

call(diff, options = {}) click to toggle source
# File lib/pact/matchers/multipart_form_diff_formatter.rb, line 16
def self.call diff, options = {}
  new(diff, options).call
end
new(diff, options = {}) click to toggle source
# File lib/pact/matchers/multipart_form_diff_formatter.rb, line 8
def initialize diff, options = {}
  @options = options
  @body_diff = diff[:body]
  @non_body_diff = diff.reject{ |k, v| k == :body }
  @colour = options.fetch(:colour, false)
  @differ = Pact::Matchers::Differ.new(@colour)
end

Public Instance Methods

body_diff_string() click to toggle source
# File lib/pact/matchers/multipart_form_diff_formatter.rb, line 32
def body_diff_string
  if @body_diff
    @differ.diff_as_string(@body_diff.expected, @body_diff.actual)
  else
    ""
  end
end
call() click to toggle source
# File lib/pact/matchers/multipart_form_diff_formatter.rb, line 20
def call
  Pact::Matchers::UnixDiffFormatter::MESSAGES_TITLE + "\n" + non_body_diff_string + "\n" + body_diff_string
end
non_body_diff_string() click to toggle source
# File lib/pact/matchers/multipart_form_diff_formatter.rb, line 24
def non_body_diff_string
  if @non_body_diff.any?
    Pact::Matchers::ExtractDiffMessages.call(@non_body_diff).collect{ | message| "* #{message}" }.join("\n")
  else
    ""
  end
end