class BaconExpect::FailMessageRenderer
Public Class Methods
expectation(negated)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 3 def self.expectation(negated) "#{negated ? " not" : ""} expected" end
message_for_be(negated, subject, method_name, values)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 19 def self.message_for_be(negated, subject, method_name, values) message = "#{subject.inspect} ##{method_name}" message += "(#{values.map(&:inspect).join(', ')})" unless values.empty? message += "#{expectation(negated)} to return true" message end
message_for_be_eq(negated, subject, value)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 49 def self.message_for_be_eq(negated, subject, value) "#{subject.inspect}#{expectation(negated)} to be == to #{value.inspect}" end
message_for_be_equal(negated, subject, value)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 45 def self.message_for_be_equal(negated, subject, value) "#{subject.inspect}#{expectation(negated)} to be same object as #{value.inspect}" end
message_for_be_false(negated, subject)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 7 def self.message_for_be_false(negated, subject) "#{subject.inspect}#{expectation(negated)} to be false" end
message_for_be_nil(negated, subject)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 15 def self.message_for_be_nil(negated, subject) "#{subject.inspect}#{expectation(negated)} to be nil" end
message_for_be_true(negated, subject)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 11 def self.message_for_be_true(negated, subject) "#{subject.inspect}#{expectation(negated)} to be true" end
message_for_be_within(negated, subject, range, center_value)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 26 def self.message_for_be_within(negated, subject, range, center_value) "#{subject.inspect}#{expectation(negated)} to be within #{range} of #{center_value}" end
message_for_change(negated, change_amount, value_diff)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 30 def self.message_for_change(negated, change_amount, value_diff) message = "Block#{expectation(negated)} to change value" message += " by #{change_amount}" if change_amount message += " but changed by #{value_diff}" if change_amount && !negated message end
message_for_end_with(negated, subject, end_string)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 37 def self.message_for_end_with(negated, subject, end_string) "#{subject.inspect}#{expectation(negated)} to end with #{end_string.inspect}" end
message_for_have_generic(negated, subject, method_name, values)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 53 def self.message_for_have_generic(negated, subject, method_name, values) message = "#{subject.inspect} #has_#{method_name}?" message += "(#{values.map(&:inspect).join(', ')})" unless values.empty? message += "#{expectation(negated)} to return true" message end
message_for_have_items(negated, subject, expected_number_of_items, actual_number_of_items, key_type_name)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 60 def self.message_for_have_items(negated, subject, expected_number_of_items, actual_number_of_items, key_type_name) message = "#{subject.inspect}#{expectation(negated)} to have #{expected_number_of_items} #{key_type_name}" message += " but had #{actual_number_of_items}" unless negated message end
message_for_include(negated, subject, values)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 66 def self.message_for_include(negated, subject, values) values_message = values.size == 1 ? values.first : values message = "#{subject.inspect}#{expectation(negated)} to include #{values_message.inspect}" message end
message_for_match(negated, subject, match)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 78 def self.message_for_match(negated, subject, match) "#{subject.inspect}#{expectation(negated)} to match #{match.inspect}" end
message_for_match_array(negated, subject_array, expected_array)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 72 def self.message_for_match_array(negated, subject_array, expected_array) message = "#{subject_array.inspect}#{expectation(negated)} to match array" message += " #{expected_array.inspect}" message end
message_for_raise_error(negated, show_class, error_class, show_message, error_message, rescued_exception)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 82 def self.message_for_raise_error(negated, show_class, error_class, show_message, error_message, rescued_exception) message = "Block#{expectation(negated)} to raise error" message += " of type #{error_class}" if show_class message += " with message matching #{error_message.inspect}" if show_message message += " but was #{rescued_exception.inspect}" if rescued_exception && !negated message end
message_for_respond_to(negated, subject, method_name, number_of_args)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 90 def self.message_for_respond_to(negated, subject, method_name, number_of_args) message = "#{subject.inspect}#{expectation(negated)} to respond to ##{method_name}" message += " with #{number_of_args} arguments" if number_of_args message end
message_for_satisfy(negated)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 96 def self.message_for_satisfy(negated) "Block#{expectation(negated)} to satisfy condition" end
message_for_start_with(negated, subject, start_string)
click to toggle source
# File lib/bacon-expect/fail_message_renderer.rb, line 41 def self.message_for_start_with(negated, subject, start_string) "#{subject.inspect}#{expectation(negated)} to start with #{start_string.inspect}" end