module SuperDiff::RSpec::MatcherTextBuilders
Public Instance Methods
actual_phrase()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 89 def actual_phrase "Expected" end
add_actual_section()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 80 def add_actual_section template.add_text_in_singleline_mode actual_phrase template.add_text_in_multiline_mode do actual_phrase.rjust(phrase_width) end template.add_text " " add_actual_value end
add_actual_value()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 93 def add_actual_value template.add_text_in_color(actual_color) { actual } end
add_expected_value_to_description(template)
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 119 def add_expected_value_to_description(template) if respond_to?(:add_expected_value_to, true) add_expected_value_to(template, expected_for_description) else template.add_text " " template.add_text_in_color(expected_color, expected_for_description) end end
add_expected_value_to_failure_message(template)
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 107 def add_expected_value_to_failure_message(template) if respond_to?(:add_expected_value_to, true) add_expected_value_to(template, expected_for_failure_message) else template.add_text " " template.add_text_in_color( expected_color, expected_for_failure_message, ) end end
description_of(object)
click to toggle source
TODO: Should this be applied to expected and actual automatically instead of expecting the caller to pass in already formatted versions of those objects?
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 149 def description_of(object) ::RSpec::Support::ObjectFormatter.format(object) end
expected_phrase()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 128 def expected_phrase "#{to_or_not_to} #{expected_action_for_failure_message}" end
expected_section()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 97 def expected_section MatcherTextTemplate.new do |t| t.add_text_in_singleline_mode expected_phrase t.add_text_in_multiline_mode do expected_phrase.to_s.rjust(phrase_width) end add_expected_value_to_failure_message(t) end end
fill_template()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 71 def fill_template add_actual_section template.add_break template.insert expected_section add_extra_after_expected_to(template) template.add_text_in_singleline_mode "." add_extra_after_error end
phrase_width()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 140 def phrase_width [actual_phrase, expected_phrase]. map { |text| Csi.decolorize(text.to_s).length }. max end
to_or_not_to()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/base.rb, line 132 def to_or_not_to if negated? "not to" else "to" end end