Sha256: fc271308cd7a85e12c01169fda06bdcb5b50cfbbd367eb0c68e2f3c19d1e6622

Contents?: true

Size: 880 Bytes

Versions: 3

Compression:

Stored size: 880 Bytes

Contents

module Fitting
  class Tests
    def initialize(tested_requests)
      @tested_requests = tested_requests
    end

    def save
      make_dir(Fitting.configuration.rspec_json_path)
      array = @tested_requests.inject([]) do |res, request|
        res.push(request.to_spherical.to_hash)
      end
      json = JSON.dump(array)

      File.open("#{Fitting.configuration.rspec_json_path}/test#{ENV['TEST_ENV_NUMBER']}.json", 'w') { |file| file.write(json) }
    end

    def outgoing_save
      make_dir('./outgoing_request_tests')
      array = @tested_requests.inject([]) do |res, request|
        res.push(request.to_spherical.to_hash)
      end
      json = JSON.dump(array)

      File.open("./outgoing_request_tests/test#{ENV['TEST_ENV_NUMBER']}.json", 'w') { |file| file.write(json) }
    end

    def make_dir(dir_name)
      FileUtils.mkdir_p(dir_name)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fitting-3.0.2 lib/fitting/tests.rb
fitting-3.0.1 lib/fitting/tests.rb
fitting-3.0.0 lib/fitting/tests.rb