Module: RSpec::Rails::Swagger::Helpers::PathItem

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

Constant Summary collapse

METHODS =
%w(get put post delete options head patch).freeze

Instance Method Summary collapse

Instance Method Details

#operation(method, attributes = {}, &block) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/rspec/rails/swagger/helpers.rb', line 68

def operation method, attributes = {}, &block
  attributes.symbolize_keys!
  # Include tags from parent contexts so you can tag all the paths
  # in a controller at once.
  if .try(:[], :tags).present?
    attributes[:tags] ||= []
    attributes[:tags] += [:tags]
  end

  method = method.to_s.downcase
  validate_method! method

  meta = {
    swagger_object: :operation,
    swagger_operation: attributes.merge(method: method.to_sym).reject{ |v| v.nil? }
  }
  describe(method.to_s, meta, &block)
end