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.10.1 tests/core/attribute_tests.rb
fog-parser-fix-1.6.1 tests/core/attribute_tests.rb
fog-test-again-1.6.0 tests/core/attribute_tests.rb
fog-test-me-1.10.0 tests/core/attribute_tests.rb
fog-parser-fix-1.6.0 tests/core/attribute_tests.rb
fog-1.10.0 tests/core/attribute_tests.rb
fog-1.9.0 tests/core/attribute_tests.rb
fog-maestrodev-1.8.0.20130114204828 tests/core/attribute_tests.rb
fog-maestrodev-1.8.0.20130111070250 tests/core/attribute_tests.rb
fog-maestrodev-1.8.0.20130109172219 tests/core/attribute_tests.rb
fog-sgonyea-1.8.1 tests/core/attribute_tests.rb
fog-1.8.0 tests/core/attribute_tests.rb
fog-maestrodev-1.7.0.20121114190951 tests/core/attribute_tests.rb
fog-1.7.0 tests/core/attribute_tests.rb
fog-1.6.0 tests/core/attribute_tests.rb
fog-1.5.0 tests/core/attribute_tests.rb
rackspace-fog-1.4.2 tests/core/attribute_tests.rb
fog-1.4.0 tests/core/attribute_tests.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/tests/core/attribute_tests.rb
michiels-fog-1.3.1 tests/core/attribute_tests.rb