Sha256: 67b2b0d7af17d2223dc0f298e777317d04a4bd5af14c175fc2782d95b71b6c38

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'simplecov'
require 'coveralls'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
  SimpleCov::Formatter::HTMLFormatter,
  Coveralls::SimpleCov::Formatter
]
SimpleCov.start

require 'json'
require 'idbus_api'
require 'rspec'
require 'webmock/rspec'

WebMock.disable_net_connect!(:allow => 'coveralls.io')

require 'vcr'
VCR.configure do |c|
  c.configure_rspec_metadata!
  c.filter_sensitive_data("<<ACCESS_TOKEN>>") do
    test_token
  end
  c.default_cassette_options = {
    :serialize_with             => :json,
    :preserve_exact_body_bytes  => true,
    :decode_compressed_response => true,
    :record                     => ENV['TRAVIS'] ? :none : :once
  }
  c.cassette_library_dir = 'spec/cassettes'
  c.hook_into :webmock
end

def idbus_url(url)
  return url if url =~ /^http/

  url = File.join(IdbusApi.api_endpoint, IdbusApi.api_version, url)
  uri = Addressable::URI.parse(url)

  uri.to_s
end

def token_client
  IdbusApi::Client.new(:access_token => test_token)
end

def test_token
  ENV.fetch 'IDBUS_TEST_TOKEN', 'x' * 20
end

def stub_get(url)
  stub_request(:get, idbus_url(url))
end

def fixture_path
  File.expand_path("../fixtures", __FILE__)
end

def fixture(file)
  File.new(fixture_path + '/' + file)
end

def json_response(file)
  {
    :body => fixture(file),
    :headers => {
      :content_type => 'application/json; charset=utf-8'
    }
  }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
idbus_api-0.0.1 spec/spec_helper.rb