Rspec::Ohm
RSpec matchers for Ohm: Object Hash Mapper
Installation
Add this line to your application's Gemfile:
group :development, :test do
gem 'rspec-ohm'
end
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec-ohm
Usage
Wire up:
RSpec.configure do |config|
config.include RSpec::Ohm, type: :model
end
Matchers
class User < Ohm::Model
end
class Widget < Ohm::Model
attribute :name
index :name
unique :name
set :users, :User
end
RSpec.describe Widget do
it do
expect(subject).to have_attribute(:name)
expect(subject).to have_attribute(:name).with_index
end
it do
expect(subject).to have_set_of(:users).with_index
expect(subject).to have_set_of(:users).with_class(User)
end
it do
expect(subject).to have_unique(:name)
end
end
TODO
- More matchers!
Contributing
- Fork it ( https://github.com/jc00ke/rspec-ohm/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request