Sha256: 45ce2f8a4198148c960114f82c6ebc7c9f5c0502cacdbdd45a924362f7638ab6
Contents?: true
Size: 1.19 KB
Versions: 39
Compression:
Stored size: 1.19 KB
Contents
require 'json' module CouchPotato module RSpec class MapToProxy def initialize(input_ruby) @input_ruby = input_ruby end def to(*expected_ruby) MapToMatcher.new(expected_ruby, @input_ruby) end end class MapToMatcher include RunJS def initialize(expected_ruby, input_ruby) @expected_ruby = expected_ruby @input_ruby = input_ruby end def matches?(view_spec) js = <<-JS #{File.read(File.dirname(__FILE__) + '/print_r.js')} var doc = #{@input_ruby.to_json}; var map = #{view_spec.map_function}; var result = []; var emit = function(key, value) { result.push([key, value]); }; map(doc); print(print_r(result)); JS @actual_ruby = JSON.parse(run_js(js)) @expected_ruby == @actual_ruby end def failure_message_for_should "Expected to map to #{@expected_ruby.inspect} but got #{@actual_ruby.inspect}." end def failure_message_for_should_not "Expected not to map to #{@actual_ruby.inspect} but did." end end end end
Version data entries
39 entries across 39 versions & 3 rubygems