spec/model_spec.rb in cistern-2.2.4 vs spec/model_spec.rb in cistern-2.2.5
- old
+ new
@@ -93,10 +93,11 @@
attribute :butternut_type, squash: %w(squash type)
attribute :squash
attribute :vegetable, aliases: 'squash'
attribute :custom, parser: lambda { |v, _| "X!#{v}" }
attribute :default, default: 'im a squash'
+ attribute :string_allow_nil, type: :string, allow_nil: true
attribute :same_alias_1, aliases: 'nested'
attribute :same_alias_2, aliases: 'nested'
attribute :same_alias_squashed_1, squash: %w(nested attr_1)
@@ -109,11 +110,16 @@
end
end
it 'should parse string' do
expect(TypeSpec.new(name: 1).name).to eq('1')
+ expect(TypeSpec.new(name: "b").name).to eq('b')
+ expect(TypeSpec.new(name: nil).name).to eq("")
end
+ it 'should allow nils in string types' do
+ expect(TypeSpec.new(string_allow_nil: nil).string_allow_nil).to eq(nil)
+ end
it "should handle a 'attributes' aliased attribute" do
expect(TypeSpec.new(attributes: 'x').adam_attributes).to eq('x')
end
it 'should parse time' do