Class: Fitting::Tests

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/tests.rb

Instance Method Summary collapse

Constructor Details

#initialize(tested_requests) ⇒ Tests

Returns a new instance of Tests.



3
4
5
# File 'lib/fitting/tests.rb', line 3

def initialize(tested_requests)
  @tested_requests = tested_requests
end

Instance Method Details

#make_dir(dir_name) ⇒ Object



27
28
29
# File 'lib/fitting/tests.rb', line 27

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

#outgoing_saveObject



17
18
19
20
21
22
23
24
25
# File 'lib/fitting/tests.rb', line 17

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

#saveObject



7
8
9
10
11
12
13
14
15
# File 'lib/fitting/tests.rb', line 7

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