spec/spec_helper.rb in appengine-apis-0.0.12 vs spec/spec_helper.rb in appengine-apis-0.0.13

- old
+ new

@@ -6,13 +6,12 @@ require 'spec' require 'appengine-sdk' end $:.unshift(File.dirname(__FILE__) + '/../lib') -AppEngine::SDK.load_apiproxy require 'appengine-apis/testing' -AppEngine::Testing.install_test_env +AppEngine::Testing.setup class ProtoMatcher def compare(hash, proto, prefix='') hash.each do |key, value| name = "#{prefix}#{key}" @@ -34,54 +33,54 @@ else compare_value(name, value, proto.send(key)) end end end - + def compare_value(label, expected, actual) if expected != actual - @failures << "%s differs. expected: %s actual: %s" % + @failures << "%s differs. expected: %s actual: %s" % [label, expected.inspect, actual.inspect] end end - + def initialize(klass, expected) @klass = klass @expected = expected end - + def matches(bytes) @failures = [] @proto = @klass.new @proto.parse_from(bytes) compare(@expected, @proto) @failures.empty? end - + def ==(bytes) Spec::Expectations.fail_with(failure_message) unless matches(bytes) true end - + def failure_message @failures.join("\n") end end module ProtoMethods def proto(klass, hash) ProtoMatcher.new(klass, hash) end alias be_proto proto - + def mock_delegate delegate = mock("apiproxy") delegate.instance_eval do class << self include AppEngine::ApiProxy::Delegate end end - end + end end Spec::Runner.configure do |config| config.include(ProtoMethods) end \ No newline at end of file