Project

dm-spec

0.0
No commit activity in last 3 years
No release in over 3 years
Some rSpec matchers for DataMapper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

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)