Sha256: d9c054300d296f4125616c7b51093e993caeaf5cdd8dee87495765149e322ea0

Contents?: true

Size: 645 Bytes

Versions: 3

Compression:

Stored size: 645 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
        "has property #{@children}"
      end
    end


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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dm-rspec-0.2.2 lib/dm/matchers/have_property.rb
dm-rspec-0.2.1 lib/dm/matchers/have_property.rb
dm-rspec-0.2.0 lib/dm/matchers/have_property.rb