|
| 1 | +require "rspec_api_documentation" |
1 | 2 | require "rspec_api_documentation/dsl/resource"
|
2 | 3 | require "rspec_api_documentation/dsl/endpoint"
|
3 | 4 | require "rspec_api_documentation/dsl/callback"
|
4 | 5 |
|
5 |
| -# Custom describe block that sets metadata to enable the rest of RAD |
6 |
| -# |
7 |
| -# resource "Orders", :meta => :data do |
8 |
| -# # ... |
9 |
| -# end |
10 |
| -# |
11 |
| -# Params: |
12 |
| -# +args+:: Glob of RSpec's `describe` arguments |
13 |
| -# +block+:: Block to pass into describe |
14 |
| -# |
15 |
| -def self.resource(*args, &block) |
16 |
| - options = if args.last.is_a?(Hash) then args.pop else {} end |
17 |
| - options[:api_doc_dsl] = :resource |
18 |
| - options[:resource_name] = args.first |
19 |
| - options[:document] ||= :all |
20 |
| - args.push(options) |
21 |
| - describe(*args, &block) |
| 6 | + |
| 7 | +module RspecApiDocumentation |
| 8 | + module DSL |
| 9 | + |
| 10 | + # Custom describe block that sets metadata to enable the rest of RAD |
| 11 | + # |
| 12 | + # resource "Orders", :meta => :data do |
| 13 | + # # ... |
| 14 | + # end |
| 15 | + # |
| 16 | + # Params: |
| 17 | + # +args+:: Glob of RSpec's `describe` arguments |
| 18 | + # +block+:: Block to pass into describe |
| 19 | + # |
| 20 | + def resource(*args, &block) |
| 21 | + options = if args.last.is_a?(Hash) then args.pop else {} end |
| 22 | + options[:api_doc_dsl] = :resource |
| 23 | + options[:resource_name] = args.first |
| 24 | + options[:document] ||= :all |
| 25 | + args.push(options) |
| 26 | + describe(*args, &block) |
| 27 | + end |
| 28 | + end |
22 | 29 | end
|
23 | 30 |
|
| 31 | +RSpec::Core::ExampleGroup.extend(RspecApiDocumentation::DSL) |
| 32 | +RSpec::Core::DSL.expose_example_group_alias(:resource) |
| 33 | + |
24 | 34 | RSpec.configuration.include RspecApiDocumentation::DSL::Resource, :api_doc_dsl => :resource
|
25 | 35 | RSpec.configuration.include RspecApiDocumentation::DSL::Endpoint, :api_doc_dsl => :endpoint
|
26 | 36 | RSpec.configuration.include RspecApiDocumentation::DSL::Callback, :api_doc_dsl => :callback
|
|
0 commit comments