spec/api-client/collection_spec.rb in api-client-2.5.0 vs spec/api-client/collection_spec.rb in api-client-2.6.0
- old
+ new
@@ -6,10 +6,21 @@
describe '.initialize' do
it 'should save the class in an instance_variable' do
ApiClient::Collection.new([], User).instance_variable_get('@klass').should == User
end
+ context 'with a hash of attributes' do
+ before :each do
+ attributes = { 'users' => [ { :user => { :a => 'a' } }, { :user => { :b => 'b' } } ] }
+ @collection = ApiClient::Collection.new(attributes, User)
+ end
+
+ it 'should initialize a collection of objects' do
+ @collection.size.should == 2
+ end
+ end
+
context 'with a collection of attributes' do
before :each do
attributes = [ { :user => { :a => 'a' } }, { :user => { :b => 'b' } } ]
@collection = ApiClient::Collection.new(attributes, User)
end
@@ -34,9 +45,16 @@
describe '#update' do
before :each do
attributes = [ { :user => { :a => 'a' } }, { :user => { :b => 'b' } } ]
@collection = ApiClient::Collection.new(attributes, User)
end
+
+ context 'with a hash of attributes' do
+ it 'Should update the collection with new objects based on the attributes' do
+ @collection.update({ 'users' => [ { :user => { :a => 'a' } }, { :user => { :b => 'b' } } ] }).size.should == 2
+ end
+ end
+
context 'with a collection of attributes' do
it 'Should update the collection with new objects based on the attributes' do
@collection.update([ { :user => { :a => 'a' } }, { :user => { :b => 'b' } } ]).size.should == 2
end
end
\ No newline at end of file