Sha256: 63c421b3ea292760bb35eee6c892c5d0dabca2da7bb24a88841e153189a9cba2

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')


class Sample < ActiveRecord::Base

  define_attribute_methods ['foo', 'bar', 'buzz', 'other']
  attr_accessor :foo, :bar, :buzz, :other

  default_values do
    lambda do
      {
        :foo => 'foo',
        :bar => 'bar',
        :time => Time.now
      }
    end
  end
end

describe "ArDefaultValues" do
  subject { @sample }
  before do
    @t = Time.now
    Time.stub(:now).and_return(@t)
    @sample = Sample.new(:bar => 'test')
  end
  its(:foo) { should == 'foo' }
  its(:bar) { should == 'test' }
  its(:buzz) { should be_nil }
  its(:time) { should == @t }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ar_default_values-0.1.0 spec/ar_default_values_spec.rb