2012-06-14 13:04:30 +00:00
|
|
|
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
2010-08-17 01:21:17 +00:00
|
|
|
$LOAD_PATH.uniq!
|
2012-06-14 09:18:35 +00:00
|
|
|
|
2012-06-14 13:04:30 +00:00
|
|
|
require 'rspec'
|
2012-09-24 23:09:17 +00:00
|
|
|
require 'faraday'
|
|
|
|
|
|
|
|
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.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 13:04:30 +00:00
|
|
|
|
2012-06-14 09:18:35 +00:00
|
|
|
RSpec.configure do |config|
|
|
|
|
end
|