Module: RspecApiDocumentation::DSL::Resource::ClassMethods

Defined in:
lib/rspec_api_documentation/dsl/resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_action(method) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rspec_api_documentation/dsl/resource.rb', line 7

def self.define_action(method)
  define_method method do |*args, &block|
    options = args.extract_options!
    options[:method] = method
    options[:route] = args.first
    options[:api_doc_dsl] = :endpoint
    args.push(options)
    args[0] = "#{method.to_s.upcase} #{args[0]}"
    context(*args, &block)
  end
end

Instance Method Details

#callback(*args, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rspec_api_documentation/dsl/resource.rb', line 26

def callback(*args, &block)
  begin
    require 'webmock'
  rescue LoadError
    raise "Callbacks require webmock to be installed"
  end
  self.send(:include, WebMock::API)

  options = if args.last.is_a?(Hash) then args.pop else {} end
  options[:api_doc_dsl] = :callback
  args.push(options)

  context(*args, &block)
end

#header(name, value) ⇒ Object



49
50
51
# File 'lib/rspec_api_documentation/dsl/resource.rb', line 49

def header(name, value)
  headers[name] = value
end

#parameter(name, *args) ⇒ Object



41
42
43
# File 'lib/rspec_api_documentation/dsl/resource.rb', line 41

def parameter(name, *args)
  parameters.push(field_specification(name, *args))
end

#response_field(name, *args) ⇒ Object



45
46
47
# File 'lib/rspec_api_documentation/dsl/resource.rb', line 45

def response_field(name, *args)
  response_fields.push(field_specification(name, *args))
end