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, FixtureGenerator
Class Method Summary
collapse
Class Method Details
.disable_self_mocked_requests! ⇒ Object
19
20
21
22
23
|
# File 'lib/vantiv/mocked_sandbox.rb', line 19
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
|
# 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
)
end
end
|
.fixtures_directory ⇒ Object
25
26
27
|
# File 'lib/vantiv/mocked_sandbox.rb', line 25
def self.fixtures_directory
"#{Vantiv.root}/lib/vantiv/mocked_sandbox/fixtures/"
end
|