From: <nul...@cl...> - 2010-12-24 09:28:06
|
Kakutani Shintaro 2010-12-24 09:17:25 +0000 (Fri, 24 Dec 2010) New Revision: 3747c648ccc685da7e6c6f284f38064e720d4e4b Log: factored out ascii8bit pstore database. rake specで動かすと、comppatible.rb が既に読み込まれてしまっているため、 テストフィクスチャのPStoreがASCII-8BITではなくUTF-8になってしまう。 そのため、beforeでセットアップしているのと同様のascii8bit-pstore.db を テストフィクスチャにした。 Added files: spec/core/ascii8bit-pstore.db Modified files: spec/core/compatible_spec.rb Added: spec/core/ascii8bit-pstore.db (+0 -0) 100644 =================================================================== (Binary files differ) Modified: spec/core/compatible_spec.rb (+18 -7) =================================================================== --- spec/core/compatible_spec.rb 2010-12-24 08:31:48 +0000 (ad5ddd8) +++ spec/core/compatible_spec.rb 2010-12-24 09:17:25 +0000 (977377d) @@ -4,6 +4,7 @@ require File.dirname(__FILE__) + "/../spec_helper" if RUBY_VERSION > '1.9' require 'tempfile' require 'pstore' + require 'fileutils' class String def to_8bit @@ -18,16 +19,26 @@ if RUBY_VERSION > '1.9' end describe PStore, "auto convert library" do - before do - @dbfile = Tempfile.new("compatible_spec").path - PStore.new(@dbfile).transaction do |db| - db["key1".to_8bit] = "val1".to_8bit - db["key2".to_8bit] = 2 - db["key3".to_8bit] = [1, :sym, "string".to_8bit] - end + before(:all) do +# rake specで動かすと、comppatible.rb が既に読み込まれてしまっているため、 +# このPStoreがASCII-8BITではなくUTF-8になってしまう。 +# そのため、下記と同様の ascii8bit-pstore.db をテストフィクスチャとしている。 +# PStore.new(@dbfile).transaction do |db| +# db["key1".to_8bit] = "val1".to_8bit +# db["key2".to_8bit] = 2 +# db["key3".to_8bit] = [1, :sym, "string".to_8bit] +# end + dbfilename = 'ascii8bit-pstore.db' + dbfile_orig = File.join(File.dirname(__FILE__), dbfilename) + @dbfile = File.join(File.dirname(__FILE__), "#{dbfilename}.work") + FileUtils.cp dbfile_orig, @dbfile require File.dirname(__FILE__) + '/../../misc/lib/compatible' end + after(:all) do + FileUtils.rm @dbfile + end + if "".respond_to?(:force_encoding) it "should convert an encoding to UTF-8 automatically" do PStore.new(@dbfile).transaction do |db| |