Sha256: 6c685f33462e579fec15ee91bd23b003b878c8f19b94b9cdd279df78092b2edb

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

require 'spec_helper'

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

3 entries across 3 versions & 2 rubygems

Version Path
the_viking-1.0.0 spec/core_ext/transformations_spec.rb
viking-1.0.1 spec/core_ext/transformations_spec.rb
viking-1.0.0 spec/core_ext/transformations_spec.rb