Sha256: 15745049dd59b69f45e460a0c6603d13282f7c5c7a00c9afdc92b121307862e2

Contents?: true

Size: 1.36 KB

Versions: 16

Compression:

Stored size: 1.36 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Axiom::Types::Hash, '.finalize' do
  subject { object.finalize }

  let(:object) { Class.new(Axiom::Types::Hash) }

  context 'with the default key and value constraints' do
    it_should_behave_like 'a command method'
    it_should_behave_like 'an idempotent method'

    it { should be_frozen }

    its(:constraint) { should be_frozen }

    it 'adds a constraint that returns true for a Hash' do
      should include(Object.new => Object.new)
    end

    it 'adds a constraint that returns false for a non-Hash' do
      should_not include(Object.new)
    end
  end

  context 'with custom key and value constraints' do
    let(:key)   { :name      }
    let(:value) { 'Dan Kubb' }

    before do
      object.key_type   Axiom::Types::Symbol
      object.value_type Axiom::Types::String
    end

    it_should_behave_like 'a command method'
    it_should_behave_like 'an idempotent method'

    it { should be_frozen }

    its(:constraint) { should be_frozen }

    it 'adds a constraint that returns true for valid keys and values' do
      should include(key => value)
    end

    it 'adds a constraint that returns false for an invalid key' do
      should_not include(key.to_s => value)
    end

    it 'adds a constraint that returns false for an invalid value' do
      should_not include(key => value.to_sym)
    end
  end
end

Version data entries

16 entries across 14 versions & 4 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
axiom-types-0.1.1 spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
axiom-types-0.1.0 spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
axiom-types-0.0.5 spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
axiom-types-0.0.4 spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
axiom-types-0.0.3 spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
axiom-types-0.0.2 spec/unit/axiom/types/hash/class_methods/finalize_spec.rb
axiom-types-0.0.1 spec/unit/axiom/types/hash/class_methods/finalize_spec.rb