Sha256: e5129a3ac0c9bdf5dad63d905eba8ea6bb1f6b22c894463830f6f9556f1cee33
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
module CouchPotato module RSpec class ListAsProxy def initialize(results_ruby) @results_ruby = results_ruby end def as(expected_ruby) ListAsMatcher.new(expected_ruby, @results_ruby) end end class ListAsMatcher include RunJS def initialize(expected_ruby, results_ruby) @expected_ruby = expected_ruby @results_ruby = results_ruby end def matches?(view_spec) js = <<-JS #{File.read(File.dirname(__FILE__) + '/print_r.js')} #{File.read(File.dirname(__FILE__) + '/json2.js')} var results = #{@results_ruby.to_json}; var listed = ''; var list = #{view_spec.list_function}; var getRow = function() { return results.rows.shift(); }; var send = function(text) { listed = listed + text; }; list(); print_r(JSON.parse(listed)); JS @actual_ruby = JSON.parse(run_js(js)) @expected_ruby == @actual_ruby end def failure_message_for_should "Expected to list as #{@expected_ruby.inspect} but got #{@actual_ruby.inspect}." end def failure_message_for_should_not "Expected to not list as #{@expected_ruby.inspect} but did." end end end end
Version data entries
3 entries across 3 versions & 1 rubygems