Sha256: c83f83cab2733c0c3b67c7fbef81953663372c71cad657b6b50dfb9c7159722e

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 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)
      puts "dm-rspec: `have_errors_on` is deprecated. Please use `have(n).errors_on` instead"
      HaveErrorsOn.new(property)
    end

    def have_error_on(property)
      puts "dm-rspec: `have_error_on` is deprecated. Please use `have(1).error_on` instead"
      HaveErrorsOn.new(property)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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