Sha256: 57c45333d80982c0d3ec7acbf61f38d9c4a88476816fc13211374c0867721342

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 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 failure_message_when_negated
        "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

1 entries across 1 versions & 1 rubygems

Version Path
dm-rspec-0.3.0 lib/dm/matchers/have_property.rb