Module: Vantiv::MockedSandbox

Defined in:
lib/vantiv/mocked_sandbox.rb,
lib/vantiv/mocked_sandbox/api_request.rb,
lib/vantiv/mocked_sandbox/fixture_generator.rb

Defined Under Namespace

Classes: ApiRequest, CardforFixtureGeneration, FixtureGenerator

Class Method Summary collapse

Class Method Details

.disable_self_mocked_requests!Object



20
21
22
23
24
# File 'lib/vantiv/mocked_sandbox.rb', line 20

def self.disable_self_mocked_requests!
  if Vantiv::Api::Request.instance_methods.include? :orig_run_request
    Vantiv::Api::Request.send(:alias_method, :run_request, :orig_run_request)
  end
end

.enable_self_mocked_requests!Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vantiv/mocked_sandbox.rb', line 5

def self.enable_self_mocked_requests!
  raise "Usage Error: cannot mock in production" if Vantiv::Environment.production?

  unless Vantiv::Api::Request.instance_methods.include? :orig_run_request
    Vantiv::Api::Request.send(:alias_method, :orig_run_request, :run_request)
  end
  Vantiv::Api::Request.send(:define_method, :run_request) do
    Vantiv::MockedSandbox::ApiRequest.run(
      endpoint: @endpoint,
      body: body,
      response_object: @response_object
    )
  end
end

.fixtures_directoryObject



26
27
28
# File 'lib/vantiv/mocked_sandbox.rb', line 26

def self.fixtures_directory
  "#{Vantiv.root}/lib/vantiv/mocked_sandbox/fixtures/"
end