test/collection_json_test.rb in roar-0.12.9 vs test/collection_json_test.rb in roar-1.0.0.beta1
- old
+ new
@@ -1,12 +1,12 @@
require 'test_helper'
-require 'roar/representer/json/collection_json'
+require 'roar/json/collection_json'
class CollectionJsonTest < MiniTest::Spec
let(:song) { OpenStruct.new(:title => "scarifice", :length => 43) }
- representer_for([Roar::Representer::JSON::CollectionJSON]) do
+ representer_for([Roar::JSON::CollectionJSON]) do
version "1.0"
href { "//songs/" }
link(:feed) { "//songs/feed" }
@@ -32,15 +32,13 @@
end
end
describe "#to_json" do
it "renders document" do
- collection_key = Representable::VERSION =~ /^1.8/ ? "collection" : :collection
-
[song].extend(rpr).to_hash.must_equal(
{
- collection_key=>{
+ "collection"=>{
"version"=>"1.0",
"href"=>"//songs/",
"template"=>{
:data=>[
@@ -48,32 +46,32 @@
{:name=>"length", :value=>nil}
]
},
"queries"=>[
- {:rel=>:search, :href=>"//search",
- :data=>[
+ {"rel"=>"search", "href"=>"//search",
+ "data"=>[
{:name=>"q", :value=>""}
]
}
],
"items"=>[
{
"links"=>[
- {:rel=>:download, :href=>"//songs/scarifice.mp3"},
- {:rel=>:stats, :href=>"//songs/scarifice/stats"}
+ {"rel"=>"download", "href"=>"//songs/scarifice.mp3"},
+ {"rel"=>"stats", "href"=>"//songs/scarifice/stats"}
],
"href"=>"//songs/scarifice",
:data=>[
{:name=>"title", :value=>"scarifice"},
{:name=>"length", :value=>43}
]
}
],
"links"=>[
- {:rel=>:feed, :href=>"//songs/feed"}
+ {"rel"=>"feed", "href"=>"//songs/feed"}
]
}
})# %{{"collection":{"version":"1.0","href":"//songs/","items":[{"href":"//songs/scarifice","links":[{"rel":"download","href":"//songs/scarifice.mp3"},{"rel":"stats","href":"//songs/scarifice/stats"}],"data":[{"name":"title","value":"scarifice"},{"name":"length","value":43}]}],"template":{"data":[{"name":"title","value":null},{"name":"length","value":null}]},"queries":[{"rel":"search","href":"//search","data":[{"name":"q","value":""}]}],"links":[{"rel":"feed","href":"//songs/feed"}]}}}
end
end
\ No newline at end of file