Contents

This page comes from RSpec Mocks 2.7.1. It is not part of the 3.12.4 docs. See the latest RSpec Mocks docs.

current example

You can reference the example object, and access its metadata, using the example method within an example.

Scenario: access the example object from within an example

  • Given a file named "spec/example_spec.rb" with:
    ruby
    describe "an example" do
      it "knows itself as example" do
        example.description.should eq("knows itself as example")
      end
    end
  • When I run `rspec spec/example_spec.rb`
  • Then the example should pass

Source: features/metadata/current_example.feature at v2.7.1, RSpec Mocks (MIT license).