Sha256: 3cd3a33e65eac601d6a63df9cedab2b435e3e4161aaa77c6fdfe9b6472acf219

Contents?: true

Size: 462 Bytes

Versions: 2

Compression:

Stored size: 462 Bytes

Contents

module SimpleShipping
  module CustomMatchers
    class HaveErrorsOnMatcher < BasicMatcher

      def initialize(attribute)
        @attribute = attribute.to_sym
      end
      
      def matches?(model)
        model.valid?
        !!model.errors.messages[@attribute]
      end

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

    def have_errors_on(attr_name)
      HaveErrorsOnMatcher.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_errors_on_matcher.rb
simple_shipping-0.4.6 spec/support/custom_matchers/have_errors_on_matcher.rb