Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

map returns result of map function, not results of emit. #1

@ghost

Description

The test is only passed because emit is the last thing called in the test, and emit returns the result of all admits.

to verify, add "1" to the end of the emit-twice rspec function, in both javascript and ruby. passes in javascript, fails in ruby.

Anyway, patch attached.

diff --git a/lib/couch_db/view.rb b/lib/couch_db/view.rb
index 803cb07..0bf07ff 100644
--- a/lib/couch_db/view.rb
+++ b/lib/couch_db/view.rb
@@ -35,6 +35,15 @@ module CouchDB
       def emit(key, value)
         @results.push([key, value])
       end
+      
+      def run(*args)
+        begin
+          instance_exec *args, &@func
+          @results
+        rescue HaltedFunction => e
+          @error
+        end
+      end
     end

     def reduce(functions, vals)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions