{"action":"created","issue":{"url":"https://api.github.com/repos/rspec/rspec-core/issues/2544","repository_url":"https://api.github.com/repos/rspec/rspec-core","labels_url":"https://api.github.com/repos/rspec/rspec-core/issues/2544/labels{/name}","comments_url":"https://api.github.com/repos/rspec/rspec-core/issues/2544/comments","events_url":"https://api.github.com/repos/rspec/rspec-core/issues/2544/events","html_url":"https://github.com/rspec/rspec-core/issues/2544","id":325455972,"number":2544,"title":"Nested Before/Around Run In Weird Order","user":{"login":"benmmurphy","id":392520,"avatar_url":"https://avatars2.githubusercontent.com/u/392520?v=4","gravatar_id":"","url":"https://api.github.com/users/benmmurphy","html_url":"https://github.com/benmmurphy","followers_url":"https://api.github.com/users/benmmurphy/followers","following_url":"https://api.github.com/users/benmmurphy/following{/other_user}","gists_url":"https://api.github.com/users/benmmurphy/gists{/gist_id}","starred_url":"https://api.github.com/users/benmmurphy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benmmurphy/subscriptions","organizations_url":"https://api.github.com/users/benmmurphy/orgs","repos_url":"https://api.github.com/users/benmmurphy/repos","events_url":"https://api.github.com/users/benmmurphy/events{/privacy}","received_events_url":"https://api.github.com/users/benmmurphy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-22T20:44:22Z","updated_at":"2018-05-24T21:03:57Z","closed_at":null,"author_association":"NONE","body":"### Subject of the issue\r\n\r\nIf you have a describe block with an before(:each) and then nest a describe block with an around(:each) the around(:each) runs before the before(:each). I would have thought the around(:each) is just a nice way of writing before(:each) after(:each) and sharing some state between them. but because of the way around(:each) always runs before before(:each) even if it is nested lower it makes around(:each) much less useful.\r\n\r\nthere doesn't seem to be a test case for this behaviour in the documentation so I'm not sure if this was deliberate or not. though, i guess it would be hard to change this behaviour because probably a lot of people rely on it.\r\n\r\nhttps://relishapp.com/rspec/rspec-core/v/2-0/docs/hooks/around-hooks#before/after(:each)-hooks-are-wrapped-by-the-around-hook\r\n\r\n### Your environment\r\n* Ruby version: 2.4.0\r\n* rspec-core version: 3.7\r\n\r\n### Steps to reproduce\r\n\r\n```\r\ndescribe \"filter\" do\r\n\r\n  before(:each) do\r\n    puts \"before each outer\"\r\n  end\r\n\r\n  describe \"inner\" do\r\n    around(:each) do |example|\r\n      puts \"around each inner\"\r\n      example.run\r\n    end\r\n\r\n    it \"should\" do\r\n      puts \"example\"\r\n    end\r\n  end\r\n\r\nend\r\n```\r\n\r\nactual:\r\n\r\n```\r\naround each inner\r\nbefore each outer\r\nexample\r\n```\r\n\r\nexpected:\r\n\r\n```\r\nbefore each outer\r\naround each inner\r\nexample\r\n```\r\n\r\nhere is how it works if they are both before(:each) rather than using an around(:each) for the inner.\r\n\r\n```\r\ndescribe \"filter\" do\r\n\r\n  before(:each) do\r\n    puts \"before each outer\"\r\n  end\r\n\r\n  describe \"inner\" do\r\n    before(:each) do\r\n      puts \"before each inner\"\r\n    end\r\n\r\n    it \"should\" do\r\n      puts \"example\"\r\n    end\r\n  end\r\n\r\nend\r\n```\r\n\r\n```\r\nbefore each outer\r\nbefore each inner\r\nexample\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/rspec/rspec-core/issues/comments/391861559","html_url":"https://github.com/rspec/rspec-core/issues/2544#issuecomment-391861559","issue_url":"https://api.github.com/repos/rspec/rspec-core/issues/2544","id":391861559,"user":{"login":"JonRowe","id":162976,"avatar_url":"https://avatars1.githubusercontent.com/u/162976?v=4","gravatar_id":"","url":"https://api.github.com/users/JonRowe","html_url":"https://github.com/JonRowe","followers_url":"https://api.github.com/users/JonRowe/followers","following_url":"https://api.github.com/users/JonRowe/following{/other_user}","gists_url":"https://api.github.com/users/JonRowe/gists{/gist_id}","starred_url":"https://api.github.com/users/JonRowe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JonRowe/subscriptions","organizations_url":"https://api.github.com/users/JonRowe/orgs","repos_url":"https://api.github.com/users/JonRowe/repos","events_url":"https://api.github.com/users/JonRowe/events{/privacy}","received_events_url":"https://api.github.com/users/JonRowe/received_events","type":"User","site_admin":false},"created_at":"2018-05-24T21:03:57Z","updated_at":"2018-05-24T21:03:57Z","author_association":"MEMBER","body":"Verified this is a bit odd, we should at least document the order that we expect this to run in, I think at least around hooks should run after before when defined in an inner context"}}
{"actor":{"display_login":"JonRowe"}}