Re-org service account support
[arvados.git] / spec / spec_helper.rb
1 $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
2 $LOAD_PATH.uniq!
3
4 require 'rspec'
5 require 'faraday'
6 require 'faraday/adapter/test'
7
8 module Faraday
9   class Connection
10     def verify
11       if app.kind_of?(Faraday::Adapter::Test)
12         app.stubs.verify_stubbed_calls
13       else
14         raise TypeError, "Expected test adapter"
15       end
16     end
17   end
18 end
19
20 module ConnectionHelpers
21   def stub_connection(&block)
22     stubs = Faraday::Adapter::Test::Stubs.new do |stub|
23       block.call(stub)
24     end
25     connection = Faraday.new do |builder|
26       builder.adapter(:test, stubs)
27     end
28   end
29 end
30
31 module JSONMatchers
32   class EqualsJson
33     def initialize(expected)
34       @expected = JSON.parse(expected)
35     end
36     def matches?(target)
37       @target = JSON.parse(target)
38       @target.eql?(@expected)
39     end
40     def failure_message
41       "expected #{@target.inspect} to be #{@expected}"
42     end
43     def negative_failure_message
44       "expected #{@target.inspect} not to be #{@expected}"
45     end
46   end
47   
48   def be_json(expected)
49     EqualsJson.new(expected)
50   end
51 end
52
53 RSpec.configure do |config|
54 end