Sha256: 6874ec7da98ac4b772af2fa0f97ba9b3986b325cb3b7bdd85a5833f09fe82d11

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'coveralls'
require 'simplecov'
require 'minitest/autorun'
require 'webmock/minitest'
require 'razorpay'

Coveralls.wear! if ENV['CI']

def fixture_file(filename)
  return '' if filename == ''
  file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename + '.json')
  File.read(file_path)
end

def stub_response(_url, filename, status = nil)
  response = { body: fixture_file(filename) }
  response[:status] = status unless status.nil?
  response.merge!(headers: { 'Content-Type' => 'application/json' })
end

def stub_get(*args)
  response = stub_response(*args)
  url = args[0]
  stub_request(:get, url).to_return(response)
end

def stub_post(*args)
  stub_request_with_body(:post, *args)
end

def stub_put(*args)
  stub_request_with_body(:put, *args)
end

def stub_patch(*args)
  stub_request_with_body(:patch, *args)
end

def stub_request_with_body(verb, *args)
  # The last argument is the data
  data = args.pop
  response = stub_response(*args)
  url = args[0]
  stub_request(verb, url).with(body: data).to_return(response)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
razorpay-2.3.0 test/test_helper.rb
razorpay-2.2.0 test/test_helper.rb
razorpay-2.1.0 test/test_helper.rb
razorpay-2.1.0.pre test/test_helper.rb