Sha256: c0e73c3dd5b493e1b7f02da7e6da3bc497497d56d48fa3c6247350c112fd2dd8

Contents?: true

Size: 1.12 KB

Versions: 15

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe Hashie::Clash do
  before do
    @c = Hashie::Clash.new
  end
  
  it 'should be able to set an attribute via method_missing' do
    @c.foo('bar')
    @c[:foo].should == 'bar'
  end
  
  it 'should be able to set multiple attributes' do
    @c.foo('bar').baz('wok')
    @c.should == {:foo => 'bar', :baz => 'wok'}
  end
  
  it 'should convert multiple arguments into an array' do
    @c.foo(1, 2, 3)
    @c[:foo].should == [1,2,3]
  end
  
  it 'should be able to use bang notation to create a new Clash on a key' do
    @c.foo!
    @c[:foo].should be_kind_of(Hashie::Clash)
  end
  
  it 'should be able to chain onto the new Clash when using bang notation' do
    @c.foo!.bar('abc').baz(123)
    @c.should == {:foo => {:bar => 'abc', :baz => 123}}
  end
  
  it 'should be able to jump back up to the parent in the chain with #_end!' do
    @c.foo!.bar('abc')._end!.baz(123)
    @c.should == {:foo => {:bar => 'abc'}, :baz => 123}
  end
  
  it 'should merge rather than replace existing keys' do
    @c.where(:abc => 'def').where(:hgi => 123)
    @c.should == {:where => {:abc => 'def', :hgi => 123}}
  end
end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
hashie-2.0.2 spec/hashie/clash_spec.rb
hashie-2.0.1 spec/hashie/clash_spec.rb
hashie-2.0.0 spec/hashie/clash_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/hashie-1.2.0/spec/hashie/clash_spec.rb
cb_hashie-2.0.0.beta spec/hashie/clash_spec.rb
hashie-pre-2.0.0.beta spec/hashie/clash_spec.rb
hashie-1.2.0 spec/hashie/clash_spec.rb
hashie-1.1.0 spec/hashie/clash_spec.rb
hashie-1.0.0 spec/hashie/clash_spec.rb
putio-0.0.1.pre2 development/ruby/1.8/gems/hashie-0.4.0/spec/hashie/clash_spec.rb
putio-0.0.1.pre development/ruby/1.8/gems/hashie-0.4.0/spec/hashie/clash_spec.rb
hashie-0.4.0 spec/hashie/clash_spec.rb
hashie-0.3.1 spec/hashie/clash_spec.rb
hashie-0.3.0 spec/hashie/clash_spec.rb
hashie-0.2.2 spec/hashie/clash_spec.rb