Sha256: 7aad7d4926b322d3800f313fe46bb408406f2c3eab8d7abb0b8d0047e2686e9a
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'spec_helper' require 'flavors' describe Flavors::Preferences do before do User.class_eval do preference :notification, :default => true end Post.class_eval do preference :sticky, :default => false end end subject { User.create } it "should have a default value" do subject.notification.should == true end it "should update preference" do subject.notification = false subject.notification.should == false end it "should scope preferences for different classes" do expect { subject.sticky }.to raise_error NoMethodError end it "should scope default value for different classes" do Post.class_eval do preference :notification, :default => false end subject.notification.should be_true end it "should return if nil if no default value defined" do User.class_eval do preference :foo end subject.foo.should be_nil end it "should invoke callback block" do User.class_eval do def buz; end preference :bar do |object, value| object.buz end end subject.should_receive(:buz) subject.bar = true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flavors-0.2.0 | spec/preferences_spec.rb |