spec/riak/http_backend_spec.rb in riak-client-1.4.2 vs spec/riak/http_backend_spec.rb in riak-client-1.4.3

- old
+ new

@@ -47,10 +47,15 @@ it "should escape the bucket and key names" do @backend.should_receive(:get).with([200,300], @backend.object_path('foo ', ' bar')).and_return({:headers => {"content-type" => ["application/json"]}, :body => '{"name":"Riak","company":"Basho"}'}) @backend.fetch_object('foo ',' bar').should be_kind_of(Riak::RObject) end + + it "should escape brackets in the bucket and key names" do + @backend.should_receive(:get).with([200,300], @backend.object_path('[foo]', '[bar]')).and_return({:headers => {"content-type" => ["application/json"]}, :body => '{"name":"Riak","company":"Basho"}'}) + @backend.fetch_object('[foo]','[bar]').should be_kind_of(Riak::RObject) + end end context "reloading an object" do before do @object = Riak::RObject.new(@client.bucket("foo"), "bar") @@ -126,9 +131,21 @@ end it "should include persistence-tuning parameters in the query string" do @backend.should_receive(:put).with([200,204,300], @backend.object_path("foo", "bar", {:w => 2, :returnbody => true}), "This is some text.", @headers).and_return({:headers => {'location' => ["/riak/foo/somereallylongstring"], "x-riak-vclock" => ["areallylonghashvalue"]}, :code => 204}) @backend.store_object(@object, :returnbody => true, :w => 2) + end + end + + context "when the object's key contains square brackets" do + before :each do + @object.key = "[bar]" + end + + it "should escape the key name" do + @backend.should_receive(:put).with([200,204,300], @backend.object_path("foo", "[bar]", {:returnbody => true}), "This is some text.", @headers).and_return({:headers => {'location' => ["/riak/foo/%5Bbar%5D"], "x-riak-vclock" => ["areallylonghashvalue"]}, :code => 204}) + @backend.store_object(@object, :returnbody => true) + @object.key.should == "[bar]" end end end context "deleting an object" do