test/integration_test.rb in roar-0.8.3 vs test/integration_test.rb in roar-0.9.0
- old
+ new
@@ -16,11 +16,11 @@
class Beers
include Roar::Representer::JSON
include Roar::Representer::Feature::Hypermedia
- collection :items, :as => Beer
+ collection :items, :class => Beer
end
describe "Beer service" do
it "provides a document for a particular beer" do
assert_equal "{\"beer\":{\"name\":\"Eisenbahn\",\"links\":[{\"rel\":\"self\",\"href\":\"http://beers/eisenbahn\"}]}}", Beer.from_attributes(name: "Eisenbahn").to_json
@@ -43,11 +43,11 @@
include Roar::Representer::JSON
include Roar::Representer::Feature::Hypermedia
attr_accessor :per_page, :current_page, :all_items
- collection :beers, :as => Beer
+ collection :beers, :class => Beer
property :total
def total
all_items.size
end
@@ -77,9 +77,9 @@
assert_equal "{\"beer_collection\":{\"beers\":[{\"name\":\"Jever\",\"links\":[{\"rel\":\"self\",\"href\":\"http://beers/jever\"}]},{\"name\":\"Becks\",\"links\":[{\"rel\":\"self\",\"href\":\"http://beers/becks\"}]}],\"total\":4,\"links\":[{\"rel\":\"next\",\"href\":\"http://beers/all?page=2\"},{\"rel\":\"prev\"}]}}", list.to_json
list.current_page = 2
- assert_equal "{\"beers\":[{\"name\":\"Eisenbahn\",\"links\":[{\"rel\":\"self\",\"href\":\"http://beers/eisenbahn\"}]},{\"name\":\"Colorado\",\"links\":[{\"rel\":\"self\",\"href\":\"http://beers/colorado\"}]}],\"total\":4,\"links\":[{\"rel\":\"next\"},{\"rel\":\"prev\",\"href\":\"http://beers/all?page=1\"}]}", list.to_json(wrap: false)
+ assert_equal "{\"beer_collection\":{\"beers\":[{\"name\":\"Eisenbahn\",\"links\":[{\"rel\":\"self\",\"href\":\"http://beers/eisenbahn\"}]},{\"name\":\"Colorado\",\"links\":[{\"rel\":\"self\",\"href\":\"http://beers/colorado\"}]}],\"total\":4,\"links\":[{\"rel\":\"next\"},{\"rel\":\"prev\",\"href\":\"http://beers/all?page=1\"}]}}", list.to_json
end
end
end