2010-12-15 17:05:55 -05:00
|
|
|
class FogAttributeTestModel < Fog::Model
|
2010-12-16 14:25:31 -05:00
|
|
|
attribute :key, :aliases => 'keys', :squash => "id"
|
2010-12-15 17:05:55 -05:00
|
|
|
attribute :time, :type => :time
|
2011-10-03 13:30:49 -04:00
|
|
|
attribute :bool, :type => :boolean
|
2010-12-15 17:05:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
Shindo.tests('Fog::Attributes', 'core') do
|
|
|
|
|
|
|
|
@model = FogAttributeTestModel.new
|
|
|
|
|
|
|
|
tests('squash') do
|
|
|
|
|
2010-12-16 14:25:31 -05:00
|
|
|
tests('"keys" => {:id => "value"}').returns('value') do
|
|
|
|
@model.merge_attributes("keys" => {:id => "value"})
|
2010-12-15 17:05:55 -05:00
|
|
|
@model.key
|
|
|
|
end
|
|
|
|
|
2010-12-16 14:25:31 -05:00
|
|
|
tests('"keys" => {"id" => "value"}').returns('value') do
|
|
|
|
@model.merge_attributes("keys" => {'id' => "value"})
|
2010-12-15 17:05:55 -05:00
|
|
|
@model.key
|
|
|
|
end
|
|
|
|
|
2011-07-20 18:18:05 -04:00
|
|
|
tests('"keys" => {"id" => false}').returns(false) do
|
|
|
|
@model.merge_attributes("keys" => {'id' => false })
|
|
|
|
@model.key
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('"keys" => {:id => false}').returns(false) do
|
|
|
|
@model.merge_attributes("keys" => {:id => false })
|
|
|
|
@model.key
|
|
|
|
end
|
2010-12-15 17:05:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
tests(':type => :time') do
|
|
|
|
|
|
|
|
@time = Time.now
|
|
|
|
|
|
|
|
tests(':time => nil').returns(nil) do
|
|
|
|
@model.merge_attributes(:time => nil)
|
|
|
|
@model.time
|
|
|
|
end
|
|
|
|
|
|
|
|
tests(':time => ""').returns('') do
|
|
|
|
@model.merge_attributes(:time => '')
|
|
|
|
@model.time
|
|
|
|
end
|
|
|
|
|
|
|
|
tests(':time => "#{@time.to_s}"').returns(Time.parse(@time.to_s)) do
|
|
|
|
@model.merge_attributes(:time => @time.to_s)
|
|
|
|
@model.time
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-10-03 13:30:49 -04:00
|
|
|
tests(':type => :boolean') do
|
|
|
|
tests(':bool => "true"').returns(true) do
|
|
|
|
@model.merge_attributes(:bool => 'true')
|
|
|
|
@model.bool
|
|
|
|
end
|
|
|
|
|
|
|
|
tests(':bool => true').returns(true) do
|
|
|
|
@model.merge_attributes(:bool => true)
|
|
|
|
@model.bool
|
|
|
|
end
|
2014-05-26 09:44:18 -04:00
|
|
|
|
2011-10-03 13:30:49 -04:00
|
|
|
tests(':bool => "false"').returns(false) do
|
|
|
|
@model.merge_attributes(:bool => 'false')
|
|
|
|
@model.bool
|
|
|
|
end
|
|
|
|
|
|
|
|
tests(':bool => false').returns(false) do
|
|
|
|
@model.merge_attributes(:bool => false)
|
|
|
|
@model.bool
|
|
|
|
end
|
|
|
|
|
|
|
|
tests(':bool => "foo"').returns(nil) do
|
|
|
|
@model.merge_attributes(:bool => "foo")
|
|
|
|
@model.bool
|
|
|
|
end
|
2014-05-26 09:44:18 -04:00
|
|
|
|
2011-10-03 13:30:49 -04:00
|
|
|
end
|
|
|
|
|
2011-07-20 18:18:05 -04:00
|
|
|
end
|