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.

Constants (e.g. class, module, etc) defined inside an example_group leak. #2181

@ioquatix

Description

@ioquatix

Say I have a spec:

#!/usr/bin/env rspec

RSpec.describe "define some module" do
    module MyModule
    end
end

RSpec.describe "a different example group" do
    it "should not have module defined" do
        expect(defined?(MyModule)).to be == nil
    end
end

I get the following output

a different example group
  should not have module defined (FAILED - 1)

Failures:

  1) a different example group should not have module defined
     Failure/Error: expect(defined?(MyModule)).to be == nil

       expected: == nil
            got:    "constant"
     # ./test.rb:10:in `block (2 levels) in <top (required)>'

Finished in 0.01106 seconds (files took 0.09443 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./test.rb:9 # a different example group should not have module defined

I don't know if this is expected, but it seems odd that constants defined in one example group would leak into another.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions