summaryrefslogtreecommitdiff
path: root/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/inject_enterprise_edition_module_spec.rb')
-rw-r--r--spec/rubocop/cop/inject_enterprise_edition_module_spec.rb178
1 files changed, 41 insertions, 137 deletions
diff --git a/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb b/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
index 8bfa57031d7..962efc23453 100644
--- a/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
+++ b/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
@@ -6,173 +6,77 @@ require_relative '../../../rubocop/cop/inject_enterprise_edition_module'
RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
subject(:cop) { described_class.new }
- it 'flags the use of `prepend_if_ee EE` in the middle of a file' do
+ it 'flags the use of `prepend_mod_with` in the middle of a file' do
expect_offense(<<~SOURCE)
class Foo
- prepend_if_ee 'EE::Foo'
- ^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ prepend_mod_with('Foo')
+ ^^^^^^^^^^^^^^^^^^^^^^^ Injecting extension modules must be done on the last line of this file, outside of any class or module definitions
end
SOURCE
end
- it 'flags the use of `prepend_if_ee QA::EE` in the middle of a file' do
+ it 'flags the use of `include_mod_with` in the middle of a file' do
expect_offense(<<~SOURCE)
class Foo
- prepend_if_ee 'QA::EE::Foo'
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ include_mod_with('Foo')
+ ^^^^^^^^^^^^^^^^^^^^^^^ Injecting extension modules must be done on the last line of this file, outside of any class or module definitions
end
SOURCE
end
-
- it 'does not flag the use of `prepend_if_ee EEFoo` in the middle of a file' do
- expect_no_offenses(<<~SOURCE)
- class Foo
- prepend_if_ee 'EEFoo'
- end
- SOURCE
- end
-
- it 'flags the use of `prepend_if_ee EE::Foo::Bar` in the middle of a file' do
- expect_offense(<<~SOURCE)
- class Foo
- prepend_if_ee 'EE::Foo::Bar'
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
- SOURCE
- end
-
- it 'flags the use of `prepend_if_ee(EE::Foo::Bar)` in the middle of a file' do
- expect_offense(<<~SOURCE)
- class Foo
- prepend_if_ee('EE::Foo::Bar')
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
- SOURCE
- end
-
- it 'flags the use of `prepend_if_ee EE::Foo::Bar::Baz` in the middle of a file' do
+ it 'flags the use of `extend_mod_with` in the middle of a file' do
expect_offense(<<~SOURCE)
class Foo
- prepend_if_ee 'EE::Foo::Bar::Baz'
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
- SOURCE
- end
-
- it 'flags the use of `prepend_if_ee ::EE` in the middle of a file' do
- expect_offense(<<~SOURCE)
- class Foo
- prepend_if_ee '::EE::Foo'
- ^^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
- SOURCE
- end
-
- it 'flags the use of `include_if_ee EE` in the middle of a file' do
- expect_offense(<<~SOURCE)
- class Foo
- include_if_ee 'EE::Foo'
- ^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
- SOURCE
- end
-
- it 'flags the use of `include_if_ee ::EE` in the middle of a file' do
- expect_offense(<<~SOURCE)
- class Foo
- include_if_ee '::EE::Foo'
- ^^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
- SOURCE
- end
-
- it 'flags the use of `extend_if_ee EE` in the middle of a file' do
- expect_offense(<<~SOURCE)
- class Foo
- extend_if_ee 'EE::Foo'
- ^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
- SOURCE
- end
-
- it 'flags the use of `extend_if_ee ::EE` in the middle of a file' do
- expect_offense(<<~SOURCE)
- class Foo
- extend_if_ee '::EE::Foo'
- ^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
- SOURCE
- end
-
- it 'does not flag prepending of regular modules' do
- expect_no_offenses(<<~SOURCE)
- class Foo
- prepend_if_ee 'Foo'
- end
- SOURCE
- end
-
- it 'does not flag including of regular modules' do
- expect_no_offenses(<<~SOURCE)
- class Foo
- include_if_ee 'Foo'
- end
- SOURCE
- end
-
- it 'does not flag extending using regular modules' do
- expect_no_offenses(<<~SOURCE)
- class Foo
- extend_if_ee 'Foo'
+ extend_mod_with('Foo')
+ ^^^^^^^^^^^^^^^^^^^^^^ Injecting extension modules must be done on the last line of this file, outside of any class or module definitions
end
SOURCE
end
- it 'does not flag the use of `prepend_if_ee EE` on the last line' do
+ it 'does not flag the use of `prepend_mod_with` on the last line' do
expect_no_offenses(<<~SOURCE)
class Foo
end
- Foo.prepend_if_ee('EE::Foo')
+ Foo.prepend_mod_with('Foo')
SOURCE
end
- it 'does not flag the use of `include_if_ee EE` on the last line' do
+ it 'does not flag the use of `include_mod_with` on the last line' do
expect_no_offenses(<<~SOURCE)
class Foo
end
- Foo.include_if_ee('EE::Foo')
+ Foo.include_mod_with('Foo')
SOURCE
end
- it 'does not flag the use of `extend_if_ee EE` on the last line' do
+ it 'does not flag the use of `extend_mod_with` on the last line' do
expect_no_offenses(<<~SOURCE)
class Foo
end
- Foo.extend_if_ee('EE::Foo')
+ Foo.extend_mod_with('Foo')
SOURCE
end
- it 'does not flag the double use of `X_if_ee` on the last line' do
+ it 'does not flag the double use of `X_mod_with` on the last line' do
expect_no_offenses(<<~SOURCE)
class Foo
end
- Foo.extend_if_ee('EE::Foo')
- Foo.include_if_ee('EE::Foo')
- Foo.prepend_if_ee('EE::Foo')
+ Foo.extend_mod_with('Foo')
+ Foo.include_mod_with('Foo')
+ Foo.prepend_mod_with('Foo')
SOURCE
end
- it 'does not flag the use of `prepend_if_ee EE` as long as all injections are at the end of the file' do
+ it 'does not flag the use of `prepend_mod_with` as long as all injections are at the end of the file' do
expect_no_offenses(<<~SOURCE)
class Foo
end
- Foo.include_if_ee('EE::Foo')
- Foo.prepend_if_ee('EE::Foo')
+ Foo.include_mod_with('Foo')
+ Foo.prepend_mod_with('Foo')
Foo.include(Bar)
# comment on prepending Bar
@@ -183,27 +87,27 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
it 'autocorrects offenses by just disabling the Cop' do
expect_offense(<<~SOURCE)
class Foo
- prepend_if_ee 'EE::Foo'
- ^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- include_if_ee 'Bar'
+ prepend_mod_with('Foo')
+ ^^^^^^^^^^^^^^^^^^^^^^^ Injecting extension modules must be done on the last line of this file, outside of any class or module definitions
+ include Bar
end
SOURCE
expect_correction(<<~SOURCE)
class Foo
- prepend_if_ee 'EE::Foo' # rubocop: disable Cop/InjectEnterpriseEditionModule
- include_if_ee 'Bar'
+ prepend_mod_with('Foo') # rubocop: disable Cop/InjectEnterpriseEditionModule
+ include Bar
end
SOURCE
end
- it 'disallows the use of prepend to inject an EE module' do
+ it 'disallows the use of prepend to inject an extension module' do
expect_offense(<<~SOURCE)
class Foo
end
Foo.prepend(EE::Foo)
- ^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_if_ee`
+ ^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_mod_with`, `extend_mod_with`, or `prepend_mod_with`
SOURCE
end
@@ -213,7 +117,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end
Foo.prepend(QA::EE::Foo)
- ^^^^^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_if_ee`
+ ^^^^^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_mod_with`, `extend_mod_with`, or `prepend_mod_with`
SOURCE
end
@@ -223,7 +127,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end
Foo.extend(EE::Foo)
- ^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_if_ee`
+ ^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_mod_with`, `extend_mod_with`, or `prepend_mod_with`
SOURCE
end
@@ -233,37 +137,37 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end
Foo.include(EE::Foo)
- ^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_if_ee`
+ ^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_mod_with`, `extend_mod_with`, or `prepend_mod_with`
SOURCE
end
- it 'disallows the use of prepend_if_ee without a String' do
+ it 'disallows the use of prepend_mod_with without a String' do
expect_offense(<<~SOURCE)
class Foo
end
- Foo.prepend_if_ee(EE::Foo)
- ^^^^^^^ EE modules to inject must be specified as a String
+ Foo.prepend_mod_with(Foo)
+ ^^^ extension modules to inject must be specified as a String
SOURCE
end
- it 'disallows the use of include_if_ee without a String' do
+ it 'disallows the use of include_mod_with without a String' do
expect_offense(<<~SOURCE)
class Foo
end
- Foo.include_if_ee(EE::Foo)
- ^^^^^^^ EE modules to inject must be specified as a String
+ Foo.include_mod_with(Foo)
+ ^^^ extension modules to inject must be specified as a String
SOURCE
end
- it 'disallows the use of extend_if_ee without a String' do
+ it 'disallows the use of extend_mod_with without a String' do
expect_offense(<<~SOURCE)
class Foo
end
- Foo.extend_if_ee(EE::Foo)
- ^^^^^^^ EE modules to inject must be specified as a String
+ Foo.extend_mod_with(Foo)
+ ^^^ extension modules to inject must be specified as a String
SOURCE
end
end