class SuperDiff::RSpec::MatcherTextBuilders::BePredicate
Attributes
expected_predicate_method_name[R]
Public Class Methods
new( predicate_accessible:, private_predicate:, expected_predicate_method_name:, **rest )
click to toggle source
Calls superclass method
SuperDiff::RSpec::MatcherTextBuilders::Base::new
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 5 def initialize( predicate_accessible:, private_predicate:, expected_predicate_method_name:, **rest ) super(**rest) @predicate_accessible = predicate_accessible @private_predicate = private_predicate @expected_predicate_method_name = expected_predicate_method_name end
Protected Instance Methods
actual_color()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 29 def actual_color :yellow end
add_actual_value()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 33 def add_actual_value template.add_text_in_color(actual_color) do description_of(actual) end end
add_expected_value_to_description(template)
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 52 def add_expected_value_to_description(template) template.add_text " " template.add_text_in_color( expected_color, "`#{expected_for_description}?`", ) template.add_text " or " template.add_text_in_color( expected_color, "`#{expected_for_description}s?`", ) end
add_expected_value_to_failure_message(template)
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 39 def add_expected_value_to_failure_message(template) template.add_text " " template.add_text_in_color( expected_color, "#{expected_for_failure_message}?", ) template.add_text " or " template.add_text_in_color( expected_color, "#{expected_for_failure_message}s?", ) end
add_extra_after_error()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 65 def add_extra_after_error if expected_predicate_method_name == :true? template.add_text "\n\n" template.add_text "(Perhaps you want to use " template.add_text_in_color(:blue, "be(true)") template.add_text " or " template.add_text_in_color(:blue, "be_truthy") template.add_text " instead?)" elsif expected_predicate_method_name == :false? template.add_text "\n\n" template.add_text "(Perhaps you want to use " template.add_text_in_color(:blue, "be(false)") template.add_text " or " template.add_text_in_color(:blue, "be_falsey") template.add_text " instead?)" end end
expected_action_for_failure_message()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 19 def expected_action_for_failure_message if predicate_accessible? "return a truthy result for" elsif private_predicate? "have a public method" else "respond to" end end
Private Instance Methods
predicate_accessible?()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 87 def predicate_accessible? @predicate_accessible end
private_predicate?()
click to toggle source
# File lib/super_diff/rspec/matcher_text_builders/be_predicate.rb, line 91 def private_predicate? @private_predicate end