-
Notifications
You must be signed in to change notification settings - Fork 23
Allow jsonapi-rspec to match Symbol or String based source documents #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cc96afb
Create .rspec file and remove require 'spec_helper' from all specs
sa73917 0168682
Create allow_symbolized_jsonapi config and as_indifferent_hash method
sa73917 b29bfae
Incorporate as_indifferent_hash into all matchers
sa73917 3d20cd2
Add new cops to .rubocop.yml to remove warnings.
sa73917 894e393
Refactor attributes spec
sa73917 1cc464c
Refactor links spec
sa73917 28d8ff0
Create relationships spec based on attributes and links spec
sa73917 ab38070
Standardise id spec and add symbolized source doc
sa73917 5116a07
Refactor id spec
sa73917 988bc9e
Refactor jsonapi spec
sa73917 865ff4b
Refactor meta spec
sa73917 63c8ab5
Refactor type spec
sa73917 88ad5f8
Add rspec_spec and sample document
sa73917 a66499b
Add indifferent matching configuration option to the README.md
sa73917 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--require ./spec/spec_helper.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe JSONAPI::RSpec do | ||
let(:doc) do | ||
json_doc = | ||
{ | ||
'attributes' => { | ||
'one' => 1, | ||
'two' => 2, | ||
'four' => 3 | ||
} | ||
} | ||
end | ||
|
||
describe '#have_attribute' do | ||
it { expect(doc).to have_attribute(:one) } | ||
it { expect(doc).not_to have_attribute(:five) } | ||
context 'when attributes is present' do | ||
it { expect(json_doc).to have_attribute(:one) } | ||
it { expect(json_doc).not_to have_attribute(:five) } | ||
end | ||
|
||
context 'when attributes is not present' do | ||
it { expect({}).not_to have_attribute(:one) } | ||
end | ||
end | ||
|
||
describe '#have_jsonapi_attributes' do | ||
it { expect(doc).to have_jsonapi_attributes(:one, :two) } | ||
it { expect(doc).not_to have_jsonapi_attributes(:two, :five) } | ||
it { expect(doc).to have_jsonapi_attributes(:one, :two, :four).exactly } | ||
it { expect(doc).not_to have_jsonapi_attributes(:one).exactly } | ||
context 'when attributes is present' do | ||
it { expect(json_doc).to have_jsonapi_attributes(:one, 'two') } | ||
it { expect(json_doc).not_to have_jsonapi_attributes(:two, 'five') } | ||
it { expect(json_doc).to have_jsonapi_attributes(:one, :two, 'four').exactly } | ||
it { expect(json_doc).not_to have_jsonapi_attributes(:one).exactly } | ||
end | ||
|
||
context 'when attributes is not present' do | ||
it { expect({}).not_to have_jsonapi_attributes(:one, 'two') } | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe JSONAPI::RSpec, '#have_id' do | ||
it 'succeeds when id matches' do | ||
expect('id' => 'foo').to have_id('foo') | ||
end | ||
|
||
it 'fails when id mismatches' do | ||
expect('id' => 'foo').not_to have_id('bar') | ||
end | ||
json_doc = | ||
{ | ||
'id' => 'foo' | ||
} | ||
|
||
it 'fails when id is absent' do | ||
expect({}).not_to have_id('foo') | ||
describe '#have_id' do | ||
context 'when id is present' do | ||
it { expect(json_doc).to have_id('foo') } | ||
it { expect(json_doc).not_to have_id('bar') } | ||
end | ||
context 'when id is not present' do | ||
it { expect({}).not_to have_id('foo') } | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
require 'spec_helper' | ||
RSpec.describe JSONAPI::RSpec do | ||
json_doc = | ||
{ | ||
'jsonapi' => { | ||
'version' => '1.0' | ||
} | ||
} | ||
|
||
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 | ||
describe '#have_jsonapi_object' do | ||
context 'when jsonapi is present' do | ||
it { expect(json_doc).to have_jsonapi_object } | ||
it { expect(json_doc).to have_jsonapi_object('version' => '1.0') } | ||
it { expect(json_doc).not_to have_jsonapi_object('version' => '2.0') } | ||
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') | ||
end | ||
|
||
it 'fails when jsonapi object mismatches' do | ||
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') | ||
context 'when jsonapi is not present' do | ||
it { expect({}).not_to have_jsonapi_object } | ||
it { expect({}).not_to have_jsonapi_object('version' => '1.0') } | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe JSONAPI::RSpec do | ||
let(:doc) do | ||
json_doc = | ||
{ | ||
'links' => { | ||
'self' => 'self_link', | ||
'related' => 'related_link' | ||
} | ||
} | ||
end | ||
|
||
context '#have_link' do | ||
it { expect(doc).to have_link(:self) } | ||
it { expect(doc).to have_link(:self).with_value('self_link') } | ||
it { expect(doc).not_to have_link(:self).with_value('any_link') } | ||
it { expect(doc).not_to have_link(:any) } | ||
describe '#have_link' do | ||
context 'when links is present' do | ||
it { expect(json_doc).to have_link(:self) } | ||
it { expect(json_doc).to have_link(:self).with_value('self_link') } | ||
it { expect(json_doc).not_to have_link(:self).with_value('any_link') } | ||
it { expect(json_doc).not_to have_link(:any) } | ||
end | ||
|
||
context 'when links is not present' do | ||
it { expect({}).not_to have_link(:self) } | ||
end | ||
end | ||
|
||
context '#have_links' do | ||
it { expect(doc).to have_links(:self, :related) } | ||
it { expect(doc).not_to have_links(:self, :other) } | ||
describe '#have_links' do | ||
context 'when links is present' do | ||
it { expect(json_doc).to have_links(:self, 'related') } | ||
it { expect(json_doc).not_to have_links(:self, 'other') } | ||
end | ||
|
||
context 'when links is not present' do | ||
it { expect({}).not_to have_links(:self, 'related') } | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,21 @@ | ||
require 'spec_helper' | ||
RSpec.describe JSONAPI::RSpec do | ||
json_doc = | ||
{ | ||
'meta' => { | ||
'foo' => 'bar' | ||
} | ||
} | ||
|
||
RSpec.describe JSONAPI::RSpec, '#have_meta' do | ||
context 'when providing no value' do | ||
it 'succeeds when meta is present' do | ||
expect('meta' => {}).to have_meta | ||
describe '#have_meta' do | ||
context 'when meta is present' do | ||
it { expect(json_doc).to have_meta } | ||
it { expect(json_doc).to have_meta('foo' => 'bar') } | ||
it { expect(json_doc).not_to have_meta('foo' => 'baz') } | ||
end | ||
|
||
it 'fails when meta is absent' do | ||
expect({}).not_to have_meta | ||
end | ||
end | ||
|
||
context 'when providing a value' do | ||
it 'succeeds when meta matches' do | ||
expect('meta' => { foo: 'bar' }).to have_meta(foo: 'bar') | ||
end | ||
|
||
it 'fails when meta mismatches' do | ||
expect('meta' => { foo: 'bar' }).not_to have_meta(bar: 'baz') | ||
end | ||
|
||
it 'fails when meta is absent' do | ||
expect({}).not_to have_meta(foo: 'bar') | ||
context 'when meta is not present' do | ||
it { expect({}).not_to have_meta } | ||
it { expect({}).not_to have_meta('foo' => 'bar') } | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.