Name: jsonapi-rspec
Owner: DaWanda Engineering Team
Description: RSpec matchers for JSON API
Forked from: jsonapi-rb/jsonapi-rspec
Created: 2017-10-09 08:30:14.0
Updated: 2017-10-09 08:30:16.0
Pushed: 2017-10-09 10:33:14.0
Homepage: null
Size: 11
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
RSpec matchers for JSON API.
Add the following to your application's Gemfile:
'jsonapi-rspec'
And then execute:
ndle
Add to your spec/spec_helpers.rb
:
ire 'jsonapi/rspec'
c.configure do |config|
...
nfig.include JSONAPI::RSpec
Available matchers:
expect(document['data']).to have_id('12')
expect(document['data']).to have_type('users')
expect(document['data']).to have_attributes(:name, :email)
expect(document['data']).to have_attribute(:name).with_value('Lucas')
expect(document['data']).to have_relationships(:posts, :comments)
expect(document['data']).to have_relationship(:posts).with_data([{ 'id' => '1', 'type' => 'posts' }])
expect(document['data']['relationships']['posts']).to have_links(:self, :related)
expect(document['data']).to have_link(:self).with_value('http://api.example.com/users/12')
expect(document).to have_meta
expect(document).to have_meta('foo' => 'bar')
expect(document).to have_jsonapi_object
expect(document).to have_jsonapi_object('version' => '1.0')
Checking for an included resource:
ct(response_body['included'])
o include(have_type('posts').and have_id('1'))
jsonapi-rspec is released under the MIT License.