class FriendlyAttributes::Test::Matchers::HaveFriendlyAttribute
Public Class Methods
new(example, type, *attributes)
click to toggle source
# File lib/friendly_attributes/test/matchers.rb, line 5 def initialize(example, type, *attributes) @example = example @type = type @options = attributes.extract_options! @through = @options[:through] @attributes = attributes end
Public Instance Methods
description()
click to toggle source
# File lib/friendly_attributes/test/matchers.rb, line 29 def description "have [#{@actual}] friendly_attributes of type #{@type} => #{@attributes.inspect}" end
failure_message()
click to toggle source
# File lib/friendly_attributes/test/matchers.rb, line 21 def failure_message "expected #{@actual.inspect} to have friendly attributes #{@attributes.inspect} of type #{@type}" end
matches?(actual)
click to toggle source
# File lib/friendly_attributes/test/matchers.rb, line 13 def matches?(actual) @actual = Class === actual ? actual : actual.class result = @actual.ancestors.include?(FriendlyAttributes) && @attributes.all? { |attr| @through.attributes.include?(attr) && @through.attributes[attr].type == @type } end
negative_failure_message()
click to toggle source
# File lib/friendly_attributes/test/matchers.rb, line 25 def negative_failure_message "expected #{@actual.inspect} not to have friendly attributes #{@attributes.inspect}" end