Class: Pact::Matchers::MultipartFormDiffFormatter
- Inherits:
-
Object
- Object
- Pact::Matchers::MultipartFormDiffFormatter
- Defined in:
- lib/pact/matchers/multipart_form_diff_formatter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #body_diff_string ⇒ Object
- #call ⇒ Object
-
#initialize(diff, options = {}) ⇒ MultipartFormDiffFormatter
constructor
A new instance of MultipartFormDiffFormatter.
- #non_body_diff_string ⇒ Object
Constructor Details
#initialize(diff, options = {}) ⇒ MultipartFormDiffFormatter
Returns a new instance of MultipartFormDiffFormatter.
8 9 10 11 12 13 14 |
# File 'lib/pact/matchers/multipart_form_diff_formatter.rb', line 8 def initialize diff, = {} @options = @body_diff = diff[:body] @non_body_diff = diff.reject{ |k, v| k == :body } @colour = .fetch(:colour, false) @differ = Pact::Matchers::Differ.new(@colour) end |
Class Method Details
.call(diff, options = {}) ⇒ Object
16 17 18 |
# File 'lib/pact/matchers/multipart_form_diff_formatter.rb', line 16 def self.call diff, = {} new(diff, ).call end |
Instance Method Details
#body_diff_string ⇒ Object
32 33 34 35 36 37 38 |
# 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 ⇒ Object
20 21 22 |
# 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 ⇒ Object
24 25 26 27 28 29 30 |
# 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{ | | "* #{}" }.join("\n") else "" end end |