Sha256: dcff0525e12955c5177b3ef31161d3b3414ab39c52c8e1668ff483f0da29423f
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
require 'spec_helper' require 'kangaroo/model/base' module Kangaroo module Model describe DefaultAttributes do before :all do @klass = Class.new(Kangaroo::Model::Base) @klass.define_multiple_accessors :a, :b end it 'sets default values on initialization' do @klass.stub!(:default_attributes).and_return(:a => 'one') @object = @klass.new @object.a.should == 'one' @object.should be_a_changed end it 'sets default values before initial values' do @klass.stub!(:default_attributes).and_return(:a => 'one') @object = @klass.new :a => 'two' @object.a.should == 'two' end it 'fetches default values via default_get on the object service' do @klass = Class.new(Kangaroo::Model::Base) @klass.define_multiple_accessors :a, :b @klass.field_names = %w(a b) @klass.stub!(:remote).and_return mock('object_service') @klass.remote.should_receive(:default_get).with(%w(a b), anything).and_return :a => 'one', :b => 'two' @object = @klass.new @object.a.should == 'one' @object.b.should == 'two' end end end end
Version data entries
4 entries across 4 versions & 1 rubygems