diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d5157948..e0abe295 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -59,7 +59,6 @@ end # MessageHelper RSpec.configure do |config| config.extend(SharedContext) - config.include(CompressHelper) config.include(MessageHelper) config.include(ParserHelper) config.include(Mutant::AST::Sexp) diff --git a/spec/support/compress_helper.rb b/spec/support/compress_helper.rb deleted file mode 100644 index 2f841bb3..00000000 --- a/spec/support/compress_helper.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true -module CompressHelper - def strip_indent(string) - lines = string.lines - match = /\A( *)/.match(lines.first) - return string unless match - whitespaces = match[1].to_s.length - lines.map { |line| line[whitespaces..-1] }.join - end -end # CompressHelper diff --git a/spec/support/shared_context.rb b/spec/support/shared_context.rb index df5f553f..9ac65022 100644 --- a/spec/support/shared_context.rb +++ b/spec/support/shared_context.rb @@ -28,7 +28,7 @@ module SharedContext it 'writes expected report to output' do described_class.call(output, reportable) output.rewind - expect(output.read).to eql(strip_indent(expected_content)) + expect(output.read).to eql(expected_content) end end diff --git a/spec/unit/mutant/cli_spec.rb b/spec/unit/mutant/cli_spec.rb index e8f4e4f9..dd72e84e 100644 --- a/spec/unit/mutant/cli_spec.rb +++ b/spec/unit/mutant/cli_spec.rb @@ -108,21 +108,21 @@ RSpec.describe Mutant::CLI do it_should_behave_like 'a cli parser' let(:expected_message) do - strip_indent(<<-MESSAGE) -usage: mutant [options] MATCH_EXPRESSION ... -Environment: - --zombie Run mutant zombified - -I, --include DIRECTORY Add DIRECTORY to $LOAD_PATH - -r, --require NAME Require file with NAME - -j, --jobs NUMBER Number of kill jobs. Defaults to number of processors. + <<~MESSAGE + usage: mutant [options] MATCH_EXPRESSION ... + Environment: + --zombie Run mutant zombified + -I, --include DIRECTORY Add DIRECTORY to $LOAD_PATH + -r, --require NAME Require file with NAME + -j, --jobs NUMBER Number of kill jobs. Defaults to number of processors. -Options: - --use INTEGRATION Use INTEGRATION to kill mutations - --ignore-subject EXPRESSION Ignore subjects that match EXPRESSION as prefix - --since REVISION Only select subjects touched since REVISION - --fail-fast Fail fast - --version Print mutants version - -h, --help Show this message + Options: + --use INTEGRATION Use INTEGRATION to kill mutations + --ignore-subject EXPRESSION Ignore subjects that match EXPRESSION as prefix + --since REVISION Only select subjects touched since REVISION + --fail-fast Fail fast + --version Print mutants version + -h, --help Show this message MESSAGE end end diff --git a/spec/unit/mutant/diff_spec.rb b/spec/unit/mutant/diff_spec.rb index b55b0c6f..5d0416fe 100644 --- a/spec/unit/mutant/diff_spec.rb +++ b/spec/unit/mutant/diff_spec.rb @@ -56,7 +56,7 @@ RSpec.describe Mutant::Diff do let(:new) { %w[baz bar baz] } let(:expectation) do - strip_indent(<<-STR) + <<~STR @@ -1,4 +1,4 @@ -foo +baz @@ -76,7 +76,7 @@ RSpec.describe Mutant::Diff do let(:new) { %w[baz bar] } let(:expectation) do - strip_indent(<<-STR) + <<~STR @@ -1,3 +1,3 @@ -foo +baz @@ -94,7 +94,7 @@ RSpec.describe Mutant::Diff do let(:new) { %w[foo baz bar] } let(:expectation) do - strip_indent(<<-STR) + <<~STR @@ -1,3 +1,4 @@ foo +baz @@ -112,7 +112,7 @@ RSpec.describe Mutant::Diff do let(:new) { %w[foo bar baz boz a b c other] } let(:expectation) do - strip_indent(<<-STR) + <<~STR @@ -1,8 +1,9 @@ foo bar @@ -135,7 +135,7 @@ RSpec.describe Mutant::Diff do let(:new) { %w[foo bar baz boz a b c] } let(:expectation) do - strip_indent(<<-STR) + <<~STR @@ -1,9 +1,8 @@ -other foo @@ -158,7 +158,7 @@ RSpec.describe Mutant::Diff do let(:new) { %w[other foo bar baz boz a b c] } let(:expectation) do - strip_indent(<<-STR) + <<~STR @@ -1,8 +1,9 @@ +other foo diff --git a/spec/unit/mutant/meta/example/verification_spec.rb b/spec/unit/mutant/meta/example/verification_spec.rb index 5470e922..99397bd7 100644 --- a/spec/unit/mutant/meta/example/verification_spec.rb +++ b/spec/unit/mutant/meta/example/verification_spec.rb @@ -63,7 +63,7 @@ RSpec.describe Mutant::Meta::Example::Verification do let(:expected_nodes) { [s(:false), s(:nil)] } specify do - should eql(strip_indent(<<-'REPORT')) + should eql(<<~'REPORT') --- file: foo.rb original_ast: s(:true) @@ -83,7 +83,7 @@ RSpec.describe Mutant::Meta::Example::Verification do let(:generated_nodes) { [s(:false), s(:nil)] } specify do - should eql(strip_indent(<<-'REPORT')) + should eql(<<~'REPORT') --- file: foo.rb original_ast: s(:true) @@ -104,7 +104,7 @@ RSpec.describe Mutant::Meta::Example::Verification do let(:generated_nodes) { [s(:true)] } specify do - should eql(strip_indent(<<-'REPORT')) + should eql(<<~'REPORT') --- file: foo.rb original_ast: s(:true) diff --git a/spec/unit/mutant/reporter/cli/printer/config_spec.rb b/spec/unit/mutant/reporter/cli/printer/config_spec.rb index 76b7340d..c7ffe231 100644 --- a/spec/unit/mutant/reporter/cli/printer/config_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/config_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do describe '.call' do context 'on default config' do - it_reports(<<-REPORT) + it_reports(<<~REPORT) Mutant configuration: Matcher: # Integration: Mutant::Integration::Null @@ -17,7 +17,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do end context 'with non default coverage expectation' do - it_reports(<<-REPORT) + it_reports(<<~REPORT) Mutant configuration: Matcher: # Integration: Mutant::Integration::Null diff --git a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb index 6cd0bd1a..f3d00f61 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do context 'without progress' do with(:subject_a_result) { { mutation_results: [] } } - it_reports <<-'STR' + it_reports <<~'STR' Mutant configuration: Matcher: # Integration: Mutant::Integration::Null @@ -29,7 +29,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do end context 'on full coverage' do - it_reports <<-'STR' + it_reports <<~'STR' Mutant configuration: Matcher: # Integration: Mutant::Integration::Null @@ -52,7 +52,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do context 'on partial coverage' do with(:mutation_a_test_result) { { passed: true } } - it_reports <<-'STR' + it_reports <<~'STR' Mutant configuration: Matcher: # Integration: Mutant::Integration::Null diff --git a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb index 2f951053..775c06e8 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do let(:reportable) { env_result } describe '.call' do - it_reports <<-'STR' + it_reports <<~'STR' subject-a - test-a evil:subject-a:d27d2 diff --git a/spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb b/spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb index a256bc67..b8f808b6 100644 --- a/spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do end context 'on non tty' do - it_reports(<<-'STR') + it_reports(<<~'STR') evil:subject-a:d27d2 @@ -1,2 +1,2 @@ -true @@ -44,7 +44,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do # Unparses exactly the same way as above node let(:mutation_a_node) { s(:zsuper) } - it_reports(<<-REPORT) + it_reports(<<~REPORT) evil:subject-a:a5bc7 --- Internal failure --- BUG: Mutation NOT resulted in exactly one diff hunk. Please report a reproduction! @@ -68,7 +68,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do Mutant::Mutation::Neutral.new(subject_a, s(:true)) end - it_reports(<<-REPORT) + it_reports(<<~REPORT) neutral:subject-a:d5318 --- Neutral failure --- Original code was inserted unmutated. And the test did NOT PASS. @@ -93,7 +93,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do Mutant::Mutation::Noop.new(subject_a, s(:true)) end - it_reports(<<-REPORT) + it_reports(<<~REPORT) noop:subject-a:d5318 ---- Noop failure ----- No code was inserted. And the test did NOT PASS. diff --git a/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb b/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb index 684117fd..90bb87cf 100644 --- a/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::StatusProgressive do context 'with empty scheduler' do with(:env_result) { { subject_results: [] } } - it_reports <<-REPORT + it_reports <<~REPORT (00/02) 100% - killtime: 0.00s runtime: 4.00s overhead: 4.00s REPORT end @@ -17,7 +17,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::StatusProgressive do context 'without progress' do with(:status) { { active_jobs: [].to_set } } - it_reports(<<-REPORT) + it_reports(<<~REPORT) (02/02) 100% - killtime: 2.00s runtime: 4.00s overhead: 2.00s REPORT end @@ -28,13 +28,13 @@ RSpec.describe Mutant::Reporter::CLI::Printer::StatusProgressive do context 'on failure' do with(:mutation_a_test_result) { { passed: true } } - it_reports(<<-REPORT) + it_reports(<<~REPORT) (01/02) 50% - killtime: 2.00s runtime: 4.00s overhead: 2.00s REPORT end context 'on success' do - it_reports(<<-REPORT) + it_reports(<<~REPORT) (02/02) 100% - killtime: 2.00s runtime: 4.00s overhead: 2.00s REPORT end diff --git a/spec/unit/mutant/reporter/cli/printer/status_spec.rb b/spec/unit/mutant/reporter/cli/printer/status_spec.rb index 8f503f4e..69a8fd39 100644 --- a/spec/unit/mutant/reporter/cli/printer/status_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/status_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do context 'with empty scheduler' do with(:env_result) { { subject_results: [] } } - it_reports <<-REPORT + it_reports <<~REPORT Mutant configuration: Matcher: # Integration: Mutant::Integration::Null @@ -33,7 +33,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do context 'without progress' do with(:status) { { active_jobs: [].to_set } } - it_reports(<<-REPORT) + it_reports(<<~REPORT) Mutant configuration: Matcher: # Integration: Mutant::Integration::Null @@ -60,7 +60,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do context 'on failure' do with(:mutation_a_test_result) { { passed: true } } - it_reports(<<-REPORT) + it_reports(<<~REPORT) Mutant configuration: Matcher: # Integration: Mutant::Integration::Null @@ -88,7 +88,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do end context 'on success' do - it_reports(<<-REPORT) + it_reports(<<~REPORT) Mutant configuration: Matcher: # Integration: Mutant::Integration::Null diff --git a/spec/unit/mutant/reporter/cli/printer/subject_progress_spec.rb b/spec/unit/mutant/reporter/cli/printer/subject_progress_spec.rb index a525879a..38946446 100644 --- a/spec/unit/mutant/reporter/cli/printer/subject_progress_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/subject_progress_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::SubjectProgress do describe '.call' do context 'on full coverage' do - it_reports <<-'STR' + it_reports <<~'STR' subject-a mutations: 2 .. (02/02) 100% - killtime: 2.00s runtime: 2.00s overhead: 0.00s @@ -16,7 +16,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::SubjectProgress do context 'on partial coverage' do with(:mutation_a_test_result) { { passed: true } } - it_reports <<-'STR' + it_reports <<~'STR' subject-a mutations: 2 F. (01/02) 50% - killtime: 2.00s runtime: 2.00s overhead: 0.00s @@ -26,7 +26,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::SubjectProgress do context 'without results' do with(:subject_a_result) { { mutation_results: [] } } - it_reports <<-'STR' + it_reports <<~'STR' subject-a mutations: 2 (00/02) 100% - killtime: 0.00s runtime: 0.00s overhead: 0.00s STR diff --git a/spec/unit/mutant/reporter/cli/printer/subject_result_spec.rb b/spec/unit/mutant/reporter/cli/printer/subject_result_spec.rb index ae5e3aa8..a6ce289f 100644 --- a/spec/unit/mutant/reporter/cli/printer/subject_result_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/subject_result_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::SubjectResult do describe '.call' do context 'on full coverage' do - it_reports <<-'STR' + it_reports <<~'STR' subject-a - test-a STR @@ -15,7 +15,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::SubjectResult do context 'on partial coverage' do with(:mutation_a_test_result) { { passed: true } } - it_reports <<-'STR' + it_reports <<~'STR' subject-a - test-a evil:subject-a:d27d2 @@ -29,7 +29,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::SubjectResult do context 'without results' do with(:subject_a_result) { { mutation_results: [] } } - it_reports <<-'STR' + it_reports <<~'STR' subject-a - test-a STR diff --git a/spec/unit/mutant/reporter/cli/printer/test_result_spec.rb b/spec/unit/mutant/reporter/cli/printer/test_result_spec.rb index b06a23e6..a0bbaa0e 100644 --- a/spec/unit/mutant/reporter/cli/printer/test_result_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/test_result_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::TestResult do let(:reportable) { mutation_a_test_result } describe '.call' do - it_reports <<-'STR' + it_reports <<~'STR' - 1 @ runtime: 1.0 - test-a Test Output: diff --git a/spec/unit/mutant/reporter/cli/printer_spec.rb b/spec/unit/mutant/reporter/cli/printer_spec.rb index 825e7c81..2232c7e6 100644 --- a/spec/unit/mutant/reporter/cli/printer_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer do allow(output).to receive(:tty?).and_return(tty?) subject output.rewind - expect(output.read).to eql(strip_indent(expectation)) + expect(output.read).to eql(expectation) end end diff --git a/spec/unit/mutant/reporter/cli_spec.rb b/spec/unit/mutant/reporter/cli_spec.rb index aae8e874..53c1153f 100644 --- a/spec/unit/mutant/reporter/cli_spec.rb +++ b/spec/unit/mutant/reporter/cli_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Mutant::Reporter::CLI do def self.it_reports(expected_content) it 'writes expected report to output' do expect(subject).to be(object) - expect(contents).to eql(strip_indent(expected_content)) + expect(contents).to eql(expected_content) end end @@ -119,7 +119,7 @@ RSpec.describe Mutant::Reporter::CLI do context 'on progressive format' do let(:format) { progressive_format } - it_reports(<<-REPORT) + it_reports(<<~REPORT) Mutant configuration: Matcher: # Integration: Mutant::Integration::Null @@ -137,7 +137,7 @@ RSpec.describe Mutant::Reporter::CLI do describe '#report' do subject { object.report(env_result) } - it_reports(<<-REPORT) + it_reports(<<~REPORT) Mutant configuration: Matcher: # Integration: Mutant::Integration::Null @@ -163,7 +163,7 @@ RSpec.describe Mutant::Reporter::CLI do context 'on framed format' do let(:format) { framed_format } - it_reports(<<-REPORT) + it_reports(<<~REPORT) [tput-restore]Mutant configuration: Matcher: # Integration: Mutant::Integration::Null