forked from googleapis/google-api-ruby-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec_helper.rb
66 lines (57 loc) · 1.36 KB
/
spec_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
$LOAD_PATH.uniq!
require 'rspec'
require 'faraday'
begin
require 'simplecov'
require 'coveralls'
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start
rescue LoadError
# SimpleCov missing, so just run specs with no coverage.
end
Faraday::Adapter.load_middleware(:test)
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
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
RSpec.configure do |config|
end