Sha256: 7699ec4a42ddad9ea63762493997f6879a0997d4b1264d2743f9f2035f1228d4

Contents?: true

Size: 646 Bytes

Versions: 2

Compression:

Stored size: 646 Bytes

Contents

module DataMapper
  module Matchers

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

      def matches?(model)
        model_class = model.is_a?(Class) ? model : model.class
        model_class.properties.map(&:name).include? @property
      end

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

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


    def have_property(name)
      HaveProperty.new(name)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dm-rspec-0.2.4 lib/dm/matchers/have_property.rb
dm-rspec-0.2.3 lib/dm/matchers/have_property.rb