Sha256: aef0932f970fb0d2e695c9749a9e333a964790315b0d04f8d0f78c2455efd6a6

Contents?: true

Size: 780 Bytes

Versions: 3

Compression:

Stored size: 780 Bytes

Contents

require 'simplecov'
require 'minitest/autorun'
require 'webmock/minitest'

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)
  # The last argument is post data
  data = args.pop
  response = stub_response(*args)
  url = args[0]
  stub_request(:post, url).with(body: data).to_return(response)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
razorpay-1.2.1 test/test_helper.rb
razorpay-1.2.0 test/test_helper.rb
razorpay-1.1.0 test/test_helper.rb