Class: Rpdoc::PostmanResponse
- Inherits:
-
Object
- Object
- Rpdoc::PostmanResponse
- Defined in:
- lib/rpdoc/postman_response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(rspec_example, rspec_request, rspec_response) ⇒ PostmanResponse
constructor
A new instance of PostmanResponse.
- #save ⇒ Object
Constructor Details
#initialize(rspec_example, rspec_request, rspec_response) ⇒ PostmanResponse
Returns a new instance of PostmanResponse.
7 8 9 10 11 12 13 14 |
# File 'lib/rpdoc/postman_response.rb', line 7 def initialize(rspec_example, rspec_request, rspec_response) @rspec_example = rspec_example @rspec_request = rspec_request @rspec_response = rspec_response @configuration = Rpdoc.configuration @data = response_data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/rpdoc/postman_response.rb', line 5 def data @data end |
Instance Method Details
#save ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rpdoc/postman_response.rb', line 16 def save root_path ||= @configuration.rpdoc_root folder_path = "#{root_path}/#{@rspec_example.metadata[:rpdoc_example_folders].join('/')}/#{@rspec_example.metadata[:rpdoc_action_key]}" FileUtils.mkdir_p(folder_path) unless File.exists?(folder_path) request_file_path = "#{folder_path}/#{@configuration.rpdoc_request_filename}" File.open(request_file_path, 'w+') { |f| f.write(JSON.pretty_generate(request_data)) } unless File.exists?(request_file_path) response_file_path = "#{folder_path}/#{@rspec_example.metadata[:rpdoc_example_key]}.json" File.open(response_file_path, 'w+') { |f| f.write(JSON.pretty_generate(response_data)) } end |