Skip to content

Commit

Permalink
fix regexp escaping issue in test fixture view
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Dec 20, 2009
1 parent 55d661d commit b55a3ec
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions spec/couchrest/core/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,27 @@

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
Expand Down

0 comments on commit b55a3ec

Please sign in to comment.