Sha256: 3bcd1e72edc32c252baaac66c8afce6158d3f0f5f270f1c519d9e4f960dcb6be

Contents?: true

Size: 1.25 KB

Versions: 91

Compression:

Stored size: 1.25 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'thor/core_ext/hash_with_indifferent_access'

describe Thor::CoreExt::HashWithIndifferentAccess do
  before do
    @hash = Thor::CoreExt::HashWithIndifferentAccess.new :foo => 'bar', 'baz' => 'bee', :force => true
  end

  it "has values accessible by either strings or symbols" do
    @hash['foo'].should == 'bar'
    @hash[:foo].should  == 'bar'

    @hash.values_at(:foo, :baz).should == ['bar', 'bee']
    @hash.delete(:foo).should == 'bar'
  end

  it "handles magic boolean predicates" do
    @hash.force?.should be_true
    @hash.foo?.should be_true
    @hash.nothing?.should be_false
  end

  it "handles magic comparisions" do
    @hash.foo?('bar').should be_true
    @hash.foo?('bee').should be_false
  end

  it "maps methods to keys" do
    @hash.foo.should == @hash['foo']
  end

  it "merges keys independent if they are symbols or strings" do
    @hash.merge!('force' => false, :baz => "boom")
    @hash[:force].should == false
    @hash[:baz].should == "boom"
  end

  it "creates a new hash by merging keys independent if they are symbols or strings" do
    other = @hash.merge('force' => false, :baz => "boom")
    other[:force].should == false
    other[:baz].should == "boom"
  end
end

Version data entries

91 entries across 76 versions & 13 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/thor-0.15.2/spec/core_ext/hash_with_indifferent_access_spec.rb
classiccms-0.7.4 vendor/bundle/gems/thor-0.15.2/spec/core_ext/hash_with_indifferent_access_spec.rb
classiccms-0.7.3 vendor/bundle/gems/thor-0.15.2/spec/core_ext/hash_with_indifferent_access_spec.rb
classiccms-0.7.2 vendor/bundle/gems/thor-0.15.2/spec/core_ext/hash_with_indifferent_access_spec.rb
classiccms-0.7.1 vendor/bundle/gems/thor-0.15.2/spec/core_ext/hash_with_indifferent_access_spec.rb
classiccms-0.7.0 vendor/bundle/gems/thor-0.15.2/spec/core_ext/hash_with_indifferent_access_spec.rb
challah-1.0.0.beta vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
challah-0.9.1.beta.3 vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
backbone-queryparams-rails-0.0.1 vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
railscast-assets-0.0.2 vendor/bundle/gems/backbone-forms-on-rails-0.10.0/vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
railscast-assets-0.0.2 vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
backbone-forms-on-rails-0.10.0 vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
backbone-forms-on-rails-0.10.0 vendor/bundle/gems/backbone-forms-on-rails-0.10.0/vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
backbone-deep-rails-0.0.1 vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
challah-0.9.1.beta vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
challah-0.9.0 vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
classiccms-0.6.9 vendor/bundle/gems/thor-0.15.2/spec/core_ext/hash_with_indifferent_access_spec.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/thor-0.16.0/spec/core_ext/hash_with_indifferent_access_spec.rb