Sha256: 523e816b4376e9caf5f8bcc213861766ee633ab0c09a90d81b98a1f55771ee2a

Contents?: true

Size: 1.88 KB

Versions: 43

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

43 entries across 41 versions & 6 rubygems

Version Path
fog-2.3.0 tests/core/attribute_tests.rb
fog-ifeel-2.2.0 tests/core/attribute_tests.rb
fog-2.2.0 tests/core/attribute_tests.rb
fog-2.1.0 tests/core/attribute_tests.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/tests/core/attribute_tests.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/tests/core/attribute_tests.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/tests/core/attribute_tests.rb
fog-1.42.1 tests/core/attribute_tests.rb
fog-2.0.0 tests/core/attribute_tests.rb
fog-1.42.0 tests/core/attribute_tests.rb
fog-1.41.0 tests/core/attribute_tests.rb
fog-1.40.0 tests/core/attribute_tests.rb
fog-1.39.0 tests/core/attribute_tests.rb
fog-1.38.0 tests/core/attribute_tests.rb
fog-1.37.0 tests/core/attribute_tests.rb
fog-1.36.0 tests/core/attribute_tests.rb
fog-1.35.0 tests/core/attribute_tests.rb
fog-2.0.0.pre.0 tests/core/attribute_tests.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/tests/core/attribute_tests.rb
fog-1.34.0 tests/core/attribute_tests.rb