Sha256: 7d20420b514311ac62fb5a1a615651f4f06607a2b0c8370db0c5dfddb56208c3

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

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

Coveralls.wear! if ENV['CI']
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter

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_delete(*args)
  response = stub_response(*args)
  url = args[0]
  stub_request(:delete, 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

7 entries across 7 versions & 2 rubygems

Version Path
razorpay-3.2.2 test/test_helper.rb
razorpay-3.2.1 test/test_helper.rb
razorpay-3.2.0 test/test_helper.rb
razorpay-3.1.0 test/test_helper.rb
razorpay-3.0.1 test/test_helper.rb
razorruby-3.0.4 test/test_helper.rb
razorruby-3.0.1 test/test_helper.rb