Sha256: c8b3f3710492a0b52bb2023b0afa3e134009d227168499f7d57936f07925a5ee

Contents?: true

Size: 1.31 KB

Versions: 58

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

module Convection::Model
  describe Attributes do
    subject { Attributes.new }

    describe '#fetch' do
      it 'raises a key error if the key was not defined' do
        expect { subject.fetch('<stack-name>', '<attribute-key>') }.to raise_error(KeyError)
      end

      ['<truthy object>', true, false].each do |default|
        it "supports #{default.inspect} as the default value when no value was set" do
          expect { subject.fetch('<stack-name>', '<attribute-key>', default) }.to_not raise_error
        end

        it "supports #{default.inspect} as a default value" do
          observed = subject.fetch('<stack-name>', '<attribute-key>', default)
          expect(observed).to eq(default)
        end
      end

      ['truthy object', true, false, nil].each do |value|
        it "does not raise a key error when #{value.inspect} was previously set" do
          subject.set('<stack-name>', '<attribute-key>', value)

          expect { subject.fetch('<stack-name>', '<attribute-key>') }.to_not raise_error
        end

        it "supports #{value.inspect} as a return value" do
          subject.set('<stack-name>', '<attribute-key>', value)

          observed = subject.fetch('<stack-name>', '<attribute-key>')
          expect(observed).to eq(value)
        end
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
convection-2.3.1 spec/convection/model/attributes_spec.rb
convection-2.3.0 spec/convection/model/attributes_spec.rb
convection-2.2.29 spec/convection/model/attributes_spec.rb
convection-2.2.28.pre.beta.2 spec/convection/model/attributes_spec.rb
convection-2.2.28.pre.beta.1 spec/convection/model/attributes_spec.rb
convection-2.2.27 spec/convection/model/attributes_spec.rb
convection-2.2.26 spec/convection/model/attributes_spec.rb
convection-2.2.25 spec/convection/model/attributes_spec.rb
convection-2.2.24 spec/convection/model/attributes_spec.rb
convection-2.2.23 spec/convection/model/attributes_spec.rb
convection-2.2.22 spec/convection/model/attributes_spec.rb
convection-2.2.21 spec/convection/model/attributes_spec.rb
convection-2.2.20 spec/convection/model/attributes_spec.rb
convection-2.2.19 spec/convection/model/attributes_spec.rb
convection-2.2.18 spec/convection/model/attributes_spec.rb
convection-2.2.17 spec/convection/model/attributes_spec.rb
convection-2.2.16 spec/convection/model/attributes_spec.rb
convection-2.2.15 spec/convection/model/attributes_spec.rb
convection-2.2.14 spec/convection/model/attributes_spec.rb
convection-2.2.13 spec/convection/model/attributes_spec.rb