Sha256: b8371fa6ea259d473ef342c94a6cce62ef167ae2d2def415c265c151aff20cdd
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'cached_column' require 'nulldb' ActiveRecord::Base.establish_connection :adapter => :nulldb, :schema => File.expand_path("../schema.rb", __FILE__) describe CachedColumn do let :model do Class.new(ActiveRecord::Base) do self.table_name = 'test' def cached_column(value = 42) value end def calculating_method 43 end end end describe "when saving" do it "sets the attribute value to the result of the method of the same name" do model.cached_column :cached_column instance = model.new instance.save instance[:cached_column].should == 42 end it "sets the attribute value to the result of the specified method" do model.cached_column :cached_column, :method => :calculating_method instance = model.new instance.save instance[:cached_column].should == 43 end it "allows the original method to be called" do model.cached_column :cached_column instance = model.new instance.save instance.cached_column(44).should == 44 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cached_column-0.1 | spec/cached_column_spec.rb |