Sha256: ced18255b8a8020141d5f9a7b580a66f189594d374bbef3e232ee38e754822d8

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

# Author:: Couchbase <info@couchbase.com>
# Copyright:: 2011, 2012 Couchbase, Inc.
# License:: Apache License, Version 2.0
#
# 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.join(File.dirname(__FILE__), 'setup')

class TestUtils < MiniTest::Test

  def test_complex_startkey
    assert_equal "all_docs?startkey=%5B%22Deadmau5%22%2C%22%22%5D", Couchbase::Utils.build_query("all_docs", :startkey =>  ["Deadmau5", ""])
  end

  def test_it_provides_enough_info_with_value_error
    class << MultiJson
      alias dump_good dump
      def dump(obj)
        raise ArgumentError, "cannot accept your object"
      end
    end
    assert_raises(Couchbase::Error::ValueFormat) do
      cb.set(uniq_id, "foo")
    end
    begin
      cb.set(uniq_id, "foo")
    rescue Couchbase::Error::ValueFormat => ex
      assert_match /cannot accept your object/, ex.to_s
      assert_instance_of ArgumentError, ex.inner_exception
    end
  ensure
    class << MultiJson
      undef dump
      alias dump dump_good
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
couchbase-jruby-client-0.1.8-java test/test_utils.rb
couchbase-jruby-client-0.1.7-java test/test_utils.rb
couchbase-jruby-client-0.1.6-java test/test_utils.rb
couchbase-jruby-client-0.1.5-java test/test_utils.rb
couchbase-jruby-client-0.1.4 test/test_utils.rb
couchbase-jruby-client-0.1.3 test/test_utils.rb