spec/hashme/properties_spec.rb in hashme-0.2.6 vs spec/hashme/properties_spec.rb in hashme-0.3.0
- old
+ new
@@ -1,9 +1,9 @@
require 'spec_helper'
describe Hashme::Properties do
-
+
before :all do
@aux_model = Class.new do
include Hashme
property :age, Fixnum
end
@@ -37,11 +37,11 @@
end
it "should set and cast attribute with property" do
property = model.send(:properties)[:name]
name = "Fred Flinstone"
- expect(property).to receive(:build).with(obj, name).and_return(name)
+ expect(property).to receive(:build).with(name).and_return(name)
obj.set_attribute(:name, name)
expect(obj[:name]).to eql(name)
end
it "should delete attribute set to nil" do
@@ -109,13 +109,19 @@
expect(obj).to respond_to(:desc=)
obj.desc = "test"
expect(obj.desc).to eql("test")
end
-
+
it "should return nil on property with no default" do
model.property :nickname, String
expect(obj.nickname).to be_nil
+ end
+
+ it 'should not return the default value when a Boolean is set to false' do
+ model.property :flag, TrueClass, :default => true
+ obj.flag = false
+ expect(obj.flag).to be(false)
end
it "should create helper method with support for default values" do
model.property :name, String, :default => "Sam"
expect(obj.name).to eql("Sam")