Method: RSpec::Core::ExampleGroup.it

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

.itvoid .it(&example_implementation) ⇒ void .it(doc_string, *metadata) ⇒ void .it(doc_string, *metadata, &example_implementation) ⇒ void

Defines an example within a group. This is the primary API to define a code example.

Examples:

it do
end

it "does something" do
end

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

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

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

Overloads:

  • .it(&example_implementation) ⇒ void

    Parameters:

    • example_implementation (Block)

      The implementation of the example.

  • .it(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.

  • .it(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:

[View source]

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

define_example_method :it