Skip to content

botanicus/dm-spec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

RSpec matchers for DataMapper.

Usage

You must include DataMapperMatchers to your specs. It can be done in spec/spec_helper.rb:

$: << File.dirname(__FILE__) + "/../lib"
require "dm-core"
require "dm-spec"

DataMapper.setup(:default, "sqlite3::memory")

Spec::Runner.configure do |config|
  config.include(DataMapperMatchers)
  config.before(:each) do
    DataMapper.auto_migrate!
  end
end

That’s it. Now just use these matchers in your specs. All the matchers you should call on model class, not on model instance.

Post.should has_property(:title)
Post.should has_many(:comments)
Post.should has_and_belongs_to_many(:tags)
Post.should belongs_to(:category)
Post.should has_timestamps      # created_at, updated_at
Post.should has_timestamps(:at) # created_at, updated_at
Post.should has_timestamps(:on) # created_on, updated_on
Post.should has_timestamps(:created_at)

About

RSpec matchers for DataMapper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages