Sha256: e6cf0e96bea6dc000316ca45887a09357a7ababd2c8b4b736290aeb1d24da04d

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require "coveralls"
Coveralls.wear!("test_frameworks")

require "telnyx"
require "test/unit"
require "mocha/setup"
require "stringio"
require "shoulda/context"
require "timecop"
require "webmock/test_unit"

PROJECT_ROOT = ::File.expand_path("../../", __FILE__)

require ::File.expand_path("../test_data", __FILE__)

# Set up Proxy server configuration
PROXY_PORT = 12_111 # Port where your proxy server is running
PROXY_HOST = "localhost"
PROXY_BASE_URL = "http://#{PROXY_HOST}:#{PROXY_PORT}".freeze

# Disable all real network connections except those that are outgoing to
# the Proxy server.
WebMock.disable_net_connect!(allow: "#{PROXY_HOST}:#{PROXY_PORT}")

# You can remove the Telnyx mock setup as it's not needed for Prism

Test::Unit.at_exit do
  # Clean up actions for Proxy if required
end

module Test
  module Unit
    class TestCase
      include Telnyx::TestData
      include Mocha

      setup do
        Telnyx.api_key = "KEYSUPERSECRET" # Set your desired API key or the one expected by the proxy/Prism
        Telnyx.api_base = PROXY_BASE_URL # Use Proxy's base URL

        # stub_connect
      end

      teardown do
        Telnyx.api_key = nil
      end

      private

      def stub_connect
        stub_request(:any, /^#{Telnyx.api_base}/).to_return(body: "{}")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
telnyx-3.0.6 test/test_helper.rb
telnyx-3.0.5 test/test_helper.rb
telnyx-3.0.4 test/test_helper.rb
telnyx-3.0.3 test/test_helper.rb
telnyx-3.0.2 test/test_helper.rb
telnyx-3.0.0 test/test_helper.rb