Sha256: f53088d6a982701ce273efb4b01fc7bee91d9d2dde93b9b97319af96f391401f

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe Wahashie::Clash do
  before do
    @c = Wahashie::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(Wahashie::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

1 entries across 1 versions & 1 rubygems

Version Path
wahashie-1.2.0 spec/wahashie/clash_spec.rb