spec/unit/yaks/format/collection_json_spec.rb in yaks-0.9.0 vs spec/unit/yaks/format/collection_json_spec.rb in yaks-0.10.0
- old
+ new
@@ -5,11 +5,11 @@
subject { Yaks::Primitivize.create.call(described_class.new.call(resource)) }
it { should deep_eql(load_json_fixture('plant_collection.collection')) }
end
- context '#links?' do
+ describe '#links?' do
context 'when resource is not a collection' do
let(:resource) {
Yaks::Resource.new(
attributes: {foo: 'fooval', bar: 'barval'},
links: [Yaks::Resource::Link.new(rel: 'the_rel', uri: 'the_uri')]
@@ -50,11 +50,11 @@
end
end
end
end
- context '#queries?' do
+ describe '#queries?' do
let(:resource) {
Yaks::Resource.new(
attributes: {foo: 'fooval', bar: 'barval'},
forms: [Yaks::Resource::Form.new(full_args)]
)
@@ -122,11 +122,11 @@
expect(cj.queries?(resource)).to eq false
end
end
end
- context '#template?' do
+ describe '#template?' do
context 'when no template form has been specified' do
let(:format) {
described_class.new
}
@@ -142,18 +142,18 @@
end
end
context 'when a template form has been specified' do
let(:format) {
- described_class.new(:template => :template_form_name)
+ described_class.new(template: :template_form_name)
}
context 'and the form is not present' do
let(:resource) {
Yaks::Resource.new(
- attributes: {foo: 'fooval', bar: 'barval'},
- forms: [Yaks::Resource::Form.new(name: :not_the_form_name)]
+ attributes: {foo: 'fooval', bar: 'barval'},
+ forms: [Yaks::Resource::Form.new(name: :not_the_form_name)]
)
}
subject {
Yaks::Primitivize.create.call(format.call(resource))
@@ -165,12 +165,12 @@
end
context 'and the form is present' do
let(:resource) {
Yaks::Resource.new(
- attributes: {foo: 'fooval', bar: 'barval'},
- forms: [Yaks::Resource::Form.new(name: :template_form_name)]
+ attributes: {foo: 'fooval', bar: 'barval'},
+ forms: [Yaks::Resource::Form.new(name: :template_form_name)]
)
}
subject {
Yaks::Primitivize.create.call(format.call(resource))
@@ -181,11 +181,11 @@
end
end
end
end
- context 'serialize_links' do
+ describe '#serialize_links' do
context 'without title' do
let(:resource) {
Yaks::Resource.new(
attributes: {foo: 'fooval', bar: 'barval'},
links: [Yaks::Resource::Link.new(rel: 'the_rel', uri: 'the_uri')]
@@ -201,14 +201,14 @@
"collection" => {
"version" => "1.0",
"items" => [
{
"data" => [
- { "name"=>"foo", "value"=>"fooval" },
- { "name"=>"bar", "value"=>"barval" }
+ {"name" => "foo", "value" => "fooval"},
+ {"name" => "bar", "value" => "barval"}
],
- "links" => [{"rel"=>"the_rel", "href"=>"the_uri"}]
+ "links" => [{"rel" => "the_rel", "href" => "the_uri"}]
}
]
}
)
end
@@ -231,23 +231,23 @@
"collection" => {
"version" => "1.0",
"items" => [
{
"data" => [
- { "name"=>"foo", "value"=>"fooval" },
- { "name"=>"bar", "value"=>"barval" }
+ {"name" => "foo", "value" => "fooval"},
+ {"name" => "bar", "value" => "barval"}
],
- "links" => [{"name"=>"the_name", "rel"=>"the_rel", "href"=>"the_uri"}]
+ "links" => [{"name" => "the_name", "rel" => "the_rel", "href" => "the_uri"}]
}
]
}
)
end
end
end
- context 'serialize_queries' do
+ describe '#serialize_queries' do
let(:resource) {
Yaks::Resource.new(
attributes: {foo: 'fooval', bar: 'barval'},
forms: [
Yaks::Resource::Form.new(full_args),
@@ -275,17 +275,17 @@
"collection" => {
"version" => "1.0",
"items" => [
{
"data" => [
- { "name"=>"foo", "value"=>"fooval" },
- { "name"=>"bar", "value"=>"barval" }
+ {"name" => "foo", "value" => "fooval"},
+ {"name" => "bar", "value" => "barval"}
]
}
],
"queries" => [
- { "href"=>"/foo", "rel"=>"search" }
+ {"href" => "/foo", "rel" => "search"}
]
}
)
end
end
@@ -313,34 +313,33 @@
"collection" => {
"version" => "1.0",
"items" => [
{
"data" => [
- { "name"=>"foo", "value"=>"fooval" },
- { "name"=>"bar", "value"=>"barval" }
+ {"name" => "foo", "value" => "fooval"},
+ {"name" => "bar", "value" => "barval"}
]
}
],
"queries" => [
- { "href"=>"/foo", "rel"=>"search", "prompt"=>"My query prompt",
- "data"=>
- [
- { "name"=>"foo", "value"=>"" },
- { "name"=>"bar", "value"=>"", "prompt"=>"My Bar Field" }
+ {"href" => "/foo", "rel" => "search", "prompt" => "My query prompt",
+ "data" => [
+ {"name" => "foo", "value" => ""},
+ {"name" => "bar", "value" => "", "prompt" => "My Bar Field"}
]
}
]
}
)
end
end
end
end
- context 'serialize_template' do
+ describe '#serialize_template' do
let(:format) {
- described_class.new(:template => :form_for_new)
+ described_class.new(template: :form_for_new)
}
let(:resource) {
Yaks::Resource.new(
attributes: {foo: 'fooval', bar: 'barval'},
@@ -365,19 +364,19 @@
"collection" => {
"version" => "1.0",
"items" => [
{
"data" => [
- { "name"=>"foo", "value"=>"fooval" },
- { "name"=>"bar", "value"=>"barval" }
+ {"name" => "foo", "value" => "fooval"},
+ {"name" => "bar", "value" => "barval"}
]
}
],
"template" => {
"data" => [
- { "name"=>"foo", "value"=>"", "prompt"=>"My Foo Field" },
- { "name"=>"bar", "value"=>"", "prompt"=>"My Bar Field" }
+ {"name" => "foo", "value" => "", "prompt" => "My Foo Field"},
+ {"name" => "bar", "value" => "", "prompt" => "My Bar Field"}
]
}
}
)
end
@@ -396,18 +395,18 @@
"collection" => {
"version" => "1.0",
"items" => [
{
"data" => [
- { "name"=>"foo", "value"=>"fooval" },
- { "name"=>"bar", "value"=>"barval" }
+ {"name" => "foo", "value" => "fooval"},
+ {"name" => "bar", "value" => "barval"}
]
}
],
"template" => {
"data" => [
- { "name"=>"foo", "value"=>"" },
- { "name"=>"bar", "value"=>"" }
+ {"name" => "foo", "value" => ""},
+ {"name" => "bar", "value" => ""}
]
}
}
)
end