From d456a76a295f2a3cbffeaf8c9f5bf2ebe804f207 Mon Sep 17 00:00:00 2001 From: Robert Dormer Date: Mon, 25 Jan 2021 15:57:01 -0500 Subject: [PATCH] =?UTF-8?q?Ignore=20folders=20that=20either=20start=20or?= =?UTF-8?q?=20end=20with=20spec=20or=20test,=20which=20will=E2=80=A6=20(#6?= =?UTF-8?q?5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ignore folders that either start or end with spec or test, which will skip nested folders as well as top level * Add test to verify nested spec folders are ignored * Update changelog Co-authored-by: bronzdoc --- CHANGELOG.md | 1 + lib/skunk/cli/commands/status_reporter.rb | 3 ++- samples/engines/spec/nested_sample_spec.rb | 5 +++++ test/lib/skunk/cli/commands/status_reporter_test.rb | 8 ++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 samples/engines/spec/nested_sample_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index c2de039..968e7e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] Skip both nested and top level spec and test folders ## [Unreleased] [(commits)](https://github.com/fastruby/skunk/compare/v0.4.2...HEAD) * [FEATURE] Share your results using an environment variable (by [@rahulpuroht]() and [@etagwerker]()) diff --git a/lib/skunk/cli/commands/status_reporter.rb b/lib/skunk/cli/commands/status_reporter.rb index 4a78d56..be43eef 100644 --- a/lib/skunk/cli/commands/status_reporter.rb +++ b/lib/skunk/cli/commands/status_reporter.rb @@ -43,7 +43,8 @@ def analysed_modules_count def non_test_modules @non_test_modules ||= analysed_modules.reject do |a_module| - a_module.pathname.to_s.start_with?("test", "spec") + module_path = a_module.pathname.dirname.to_s + module_path.start_with?("test", "spec") || module_path.end_with?("test", "spec") end end diff --git a/samples/engines/spec/nested_sample_spec.rb b/samples/engines/spec/nested_sample_spec.rb new file mode 100644 index 0000000..97e5559 --- /dev/null +++ b/samples/engines/spec/nested_sample_spec.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +def hello + puts "hello world" +end diff --git a/test/lib/skunk/cli/commands/status_reporter_test.rb b/test/lib/skunk/cli/commands/status_reporter_test.rb index 40e1f37..ad73997 100644 --- a/test/lib/skunk/cli/commands/status_reporter_test.rb +++ b/test/lib/skunk/cli/commands/status_reporter_test.rb @@ -35,6 +35,14 @@ def analysed_module.churn _(reporter.update_status_message).must_include output _(reporter.update_status_message).must_include "Generated with Skunk v#{Skunk::VERSION}" end + + context "When there's nested spec files" do + let(:paths) { "samples" } + it "reports the SkunkScore" do + _(reporter.update_status_message).must_include output + _(reporter.update_status_message).must_include "Generated with Skunk v#{Skunk::VERSION}" + end + end end end