Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Contrary to documentation,around hooks runs before before #2729

@rahul342

Description

@rahul342

Subject of the issue

Contrary to documentation,around hooks runs before before

Describe your issue here.
The docs here https://www.rubydoc.info/gems/rspec-core/RSpec%2FCore%2FHooks%3Aaround says -

All around hooks execute immediately surrounding an example, this means that all before hooks will have run and no after hooks will have run yet.

Your environment

  • Ruby version: 2.7.1p83
  • rspec-core version: 3.9.2

Steps to reproduce

Here's the example I used

RSpec.configure do |config|
  config.before(:each) do
    puts 'before in configure'
  end
end

RSpec.describe "Order" do
  before(:each) do
    puts 'before in describe'
  end

  around do |t|
    puts 'around started'
    t.run
    puts 'around exiting'
  end

  it 'some example' do
  end
end

Expected behavior

I would expect the prints in before to show before the prints in around since

all before hooks will have run

Actual behavior

This is the output I get

around started
before in configure
before in describe
around exiting

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions