Sha256: 684d3b82aa0a588af670f55a73d20331dda09c0a1e632e43fe313c5bb60ed56f

Contents?: true

Size: 1.14 KB

Versions: 14

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

14 entries across 14 versions & 1 rubygems

Version Path
ruby-fs-stack-0.4.12 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.11 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.10 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.9 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.8 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.7 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.6 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.5 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.4 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.3 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.2 spec/fs_utils_spec.rb
ruby-fs-stack-0.4.0 spec/fs_utils_spec.rb
ruby-fs-stack-0.3.3 spec/fs_utils_spec.rb
ruby-fs-stack-0.3.2 spec/fs_utils_spec.rb