Module: RSpec::Resources::DSL

Defined in:
lib/rspec/resources/dsl.rb,
lib/rspec/resources/dsl/actions.rb,
lib/rspec/resources/dsl/matchers.rb,
lib/rspec/resources/dsl/characteristics.rb,
lib/rspec/resources/dsl/matchers/error_matcher.rb,
lib/rspec/resources/dsl/actions/include_if_needed.rb,
lib/rspec/resources/dsl/matchers/json_model_matcher.rb

Defined Under Namespace

Modules: Actions, Characteristics, Matchers

Instance Method Summary collapse

Instance Method Details

#describe_resource(base_path, options = {}, &block) ⇒ Object

Custom describe block that sets metadata to enable easy resource testing. In contrast to ‘#describe_resources` this method is meant for resources where only one instance exists. This directly correlates with the `resource` directive of the rails routes file.

describe_resources '/v1/profile', meta: :data do
  # ...
end

Params:

base_path

The resource base path, typically the one of the get action

options

RSpec’s ‘describe` metadata arguments

block

Block to pass into describe



39
40
41
# File 'lib/rspec/resources/dsl.rb', line 39

def describe_resource(base_path, options = {}, &block)
  abstract_describe(base_path, { single_resource: true }.merge(options), &block)
end

#describe_resources(base_path, options = {}, &block) ⇒ Object

Custom describe block that sets metadata to enable easy resource testing. This directly correlates with the ‘resources` directive of the rails routes file.

describe_resources '/v1/articles', meta: :data do
  # ...
end

Params:

base_path

The resources base path, typically the one of the index action

options

RSpec’s ‘describe` metadata arguments

block

Block to pass into describe



22
23
24
# File 'lib/rspec/resources/dsl.rb', line 22

def describe_resources(base_path, options = {}, &block)
  abstract_describe(base_path, { single_resource: false }.merge(options), &block)
end