Skip to content

Commit

Permalink
Specs for UTF8 handling
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed May 3, 2009
1 parent 1cecaaf commit e195c38
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/couchrb/utf8.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# * Encoding: UTF-8
$KCODE = 'u' if /regexp/.respond_to?(:kcode)

require 'spec/helper'

describe 'UTF8 handling' do
behaves_like :couch_client

@db = DB.new('/test_suite_db')
@db.delete_db
@db.create_db

@texts = [
"1. Ascii: hello",
"2. Russian: На берегу пустынных волн",
"3. Math: ∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i),",
"4. Geek: STARGΛ̊TE SG-1",
"5. Braille: ⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌",
]

it 'stores documents with UTF8 in the db' do
@texts.each_with_index do |text, idx|
@db.save('_id' => idx.to_s, 'text' => text)['ok'].should == true
end
end

it 'opens the documents, and they have identical content' do
1.should == 1

@texts.each_with_index do |text, idx|
@db.open(idx)['text'].should == text
end
end

it "doesn't blog up on key collation" do
map = "proc{|doc| pp doc['text']; emit(nil, doc['text']) }"
rows = @db.query(:map => map)['rows']
rows.map{|row| row['value'] }.should == @texts
end
end

0 comments on commit e195c38

Please sign in to comment.