From 4b035896c4ed188c0b4ab0e0b5d1d97e4fef9886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 30 Mar 2018 17:18:12 +0200 Subject: Introduce a new FactoriesInMigrationSpecs cop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- rubocop/spec_helpers.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'rubocop/spec_helpers.rb') diff --git a/rubocop/spec_helpers.rb b/rubocop/spec_helpers.rb index a702a083958..6c0f0193b1a 100644 --- a/rubocop/spec_helpers.rb +++ b/rubocop/spec_helpers.rb @@ -6,7 +6,18 @@ module RuboCop def in_spec?(node) path = node.location.expression.source_buffer.name - !SPEC_HELPERS.include?(File.basename(path)) && path.start_with?(File.join(Dir.pwd, 'spec')) + !SPEC_HELPERS.include?(File.basename(path)) && + path.start_with?(File.join(Dir.pwd, 'spec'), File.join(Dir.pwd, 'ee', 'spec')) + end + + # Returns true if the given node originated from a migration spec. + def in_migration_spec?(node) + path = node.location.expression.source_buffer.name + + in_spec?(node) && + path.start_with?( + File.join(Dir.pwd, 'spec', 'migrations'), + File.join(Dir.pwd, 'ee', 'spec', 'migrations')) end end end -- cgit v1.2.1