spec/integration/formats/json_api_spec.rb in ivy-serializers-0.3.0 vs spec/integration/formats/json_api_spec.rb in ivy-serializers-0.4.0
- old
+ new
@@ -14,10 +14,12 @@
let(:post) { double('post', :class => post_class, :id => 1) }
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1'
}
@@ -25,10 +27,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1'
}]
@@ -48,10 +52,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:attributes => {
@@ -62,10 +68,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:attributes => {
@@ -84,10 +92,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:attributes => {
@@ -98,10 +108,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:attributes => {
@@ -127,10 +139,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -142,10 +156,12 @@
}) }
context 'with no related resource' do
let(:author) { nil }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -157,10 +173,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:relationships => {
@@ -181,10 +199,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -196,10 +216,12 @@
}) }
context 'with no related resource' do
let(:author) { nil }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -211,10 +233,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:relationships => {
@@ -235,10 +259,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -246,21 +272,21 @@
:data => {:id => '1', :type => 'author'}
}
}
},
- :included => {
- :authors => [{
- :id => '1',
- :type => 'author'
- }]
- }
+ :included => [{
+ :id => '1',
+ :type => 'author'
+ }]
}) }
context 'with no related resource' do
let(:author) { nil }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -272,10 +298,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:relationships => {
@@ -283,16 +311,14 @@
:data => {:id => '1', :type => 'author'}
}
}
}],
- :included => {
- :authors => [{
- :id => '1',
- :type => 'author'
- }]
- }
+ :included => [{
+ :id => '1',
+ :type => 'author'
+ }]
}) }
end
end
context 'with the :polymorphic option' do
@@ -303,10 +329,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -318,10 +346,12 @@
}) }
context 'with no related resource' do
let(:author) { nil }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -333,10 +363,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:relationships => {
@@ -364,10 +396,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -380,10 +414,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:relationships => {
@@ -404,10 +440,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -420,10 +458,12 @@
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:relationships => {
@@ -444,10 +484,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -455,22 +497,22 @@
:data => [{:id => '1', :type => 'comment'}]
}
}
},
- :included => {
- :comments => [{
- :type => 'comment',
- :id => '1'
- }]
- }
+ :included => [{
+ :type => 'comment',
+ :id => '1'
+ }]
}) }
end
context 'for a resource collection' do
let(:resource) { [post] }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => [{
:type => 'post',
:id => '1',
:relationships => {
@@ -478,16 +520,14 @@
:data => [{:id => '1', :type => 'comment'}]
}
}
}],
- :included => {
- :comments => [{
- :type => 'comment',
- :id => '1'
- }]
- }
+ :included => [{
+ :type => 'comment',
+ :id => '1'
+ }]
}) }
end
end
context 'with the :polymorphic option' do
@@ -498,10 +538,12 @@
end
context 'for an individual resource' do
let(:resource) { post }
+ it { should match_json_schema(:json_api) }
+
it { should eq({
:data => {
:type => 'post',
:id => '1',
:relationships => {
@@ -513,9 +555,11 @@
}) }
end
context 'for a resource collection' do
let(:resource) { [post] }
+
+ it { should match_json_schema(:json_api) }
it { should eq({
:data => [{
:type => 'post',
:id => '1',