Sha256: 362a3ac7b03128bfd2a1323507370c4f561c2fc046146a4ab49be3d9f1c6d416

Contents?: true

Size: 1.88 KB

Versions: 100

Compression:

Stored size: 1.88 KB

Contents

class FogAttributeTestModel < Fog::Model
  attribute :key, :aliases => 'keys', :squash => "id"
  attribute :time, :type => :time
  attribute :bool, :type => :boolean
end

Shindo.tests('Fog::Attributes', 'core') do

  @model = FogAttributeTestModel.new

  tests('squash') do

    tests('"keys" => {:id => "value"}').returns('value') do
      @model.merge_attributes("keys" => {:id => "value"})
      @model.key
    end

    tests('"keys" => {"id" => "value"}').returns('value') do
      @model.merge_attributes("keys" => {'id' => "value"})
      @model.key
    end

    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
  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

  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
    
    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
  
  end

end

Version data entries

100 entries across 100 versions & 17 rubygems

Version Path
fog-1.22.0 tests/core/attribute_tests.rb
fog-1.21.0 tests/core/attribute_tests.rb
fog-maestrodev-1.20.0.20140305101839 tests/core/attribute_tests.rb
fog-maestrodev-1.20.0.20140305101305 tests/core/attribute_tests.rb
fog-maestrodev-1.19.0.20140212012611 tests/core/attribute_tests.rb
fog-1.20.0 tests/core/attribute_tests.rb
fog-maestrodev-1.19.0.20140110004459 tests/core/attribute_tests.rb
fog-maestrodev-1.19.0.20140110003812 tests/core/attribute_tests.rb
fog-maestrodev-1.19.0.20140109202555 tests/core/attribute_tests.rb
fog-maestrodev-1.19.0.20140107192102 tests/core/attribute_tests.rb
fog-maestrodev-1.19.0.20140107142106 tests/core/attribute_tests.rb
fog-maestrodev-1.19.0.20131219203941 tests/core/attribute_tests.rb
fog-maestrodev-1.18.0.20131219193542 tests/core/attribute_tests.rb
fog-1.19.0 tests/core/attribute_tests.rb
fog-maestrodev-1.18.0.20131219033443 tests/core/attribute_tests.rb
fog-maestrodev-1.18.0.20131219032002 tests/core/attribute_tests.rb
fog-maestrodev-1.18.0.20131219030716 tests/core/attribute_tests.rb
fog-maestrodev-1.18.0.20131219022322 tests/core/attribute_tests.rb
fog-maestrodev-1.18.0.20131218202447 tests/core/attribute_tests.rb
fog-maestrodev-1.18.0.20131209091424 tests/core/attribute_tests.rb