From b55a3ec0d367fde3dfdf40dffbda3d103b1d5787 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Sun, 20 Dec 2009 11:07:53 -0800 Subject: [PATCH] fix regexp escaping issue in test fixture view --- spec/couchrest/core/database_spec.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/couchrest/core/database_spec.rb b/spec/couchrest/core/database_spec.rb index e315a6d..afcda6e 100644 --- a/spec/couchrest/core/database_spec.rb +++ b/spec/couchrest/core/database_spec.rb @@ -65,22 +65,27 @@ describe CouchRest::Database do describe "saving a view" do before(:each) do - @view = {'test' => {'map' => 'function(doc) { - if (doc.word && !/\W/.test(doc.word)) { - emit(doc.word,null); + @view = {'test' => {'map' => <<-JS + function(doc) { + var reg = new RegExp("\\\\W"); + if (doc.word && !reg.test(doc.word)) { + emit(doc.word,null); + } } - }'}} + JS + }} @db.save_doc({ "_id" => "_design/test", :views => @view }) end it "should work properly" do - @db.bulk_save([ + r = @db.bulk_save([ {"word" => "once"}, {"word" => "and again"} ]) - @db.view('test/test')['total_rows'].should == 1 + r = @db.view('test/test') + r['total_rows'].should == 1 end it "should round trip" do @db.get("_design/test")['views'].should == @view