Sha256: 174fbd61523d065fdd21c667e8f028d60e06914f1fc64adb7c893570678a1a39

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require 'ruby-fs-stack/fs_utils'

describe FsUtils do

  describe "querystring_from_hash" do
    it "should return a querystring" do
      qstring = FsUtils.querystring_from_hash :names => 'all'
      qstring.should == 'names=all'
    end
    
    it "should return a querystring with &s delimiting params" do
      qstring = FsUtils.querystring_from_hash :names => 'all', :events => 'all'
      # a hash never guarantees the order so we'll split the string and test
      # that it contain s all of the pieces
      qstring.should include('names=all')
      qstring.should include('events=all')
      qstring.should include('&')
    end
    
    it "should url_encode all of the hash values" do
      hash = {:name => "Parker Felch"}
      qstring = FsUtils.querystring_from_hash hash
      qstring.should == 'name=Parker%20Felch'
      hash[:name].should_not == 'Parker%20Felch'
    end
    
    it "should convert sub-hashes into key.subkey=value" do
      qstring = FsUtils.querystring_from_hash :father => {:name => 'Parker Felch'}
      qstring.should == 'father.name=Parker%20Felch'
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-fs-stack-0.5.3 spec/ruby-fs-stack/fs_utils_spec.rb
ruby-fs-stack-0.5.2 spec/ruby-fs-stack/fs_utils_spec.rb
ruby-fs-stack-0.5.1 spec/ruby-fs-stack/fs_utils_spec.rb
ruby-fs-stack-0.5.0 spec/ruby-fs-stack/fs_utils_spec.rb