forked from jsonapi-rb/jsonapi-rspec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsonapi_object_spec.rb
28 lines (24 loc) · 1.03 KB
/
jsonapi_object_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
RSpec.describe JSONAPI::RSpec, '#have_jsonapi_object' do
context 'when providing no value' do
it 'succeeds when jsonapi object is present' do
expect('jsonapi' => { 'version' => '1.0' }).to have_jsonapi_object
end
it 'fails when jsonapi object is absent' do
expect({}).not_to have_jsonapi_object
end
end
context 'when providing a value' do
it 'succeeds when jsonapi object matches' do
expect('jsonapi' => { 'version' => '1.0' }).to have_jsonapi_object('version' => '1.0')
expect('jsonapi' => { 'version' => '1.0' }).to have_jsonapi_object(version: '1.0')
end
it 'fails when jsonapi object mismatches' do
expect('jsonapi' => { 'version' => '2.0' }).not_to have_jsonapi_object('version' => '1.0')
expect('jsonapi' => { 'version' => '2.0' }).not_to have_jsonapi_object(version: '1.0')
end
it 'fails when jsonapi object is absent' do
expect({}).not_to have_jsonapi_object('version' => '1.0')
expect({}).not_to have_jsonapi_object(version: '1.0')
end
end
end