Sha256: 6fae4da13fbed754a1efc8fbe79e7cd44d3765ca3e32421a6dc994ac5dfa4543

Contents?: true

Size: 1.56 KB

Versions: 9

Compression:

Stored size: 1.56 KB

Contents

# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

require File.expand_path("../../spec_helper", __FILE__)

describe Riak::Util::Escape do
  before :each do
    @object = Object.new
    @object.extend(Riak::Util::Escape)
  end

  it "should escape standard non-safe characters" do
    @object.escape("some string").should == "some%20string"
    @object.escape("another^one").should == "another%5Eone"
    @object.escape("bracket[one").should == "bracket%5Bone"
  end

  it "should escape slashes" do
    @object.escape("some/inner/path").should == "some%2Finner%2Fpath"
  end
  
  it "should convert the bucket or key to a string before escaping" do
    @object.escape(125).should == '125'
  end

  it "should unescape escaped strings" do
    @object.unescape("some%20string").should == "some string"
    @object.unescape("another%5Eone").should == "another^one"
    @object.unescape("bracket%5Bone").should == "bracket[one"
    @object.unescape("some%2Finner%2Fpath").should == "some/inner/path"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
riak-client-0.9.8 spec/riak/escape_spec.rb
riak-client-0.9.5 spec/riak/escape_spec.rb
riak-client-0.9.4 spec/riak/escape_spec.rb
riak-client-0.9.3 spec/riak/escape_spec.rb
riak-client-0.9.2 spec/riak/escape_spec.rb
riak-client-0.9.1 spec/riak/escape_spec.rb
riak-client-0.9.0 spec/riak/escape_spec.rb
riak-client-0.9.0.beta2 spec/riak/escape_spec.rb
riak-client-0.9.0.beta spec/riak/escape_spec.rb