Sha256: 61e8889de3fd45dfd30d93a529a36288aace525f25cb1230ee890ebd45e05bc0

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

require_relative 'spec_helper'

require 'wright/config'

describe Wright::Config do
  before(:each) do
    @config = Wright::Config.config_hash.clone
    Wright::Config.config_hash.clear
  end

  after(:each) do
    Wright::Config.config_hash = @config
  end

  it 'should behave like a Hash' do
    Wright::Config.size.must_equal 0
    Wright::Config[:foo] = :bar
    Wright::Config[:bar] = :baz
    Wright::Config[:foo].must_equal :bar
    Wright::Config[:bar].must_equal :baz
    Wright::Config.size.must_equal 2
  end

  it 'should handle nested key checks' do
    Wright::Config[:foo] = { bar: :baz }
    Wright::Config.nested_key?(:foo, :bar).must_equal true
    Wright::Config.nested_key?(:foo, :bar, :qux).must_equal false
    Wright::Config.nested_key?(:nonexistent).must_equal false
    Wright::Config.nested_key?(:nonexistent1, :nonexistent2).must_equal false
  end

  it 'should return values for nested keys' do
    Wright::Config[:foo] = { bar: :baz }
    Wright::Config.nested_value(:foo, :bar).must_equal :baz
    Wright::Config.nested_value(:im, :not, :there).must_be_nil
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
wright-0.5.0 spec/config_spec.rb
wright-0.4.4 spec/config_spec.rb
wright-0.4.3 spec/config_spec.rb
wright-0.4.2 spec/config_spec.rb
wright-0.4.1 spec/config_spec.rb
wright-0.4.0 spec/config_spec.rb
wright-0.3.2 spec/config_spec.rb
wright-0.3.1 spec/config_spec.rb
wright-0.3.0 spec/config_spec.rb
wright-0.2.0 spec/config_spec.rb
wright-0.1.2 spec/config_spec.rb
wright-0.1.1 spec/config_spec.rb
wright-0.1.0 spec/config_spec.rb