RSpec / RSpec Core / Docs / Example groups
aliasing
describe and context are the default aliases for example_group. You can define your own aliases for example_group and give those custom aliases default metadata.
RSpec provides a few built-in aliases:
xdescribeandxcontextadd:skipmetadata to the example group in order to temporarily disable the examples.fdescribeandfcontextadd:focusmetadata to the example group in order to make it easy to temporarily focus the example group (when combined withconfig.filter_run :focus.)
Scenario: Custom example group aliases with metadata
- Given a file named "
nested_example_group_aliases_spec.rb" with:rubyRSpec.configure do |c| c.alias_example_group_to :detail, :detailed => true end RSpec.detail "a detail" do it "can do some less important stuff" do end end RSpec.describe "a thing" do describe "in broad strokes" do it "can do things" do end end detail "something less important" do it "can do an unimportant thing" do end end end - When I run `rspec nested_example_group_aliases_spec.rb --tag detailed -fdoc`
- Then the output should contain:
text
a detail can do some less important stuff a thing something less important
Source: features/example_groups/aliasing.feature at v3.10.2, RSpec Core (MIT license).