Module: RSpec::Rails::Swagger::Helpers::Paths

Defined in:
lib/rspec/rails/swagger/helpers.rb

Instance Method Summary collapse

Instance Method Details

#path(template, attributes = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rspec/rails/swagger/helpers.rb', line 41

def path template, attributes = {}, &block
  attributes.symbolize_keys!

  raise ArgumentError, "Path must start with a /" unless template.starts_with?('/')

  #TODO template might be a $ref
  meta = {
    swagger_object: :path_item,
    swagger_document: attributes[:swagger_document] || RSpec.configuration.swagger_docs.keys.first,
    swagger_path_item: {path: template}
  }
  describe(template, meta, &block)
end