Sha256: 3520ef1eb87a1ce612c4758d1a3897e267434184760bf0e2ee6446ecdb069b33

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'


describe "DataMapper::Matchers::HaveProperty" do
  context '#should' do
    it 'passes if property exists' do
      lambda {Book.should have_property :name}.should_pass
    end
    
    it 'passes if property exists and is of correct type' do
      lambda { Book.should have_property(:name).of_type(DataMapper::Property::String)}.should_pass
    end

    it 'fails if property does not exist' do
      lambda {Book.should have_property :bad_property}.should fail_with "Expected Book to have property bad_property"
    end
    
    it 'fails if property exists and is of wrong type' do
      lambda {Book.should have_property(:name).of_type(Integer)}.should fail_with "property name should be of type Integer but is of type DataMapper::Property::String"
    end      
  end

  context '#should_not' do
    it 'fails if property exists' do
      lambda {Book.should_not have_property :name}.should fail_with "Expected Book to not have property name, but it does!"
    end
  end

  context 'instance of model' do
    it "should pass" do
      lambda{ Book.new.should have_property :name}.should_pass
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dm-rspec2-0.3.0 spec/dm/matchers/have_property_spec.rb
dm-rspec2-0.2.4 spec/dm/matchers/have_property_spec.rb
dm-rspec2-0.2.3 spec/dm/matchers/have_property_spec.rb
dm-rspec2-0.2.2 spec/dm/matchers/have_property_spec.rb
dm-rspec2-0.2.1 spec/dm/matchers/have_property_spec.rb