Top Level Namespace

Extended by:
RSpecApi::Resource

Defined Under Namespace

Modules: RSpecApi, RspecApi

Instance Method Summary collapse

Methods included from RSpecApi::Resource::Accepts

#accepts

Methods included from RSpecApi::Resource::HasAttribute

#has_attribute

Methods included from RSpecApi::Resource::Options

#adapter, #authorize_with, #host, #throttle

Instance Method Details

#resource(name, args = {}, &block) ⇒ Object

You can also have the methods available in a RSpec Example group using ‘resource`. This is the only method that RSpecApi adds to the top-level namespace and it’s equivalent to a ‘describe` block with RSpecApi::Resource:

Examples:

Describe the resource artist:


resource :artist do
   ... # here you can write `get`, `has_attribute`, `host`, etc.
end


44
45
46
47
48
49
50
# File 'lib/rspec-api/resource.rb', line 44

def resource(name, args = {}, &block)
  describe name.to_s.pluralize.humanize, args do
    extend RSpecApi::Resource
    rspec_api_resource[:resource_name] = name
    instance_exec &block
  end
end