class CIHelper::Commands::CheckSpecSuffixes

Public Instance Methods

call() click to toggle source
# File lib/ci_helper/commands/check_spec_suffixes.rb, line 6
def call
  paths = target_paths.reject { |path| path.end_with?("_spec.rb") }
  fail!("Detected specs without _spec suffix: #{paths.join(" ")}") if paths.any?
  0
end

Private Instance Methods

base_paths() click to toggle source
# File lib/ci_helper/commands/check_spec_suffixes.rb, line 27
def base_paths
  Dir["spec/*/**/*.rb"]
end
extra_paths() click to toggle source
# File lib/ci_helper/commands/check_spec_suffixes.rb, line 31
def extra_paths
  @extra_paths ||= plural_option(:extra_paths).flat_map { |path| Dir[path] }
end
ignored_paths() click to toggle source
# File lib/ci_helper/commands/check_spec_suffixes.rb, line 35
def ignored_paths
  @ignored_paths ||= plural_option(:ignored_paths).flat_map { |path| Dir[path] }
end
spec_paths() click to toggle source
# File lib/ci_helper/commands/check_spec_suffixes.rb, line 18
def spec_paths
  base_paths.select do |path|
    next if path.start_with?("spec/support")
    next if path.start_with?("spec/factories")
    next if path.end_with?("context.rb")
    true
  end
end
target_paths() click to toggle source
# File lib/ci_helper/commands/check_spec_suffixes.rb, line 14
def target_paths
  spec_paths + extra_paths - ignored_paths
end