Sha256: 1423fc90dbb1557ce5fb3401fa25c3c0f64856145f4f14fc9b585b2626f25faa
Contents?: true
Size: 1.52 KB
Versions: 7
Compression:
Stored size: 1.52 KB
Contents
require File.dirname(__FILE__) + '/../test_helper.rb' context "basic types converter" do teardown { reset_config } specify "should raise exception if not all array contents respond to .to_restful" do Person.restful_publish(:name) should.raise(TypeError) do [""].to_restful end end specify "should convert an empty array to a restful collection" do collection = [].to_restful collection.name.should.== "nil-classes" end specify "should convert an array to a restful collection" do Person.restful_publish(:name) collection = [Person.create(:name => "Joe Bloggs")].to_restful collection.name.should.== "people" collection.value.size.should.== 1 collection.value.first.simple_attributes.first.value.should.== "Joe Bloggs" end specify "should set total_entries on the restful collection if the array responds to this" do Person.restful_publish(:name) people = PaginatedCollection.new([Person.create(:name => "Joe Bloggs")]) people.total_entries = 1001 collection = people.to_restful collection.total_entries.should.== 1001 end specify "should be able to convert a hash to a resource map" do Person.restful_publish(:name) resource = { "zeperson" => @person = Person.create(:name => "fuddzle") }.to_restful resource.should.is_a?(Restful::ApiModel::Map) attrs = resource.simple_attributes attrs.size.should.== 1 attrs.first.name.should.== "zeperson" attrs.first.value.values.first.value.== "fuddzle" end end
Version data entries
7 entries across 7 versions & 2 rubygems