Skip to content

Commit 2bedd7f

Browse files
committed
Standardise type spec and add symbolized source doc
Refactored the type spec to align it with the pattern provided in the links and attributes specs. Incorporate symbolized source document tests inline with the attributes and relationships specs
1 parent 1386cb7 commit 2bedd7f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

spec/jsonapi/type_spec.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
RSpec.describe JSONAPI::RSpec, '#have_type' do
2-
it 'succeeds when type matches' do
3-
expect('type' => 'foo').to have_type('foo')
4-
end
2+
json_doc = { 'type' => 'foo' }
3+
symbol_doc = { type: 'foo' }
54

6-
it 'fails when type mismatches' do
7-
expect('type' => 'foo').not_to have_type('bar')
8-
end
5+
describe '#have_id' do
6+
[json_doc, symbol_doc].each do |doc|
7+
subject { doc }
8+
before(:each) { RSpec.configuration.allow_symbolized_jsonapi = (doc == symbol_doc) }
99

10-
it 'fails when type is absent' do
11-
expect({}).not_to have_type('foo')
10+
it { is_expected.to have_type('foo') }
11+
it { is_expected.not_to have_type('bar') }
12+
end
13+
it 'is expected not to have id "foo" when id is not present' do
14+
expect({}).not_to have_id('foo')
15+
end
1216
end
1317
end

0 commit comments

Comments
 (0)