Sha256: 8ab8654f42d02505f9f17db9f2bb2147aad6dc0215870bf5fdc1f954a0e72892
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') class Book < ActiveRecord::Base default_values do lambda do { :price => 0, :edition => 1, :released_at => Time.now } end end end describe "ArDefaultValues" do subject { @sample } before do @now = Time.now Time.stub(:now).and_return(@now) end context :without_attributes do before do @sample = Book.new end its(:title) { should be_nil } its(:price) { should == 0 } its(:edition) { should == 1 } its(:released_at) { should == @now } end context :with_attributes do before do @sample = Book.new(:price => 100) end its(:title) { should be_nil } its(:price) { should == 100 } its(:edition) { should == 1 } its(:released_at) { should == @now } end context :with_block do before do @sample = Book.new(:edition => 3) do |t| t.title = 'foo' end end its(:title) { should == 'foo' } its(:price) { should == 0 } its(:edition) { should == 3 } its(:released_at) { should == @now } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ar_default_values-0.1.1 | spec/ar_default_values_spec.rb |