spec/public/to_json_spec.rb in dm-serializer-0.9.11 vs spec/public/to_json_spec.rb in dm-serializer-0.10.0

- old
+ new

@@ -1,20 +1,23 @@ -require 'pathname' -require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper' +require 'spec_helper' describe DataMapper::Serialize, '#to_json' do # # ==== ajaxy JSON # before(:all) do DataMapper.auto_migrate! query = DataMapper::Query.new(DataMapper::repository(:default), Cow) - @collection = DataMapper::Collection.new(query) do |c| - c.load([1, 2, 'Betsy', 'Jersey']) - c.load([10, 20, 'Berta', 'Guernsey']) - end + keys = %w[ id composite name breed ] + + resources = [ + keys.zip([ 1, 2, 'Betsy', 'Jersey' ]).to_hash, + keys.zip([ 10, 20, 'Berta', 'Guernsey' ]).to_hash, + ] + + @collection = DataMapper::Collection.new(query, query.model.load(resources, query)) @harness = Class.new(SerializerTestHarness) do def method_name :to_json end