Skip to content

Commit be5285c

Browse files
committed
Remove Lint/ConstantDefinitionInBlock exclusion for specs
The RSpec-recommended way to temporarily define constants with stub_const
1 parent 943bf87 commit be5285c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

.rubocop.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,3 @@ Style/Documentation:
5959
Exclude:
6060
- 'lib/**/*'
6161
- 'spec/**/*'
62-
Lint/ConstantDefinitionInBlock:
63-
Exclude:
64-
- 'spec/**/*'

spec/shared_examples/user_magic_login_shared_examples.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
end
3333

3434
it do
35-
TestMailerClass = Class.new # need a mailer class to test
35+
test_mailer_class = Class.new # need a mailer class to test
36+
stub_const('TestMailerClass', test_mailer_class)
3637
sorcery_model_property_set(:magic_login_mailer_class, TestMailerClass)
3738
expect(config.magic_login_mailer_class).to eq TestMailerClass
3839
end

spec/shared_examples/user_shared_examples.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@
184184

185185
it 'subclass inherits config if defined so' do
186186
sorcery_reload!([], subclasses_inherit_config: true)
187-
class Admin < User; end
187+
stub_const('Admin', Class.new(User))
188188

189189
expect(Admin.sorcery_config).not_to be_nil
190190
expect(Admin.sorcery_config).to eq User.sorcery_config
191191
end
192192

193193
it 'subclass does not inherit config if not defined so' do
194194
sorcery_reload!([], subclasses_inherit_config: false)
195-
class Admin2 < User; end
195+
stub_const('Admin2', Class.new(User))
196196

197197
expect(Admin2.sorcery_config).to be_nil
198198
end
@@ -386,7 +386,7 @@ class Admin2 < User; end
386386
end
387387

388388
it 'works with custom password encryption' do
389-
class MyCrypto
389+
my_crypto = Class.new do
390390
def self.encrypt(*tokens)
391391
tokens.join.tr('e', 'A')
392392
end
@@ -395,6 +395,7 @@ def self.matches?(crypted, *tokens)
395395
crypted == encrypt(*tokens)
396396
end
397397
end
398+
stub_const('MyCrypto', my_crypto)
398399
sorcery_model_property_set(:encryption_algorithm, :custom)
399400
sorcery_model_property_set(:custom_encryption_provider, MyCrypto)
400401

0 commit comments

Comments
 (0)