Skip to content

Commit

Permalink
Merge pull request #102 from rubocop-hq/add-leaky-constant-guideline
Browse files Browse the repository at this point in the history
Fix Declare Constants code example
  • Loading branch information
pirj committed Jul 23, 2019
2 parents b12fe28 + 4734cf6 commit 4e42fb6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ end
[#declare-constants]
=== Declare Constants

Do not explicitly declare classes, modules, or constants is example groups.
Do not explicitly declare classes, modules, or constants in example groups.
https://relishapp.com/rspec/rspec-mocks/docs/mutating-constants[Stub constants instead].

NOTE: Constants, including classes and modules, when declared in a block scope, are defined in global namespace, and leak between examples.
Expand Down Expand Up @@ -981,10 +981,12 @@ describe SomeClass do
end
# good - anonymous class, no constant needs to be defined
let(:foo_class) do
Class.new(described_class) do
def double_that
some_base_method * 2
describe SomeClass do
let(:foo_class) do
Class.new(described_class) do
def double_that
some_base_method * 2
end
end
end
Expand Down

0 comments on commit 4e42fb6

Please sign in to comment.