Sha256: 996715f3cdd1c9885ca611da6966f0f450bb7665dfcfe1d0c38fc9c8cc895a01

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'rubygems'
require 'fakeweb'

require 'simple_xurrency'
require 'rspec'

module HelperMethods
  def mock_xurrency_api(from_currency, to_currency, amount, result, updated_at, options = {}, date=nil)
    args = [from_currency, to_currency, "1"]

    response = "{\"result\":{\"value\":#{result},\"target\":\"#{to_currency}\",\"base\":\"#{from_currency}\",\"updated_at\":\"#{updated_at}\"},\"status\":\"ok\"}"

    response = "{\"message\":\"#{options[:fail_with]}\", \"status\":\"fail\"\}" if options[:fail_with]

    url = "http://xurrency.com/api/#{args.join('/')}"

    if date
      url += "?date=#{date.strftime("%Y%m%d")}"
    end

    FakeWeb.register_uri(:get, url, :body => response)
  end
end

RSpec.configuration.include(HelperMethods)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_xurrency_buntine-1.1.2 spec/spec_helper.rb