Sha256: bf1c57d5f5b21db54e95b064e1f41eea1bbba3880879122c74192434d66ff351

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require 'simplecov'
require 'coveralls'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
  SimpleCov::Formatter::HTMLFormatter,
  Coveralls::SimpleCov::Formatter
]
SimpleCov.start

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

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

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.1.7 spec/spec_helper.rb
ivapi-1.1.6 spec/spec_helper.rb
ivapi-1.1.5 spec/spec_helper.rb