Sha256: 33e65e9ff42f7edf44b60cc3bea27c5112342dac8da873d78ba3c8ffc5a18c01
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 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_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
3 entries across 3 versions & 1 rubygems