Sha256: 4d39cbfd652173d53be4fa69f88e864d9d09144b57cba2be9356d4405ceac336

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

module DataMapper
  module Matchers

    class HaveErrorsOn
      def initialize(property)
	@property = property.to_sym
      end

      def matches?(model)
	@model = model
	@model.valid?
	!@model.errors[@property].empty?
      end

      def failure_message
	"expected to have errors on #{@property}"
      end

      def negative_failure_message
	"expected to not have errors on #{@property}"
      end

      def description
        "has errors on #{@property}"
      end
    end

    def have_errors_on(property)
      HaveErrorsOn.new(property)
    end

    alias :have_error_on :have_errors_on 
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-rspec-0.0.1 lib/dm/matchers/have_errors_on.rb