Sha256: 75ec67bae4b835bc4b2c8e4fbc30783381f6384c37bb28a7e2fb5ccbb13044be

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true
require 'rspec/rails' if defined?(RSpec::Rails)

RSpec.configure do |config|
  config.before(:suite) do
    root = Rpdoc.configuration.rpdoc_root
    if Rpdoc.configuration.rpdoc_enable
      raise StandardError.new('Configuration Invalid') unless Rpdoc.configuration.valid?
      FileUtils.mkdir_p(root) unless File.exist?(root)
      Dir.glob("#{root}/**/*.json") do |filename|
        File.delete(filename)
      end
    end
  end

  config.after(:suite) do
    if Rpdoc.configuration.rpdoc_enable
      postman_collection = Rpdoc::PostmanCollection.new
      postman_collection.save
      postman_collection.send(Rpdoc.configuration.rpdoc_auto_push_strategy) if Rpdoc.configuration.rpdoc_auto_push
    end
  end
end
  
RSpec.shared_context 'rpdoc' do
  after(:each) do |example|
    example.metadata[:rpdoc_skip] ||= false
    if Rpdoc.configuration.rpdoc_enable && example.exception.nil? && example.metadata[:type] == :request && example.metadata[:rpdoc_skip] == false
      example.metadata[:rpdoc_action_key] ||= controller.action_name
      example.metadata[:rpdoc_action_name] ||= controller.action_name
      example.metadata[:rpdoc_example_key] ||= example.metadata[:description].underscore
      example.metadata[:rpdoc_example_name] ||= example.metadata[:description]
      example.metadata[:rpdoc_example_folders] ||= controller.class.controller_path.split('/')
      
      postman_response = Rpdoc::PostmanResponse.new(example, request, response)
      postman_response.save
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rpdoc-0.1.16 lib/rpdoc/helper.rb