Sha256: 2c3945e61e15ec15079618cbdc895a0e9085b0f60a6b2d3d397bd133745e26b8

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'simplecov'
require 'coveralls'

SimpleCov.formatters = [
  SimpleCov::Formatter::HTMLFormatter,
  Coveralls::SimpleCov::Formatter
]

SimpleCov.start

require 'ivapi'
require 'rspec'
require 'webmock/rspec'

WebMock.disable_net_connect!(allow: ['coveralls.io', 'codeclimate.com'])

RSpec.configure do |config|
  config.expect_with :rspec do |c|
    c.syntax = :expect
  end
end

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

def stub_command(command, options = {})
  params = { command: command }
  params.merge!(options)
  client = @client || Ivapi.client
  params.merge!(client.authentication)
  stub_request(:get, 'https://api.iv.lt/json.php').with(query: params)
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

def iv_url(url)
  if url =~ /^http/
    url
  else
    "https://api.iv.lt#{url}"
  end
end

def iv_command_url(command)
  data = { command: command }

  if @client && @client.authenticated?
    data.merge(nick: @client.username, password: @client.password)
  end

  iv_url('/json.php?' + URI.encode_www_form(data))
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ivapi-1.4.0 spec/spec_helper.rb
ivapi-1.3.0 spec/spec_helper.rb
ivapi-1.2.0 spec/spec_helper.rb