Method: RSpec::Core::ExampleGroup.specify

Defined in:
lib/rspec/core/example_group.rb

.specifyvoid .specify(&example_implementation) ⇒ void .specify(doc_string, *metadata) ⇒ void .specify(doc_string, *metadata, &example_implementation) ⇒ void

Defines an example within a group. Useful for when your docstring does not read well off of it.

Examples:

RSpec.describe MyClass do
  specify "#do_something is deprecated" do
    # ...
  end
end
specify do
end

specify "does something" do
end

specify "does something", :slow, :uses_js do
end

specify "does something", :with => 'additional metadata' do
end

specify "does something" do |ex|
  # ex is the Example object that contains metadata about the example
end

Overloads:

  • .specify(&example_implementation) ⇒ void

    Parameters:

    • example_implementation (Block)

      The implementation of the example.

  • .specify(doc_string, *metadata) ⇒ void

    Parameters:

    • doc_string (String)

      The example's doc string.

    • metadata (Array<Symbol>, Hash)

      Metadata for the example. Symbols will be transformed into hash entries with true values.

  • .specify(doc_string, *metadata, &example_implementation) ⇒ void

    Parameters:

    • doc_string (String)

      The example's doc string.

    • metadata (Array<Symbol>, Hash)

      Metadata for the example. Symbols will be transformed into hash entries with true values.

    • example_implementation (Block)

      The implementation of the example.

Yields:


170
# File 'lib/rspec/core/example_group.rb', line 170

define_example_method :specify