Sha256: 2d08a307f28becc092e52e5e7afbb27a66388fe79186eacb58fea17ad7277c17

Contents?: true

Size: 897 Bytes

Versions: 2

Compression:

Stored size: 897 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')

describe Hash do
  
  describe '#symbolize_keys' do
    it 'should convert all keys to symbols' do
      { 'foo' => 'bar', :baz => 1 }.symbolize_keys.should == { :foo => 'bar', :baz => 1 }
    end
    
    it 'should handle bad keys' do
      { nil => 'bar' }.symbolize_keys[nil].should == 'bar'
    end
  end
  
  describe '#dasherize_keys' do
    it 'should convert all all underscores in keys to dashes' do
      { 'foo_bar' => 'baz' }.dasherize_keys.should == { 'foo-bar' => 'baz' }
    end
  end
  
  describe '#to_query' do
    it 'should convert to a valid URI query' do
      { :foo => 'baz', :bar => 1 }.to_query.should == 'bar=1&foo=baz'
    end
  end
  
end

describe Array, '#to_query' do
  it 'should convert to a valid URI query' do
    [:foo, :bar].to_query('baz').should == 'baz%5B%5D=foo&baz%5B%5D=bar'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vikinggem-0.0.2 spec/core_ext/transformations_spec.rb
vikinggem-0.0.1 spec/core_ext/transformations_spec.rb