Sha256: 1e3fd0f1ea6e3342838bdda28c518184bfddfeb049a1cf063a4f76040b154ae2

Contents?: true

Size: 483 Bytes

Versions: 2

Compression:

Stored size: 483 Bytes

Contents

module SimpleShipping
  module CustomMatchers
    class HaveAttributeMatcher < BasicMatcher
      def initialize(attribute)
        @attribute = attribute.to_sym
      end
      
      def matches?(model)
        model.respond_to?(@attribute) &&
        model.respond_to?("#{@attribute}=")
      end

      def description
        "have attribute #{@attribute.inspect}"
      end
    end

    def have_attribute(attr_name)
      HaveAttributeMatcher.new(attr_name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_shipping-0.4.7 spec/support/custom_matchers/have_attribute_matcher.rb
simple_shipping-0.4.6 spec/support/custom_matchers/have_attribute_matcher.rb