Sha256: bf0351c7e47e47ecab639d84e57f5fcad01dc119595e4238d3cb7c9582ccb840

Contents?: true

Size: 1.07 KB

Versions: 87

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

describe Picky::Backends::Memory::JSON do

  let(:backend) { described_class.new '/tmp/picky_test_cache' }
  
  describe "dump_json" do
    it "works with ascii characters" do
      backend.dump_json key: 'abc'
    end
    it "works with cyrillic characters" do
      backend.dump_json key: 'ะน'
    end
    it "works with ascii strings" do
      # See https://github.com/floere/picky/pull/69.
      #
      # Rails sets both encodings to UTF-8.
      #
      old_default_external = Encoding.default_external
      old_default_internal = Encoding.default_internal
      Encoding.default_external = 'UTF-8'
      Encoding.default_internal = 'UTF-8'
      
      ascii = "\xE5".force_encoding 'ASCII-8BIT'
      # ascii.encode('UTF-8') # Uncomment this to get the error mentioned in the pull request.
      backend.dump_json ascii => ascii # Pass in the string as both key and value
      
      # Reset encodings.
      #
      Encoding.default_external = old_default_external
      Encoding.default_internal = old_default_internal
    end
  end
  
end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
picky-4.5.5 spec/functional/backends/memory_json_utf8_spec.rb
picky-4.5.4 spec/functional/backends/memory_json_utf8_spec.rb
picky-4.5.3 spec/functional/backends/memory_json_utf8_spec.rb
picky-4.5.2 spec/functional/backends/memory_json_utf8_spec.rb
picky-4.5.1 spec/functional/backends/memory_json_utf8_spec.rb
picky-4.5.0 spec/functional/backends/memory_json_utf8_spec.rb
picky-4.4.2 spec/functional/backends/memory_json_utf8_spec.rb