fix regexp escaping issue in test fixture view
This commit is contained in:
parent
55d661dd10
commit
b55a3ec0d3
|
@ -65,22 +65,27 @@ describe CouchRest::Database do
|
||||||
|
|
||||||
describe "saving a view" do
|
describe "saving a view" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@view = {'test' => {'map' => 'function(doc) {
|
@view = {'test' => {'map' => <<-JS
|
||||||
if (doc.word && !/\W/.test(doc.word)) {
|
function(doc) {
|
||||||
emit(doc.word,null);
|
var reg = new RegExp("\\\\W");
|
||||||
|
if (doc.word && !reg.test(doc.word)) {
|
||||||
|
emit(doc.word,null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}'}}
|
JS
|
||||||
|
}}
|
||||||
@db.save_doc({
|
@db.save_doc({
|
||||||
"_id" => "_design/test",
|
"_id" => "_design/test",
|
||||||
:views => @view
|
:views => @view
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
it "should work properly" do
|
it "should work properly" do
|
||||||
@db.bulk_save([
|
r = @db.bulk_save([
|
||||||
{"word" => "once"},
|
{"word" => "once"},
|
||||||
{"word" => "and again"}
|
{"word" => "and again"}
|
||||||
])
|
])
|
||||||
@db.view('test/test')['total_rows'].should == 1
|
r = @db.view('test/test')
|
||||||
|
r['total_rows'].should == 1
|
||||||
end
|
end
|
||||||
it "should round trip" do
|
it "should round trip" do
|
||||||
@db.get("_design/test")['views'].should == @view
|
@db.get("_design/test")['views'].should == @view
|
||||||
|
|
Loading…
Reference in a new issue