google-api-ruby-client/spec/spec_helper.rb

57 lines
1.2 KiB
Ruby
Raw Normal View History

$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
$LOAD_PATH.uniq!
2012-06-14 09:18:35 +00:00
require 'rspec'
2012-09-24 23:09:17 +00:00
require 'faraday'
Faraday::Adapter.load_middleware(:test)
2012-09-24 23:09:17 +00:00
module Faraday
class Connection
def verify
if app.kind_of?(Faraday::Adapter::Test)
app.stubs.verify_stubbed_calls
else
raise TypeError, "Expected test adapter"
end
end
end
end
module ConnectionHelpers
def stub_connection(&block)
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
block.call(stub)
end
connection = Faraday.new do |builder|
builder.options.params_encoder = Faraday::FlatParamsEncoder
2012-09-24 23:09:17 +00:00
builder.adapter(:test, stubs)
end
end
end
module JSONMatchers
class EqualsJson
def initialize(expected)
@expected = JSON.parse(expected)
end
def matches?(target)
@target = JSON.parse(target)
@target.eql?(@expected)
end
def failure_message
"expected #{@target.inspect} to be #{@expected}"
end
def negative_failure_message
"expected #{@target.inspect} not to be #{@expected}"
end
end
def be_json(expected)
EqualsJson.new(expected)
end
end
2012-06-14 09:18:35 +00:00
RSpec.configure do |config|
end