RSpec matchers for ActiveModel::Serializers
RSpec Matchers for testing ActiveModel::Serializers
This gem currently works with the 0.1.0 release. It will be updated for the next public release when that happens.
Add this line to your application's Gemfile:
gem 'active_model_serializer-matchers'
And then execute:
$ bundle
Or install it yourself as:
$ gem install active_model_serializer-matchers
Matchers are automatically included in all specs in spec/serializers
.
Here are some examples
describe BlogPostSerializer do
it { should have_attribute(:title) }
it { should have_attribute(:text) }
it { should have_one(:author) }
it { should have_many(:comments) }
it { should have_many(:comments).as(:responses) }
it { should embed(:objects) }
it { should include_root }
it { should include_root(:blog_post) } # if you want to test the root is specifically set to a different value
end
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)