Sha256: 9fa1014b786c4aed1048abb52abad7528b26cb5cd5562e947ba4836c6d9c96ed

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

module SimpleShipping
  module CustomMatchers
    class HaveDefaultValueMatcher < BasicMatcher
      def initialize(value)
        @value = value
      end
      
      def matches?(model)
        model.send(@attribute) == @value
      end

      def for_attribute(attribute)
        @attribute = attribute.to_sym
        self
      end

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

    def have_default_value(value)
      HaveDefaultValueMatcher.new(value)
    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_default_value_matcher.rb
simple_shipping-0.4.6 spec/support/custom_matchers/have_default_value_matcher.rb