Sha256: e0e110d8386ee9cea58d2500c7c713e86b80f9770fb5cb98b2037b0b02a80ce1

Contents?: true

Size: 910 Bytes

Versions: 7

Compression:

Stored size: 910 Bytes

Contents

# encoding: utf-8
require 'helper'
require 'memcached_mock'

class TestEncoding < Test::Unit::TestCase

  context 'using a live server' do
    should 'support i18n content' do
      memcached do |dc|
        key = 'foo'
        bad_key = utf8 = 'ƒ©åÍÎ'

        assert dc.set(key, utf8)
        assert_equal utf8, dc.get(key)

        # keys must be ASCII
        assert_raise ArgumentError, /illegal character/ do
          dc.set(bad_key, utf8)
        end
      end
    end

    should 'support content expiry' do
      memcached do |dc|
        key = 'foo'
        assert dc.set(key, 'bar', 1)
        assert_equal 'bar', dc.get(key)
        sleep 2
        assert_equal nil, dc.get(key)
      end
    end

    should 'not allow non-ASCII keys' do
      memcached do |dc|
        key = 'fooƒ'
        assert_raise ArgumentError do
          dc.set(key, 'bar')
        end
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
dalli-1.1.4 test/test_encoding.rb
dalli-1.1.3 test/test_encoding.rb
dalli-1.1.2 test/test_encoding.rb
dalli-1.1.1 test/test_encoding.rb
dalli-1.0.5 test/test_encoding.rb
sayso-dalli-1.0.3.001 test/test_encoding.rb
dalli-1.0.4 test/test_encoding.rb