Sha256: db9d9984019ab26cc6c9e6d393ef8e0ece179751a8df6d3c4fd77ba41166cce6
Contents?: true
Size: 840 Bytes
Versions: 3
Compression:
Stored size: 840 Bytes
Contents
module Warp module ModelMatchers class AttributeMatcher < Warp::ModelMatchers::Matcher attr_reader :attr_name def initialize(attr_name) @attr_name = attr_name.to_sym end def matches?(model_or_instance) @model_or_instance = model_or_instance attributes.any? {|actual| values_match?(attr_name, actual) } end def description "have attribute #{description_of(attr_name)}" end def failure_message "expected #{model_name} to #{description}" end def failure_message_when_negated "expected #{model_name} to not #{description}" end private def attributes model.attribute_names.map(&:to_sym) end end def have_attribute(attr_name) AttributeMatcher.new(attr_name) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
warp-1.2.3 | lib/warp/model_matchers/attribute_matcher.rb |
warp-1.2.2 | lib/warp/model_matchers/attribute_matcher.rb |
warp-1.2.1 | lib/warp/model_matchers/attribute_matcher.rb |