Method: RSpec::Core::Configuration#alias_example_to

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

#alias_example_to(name, *args) ⇒ void

Note:

The specific example alias below (pending) is already defined for you.

Note:

Use with caution. This extends the language used in your specs, but does not add any additional documentation. We use this in RSpec to define methods like focus and xit, but we also add docs for those methods.

Creates a method that delegates to example including the submitted args. Used internally to add variants of example like pending:

Examples:

RSpec.configure do |config|
  config.alias_example_to :pending, :pending => true
end

# This lets you do this:

RSpec.describe Thing do
  pending "does something" do
    thing = Thing.new
  end
end

# ... which is the equivalent of

RSpec.describe Thing do
  it "does something", :pending => true do
    thing = Thing.new
  end
end

Parameters:

  • name (String)

    example name alias

  • args (Array<Symbol>, Hash)

    metadata for the generated example



1171
1172
1173
1174
# File 'lib/rspec/core/configuration.rb', line 1171

def alias_example_to(name, *args)
  extra_options = Metadata.build_hash_from(args)
  RSpec::Core::ExampleGroup.define_example_method(name, extra_options)
end