Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (44 sloc) 1.343 kb
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
Jump to Line
Something went wrong with that request. Please try again.