From b72c28e28b96a8ecce73e83ab0afb5f945338d68 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 15:26:50 +0200 Subject: [PATCH 01/26] Auto-update rubocop to 0.84.0 --- aruba.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aruba.gemspec b/aruba.gemspec index e34dbdb0e..60ae32ffd 100644 --- a/aruba.gemspec +++ b/aruba.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry-doc', '~> 1.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec', '~> 3.6' - spec.add_development_dependency 'rubocop', '~> 0.82.0' + spec.add_development_dependency 'rubocop', '~> 0.84.0' spec.add_development_dependency 'rubocop-performance', '~> 1.5' spec.add_development_dependency 'simplecov', '~> 0.18.0' spec.add_development_dependency 'yard-junk', '~> 0.0.7' From 5cebecde6ed4c6914af40c2dd92920d81407e03e Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 15:28:35 +0200 Subject: [PATCH 02/26] Enable new cops from RuboCop 0.83 and 0.84 --- .rubocop.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3cae66c73..bee7c5342 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,9 +26,13 @@ Style/FrozenStringLiteralComment: Layout/LineLength: Max: 94 -# Enable new cops from RuboCop 0.80, 0.81 and 0.82 +# Enable new cops from RuboCop 0.80, 0.81 and 0.84 +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: true Layout/SpaceAroundMethodCallOperator: Enabled: true +Lint/DeprecatedOpenSSLConstant: + Enabled: true Lint/RaiseException: Enabled: true Lint/StructNewOverride: @@ -41,6 +45,8 @@ Style/HashTransformKeys: Enabled: true Style/HashTransformValues: Enabled: true +Style/SlicingWithRange: + Enabled: true # We only permit it in this one area which is internal code testing. Never exposed to users Security/Eval: From 283e5d828e115045e1d2b896d8ac16c1c8c04e9c Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 15:30:06 +0200 Subject: [PATCH 03/26] Add rubocop-rspec --- .rubocop.yml | 1 + aruba.gemspec | 1 + 2 files changed, 2 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index bee7c5342..a3977a2af 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,6 @@ require: - rubocop-performance + - rubocop-rspec AllCops: Exclude: diff --git a/aruba.gemspec b/aruba.gemspec index 60ae32ffd..fe2c07cec 100644 --- a/aruba.gemspec +++ b/aruba.gemspec @@ -38,6 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rspec', '~> 3.6' spec.add_development_dependency 'rubocop', '~> 0.84.0' spec.add_development_dependency 'rubocop-performance', '~> 1.5' + spec.add_development_dependency 'rubocop-rspec', '~> 1.39' spec.add_development_dependency 'simplecov', '~> 0.18.0' spec.add_development_dependency 'yard-junk', '~> 0.0.7' From 7b7da74e0a10d7f175d67e7d0e81114ebc3ef605 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 15:35:14 +0200 Subject: [PATCH 04/26] Autocorrect rubocop-rspec offenses --- spec/aruba/api/commands_spec.rb | 5 +- spec/aruba/api/filesystem_spec.rb | 91 ++++++++++--------- spec/aruba/api/runtime_spec.rb | 3 +- spec/aruba/api_spec.rb | 12 +-- spec/aruba/in_config_wrapper_spec.rb | 2 +- spec/aruba/jruby_spec.rb | 2 +- spec/aruba/matchers/command_spec.rb | 31 ++++--- spec/aruba/matchers/directory_spec.rb | 6 +- spec/aruba/matchers/file_spec.rb | 12 +-- spec/aruba/matchers/path_spec.rb | 10 +- .../windows_environment_variables_spec.rb | 12 +-- .../platforms/unix_command_string_spec.rb | 3 + .../platforms/windows_command_string_spec.rb | 3 + spec/aruba/processes/basic_process_spec.rb | 22 ++--- spec/aruba/processes/spawn_process_spec.rb | 7 +- spec/aruba/runtime_spec.rb | 2 +- spec/event_bus/name_resolver_spec.rb | 11 ++- spec/event_bus_spec.rb | 24 ++--- spec/support/configs/rspec.rb | 2 +- spec/support/shared_contexts/aruba.rb | 2 +- spec/support/shared_examples/configuration.rb | 22 +++-- 21 files changed, 158 insertions(+), 126 deletions(-) diff --git a/spec/aruba/api/commands_spec.rb b/spec/aruba/api/commands_spec.rb index 544d10e62..a40adb6cb 100644 --- a/spec/aruba/api/commands_spec.rb +++ b/spec/aruba/api/commands_spec.rb @@ -7,8 +7,9 @@ describe '#run_command' do context 'when succesfully running a command' do - before(:each) { @aruba.run_command 'cat' } - after(:each) { @aruba.all_commands.each(&:stop) } + before { @aruba.run_command 'cat' } + + after { @aruba.all_commands.each(&:stop) } it 'respond to input' do @aruba.type 'Hello' diff --git a/spec/aruba/api/filesystem_spec.rb b/spec/aruba/api/filesystem_spec.rb index 17dbbd81f..56b431929 100644 --- a/spec/aruba/api/filesystem_spec.rb +++ b/spec/aruba/api/filesystem_spec.rb @@ -9,7 +9,7 @@ let(:path) { @file_path } context 'when file exists' do - before :each do + before do Aruba.platform.write_file(path, '') end @@ -20,7 +20,7 @@ let(:name) { 'test_dir' } let(:path) { File.join(@aruba.aruba.current_directory, name) } - before :each do + before do Aruba.platform.mkdir(path) end @@ -37,7 +37,7 @@ let(:path) { @file_path } context 'when file exists' do - before :each do + before do Aruba.platform.write_file(path, '') end @@ -48,7 +48,7 @@ let(:name) { 'test_dir' } let(:path) { File.join(@aruba.aruba.current_directory, name) } - before :each do + before do Aruba.platform.mkdir(path) end @@ -65,7 +65,7 @@ let(:path) { @file_path } context 'when file exists' do - before :each do + before do Aruba.platform.write_file(path, '') end @@ -76,7 +76,7 @@ let(:name) { 'test_dir' } let(:path) { File.join(@aruba.aruba.current_directory, name) } - before :each do + before do Aruba.platform.mkdir(path) end @@ -94,7 +94,7 @@ let(:size) { file_size(name) } context 'when file exists' do - before :each do + before do File.open(path, 'w') { |f| f.print 'a' } end @@ -103,6 +103,7 @@ context 'when file does not exist' do let(:name) { 'non_existing_file' } + it { expect { size }.to raise_error RSpec::Expectations::ExpectationNotMetError } end end @@ -112,17 +113,18 @@ let(:path) { @file_path } let(:options) { {} } - before :each do + before do @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) end context 'when touching a file that does not exist' do - before :each do + before do @aruba.touch(name, options) end context 'and should be created in an existing directory' do it { expect(File.size(path)).to eq 0 } + it_behaves_like 'an existing file' end @@ -154,6 +156,7 @@ let(:path) do %w(file1 file2 file3).map { |p| File.join(@aruba.aruba.current_directory, p) } end + it_behaves_like 'an existing file' end end @@ -209,7 +212,7 @@ let(:path) { @file_path } context 'when it exists' do - before :each do + before do Aruba.platform.write_file(path, '') end @@ -226,7 +229,7 @@ let(:path) { File.join(@aruba.aruba.current_directory, name) } context 'when it exists' do - before :each do + before do Aruba.platform.mkdir(path) end @@ -245,7 +248,7 @@ let(:path) { @file_path } context 'when it exists' do - before :each do + before do Aruba.platform.write_file(path, '') end @@ -262,7 +265,7 @@ let(:path) { File.join(@aruba.aruba.current_directory, name) } context 'when it exists' do - before :each do + before do Aruba.platform.mkdir(path) end @@ -281,7 +284,7 @@ let(:path) { @file_path } context 'when it exists' do - before :each do + before do Aruba.platform.write_file(path, '') end @@ -298,7 +301,7 @@ let(:path) { File.join(@aruba.aruba.current_directory, name) } context 'when it exists' do - before :each do + before do Aruba.platform.mkdir(path) end @@ -318,9 +321,9 @@ context 'when source is existing' do context 'when destination is non-existing' do context 'when source is file' do - before(:each) { create_test_files(source) } + before { create_test_files(source) } - before :each do + before do @aruba.copy source, destination end @@ -330,12 +333,14 @@ context 'when source is contains "~" in path' do let(:source) { '~/file.txt' } + it { expect(destination).to be_an_existing_file } end context 'when source is fixture' do let(:source) { '%/copy/file.txt' } let(:destination) { 'file.txt' } + it { expect(destination).to be_an_existing_file } end @@ -352,11 +357,11 @@ let(:source) { 'src.d' } let(:destination) { 'dst.d' } - before :each do + before do Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, source)) end - before :each do + before do @aruba.copy source, destination end @@ -375,18 +380,18 @@ context 'when destination is existing' do context 'when source is list of files' do - before(:each) { create_test_files(source) } + before { create_test_files(source) } context 'when destination is directory' do let(:source) { %w(file1.txt file2.txt file3.txt) } let(:destination) { 'file.d' } let(:destination_files) { source.map { |s| File.join(destination, s) } } - before :each do + before do Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, destination)) end - before :each do + before do @aruba.copy source, destination end @@ -398,7 +403,7 @@ let(:destination) { 'file.txt' } let(:error_message) { 'Multiples sources can only be copied to a directory' } - before(:each) { create_test_files(destination) } + before { create_test_files(destination) } it 'raises an appropriate error' do expect { @aruba.copy source, destination } @@ -410,7 +415,7 @@ let(:source) { 'file1.txt' } let(:destination) { 'file1.txt' } - before(:each) { create_test_files(source) } + before { create_test_files(source) } it 'raises an appropriate error' do src_path = File.expand_path(File.join(@aruba.aruba.current_directory, source)) @@ -443,7 +448,7 @@ end end - context '#write_file' do + describe '#write_file' do it 'writes file' do @aruba.write_file(@file_name, '') @@ -451,8 +456,8 @@ end end - context '#write_fixed_size_file' do - it 'should write a fixed sized file' do + describe '#write_fixed_size_file' do + it 'writes a fixed sized file' do @aruba.write_fixed_size_file(@file_name, @file_size) expect(File.exist?(@file_path)).to eq true expect(File.size(@file_path)).to eq @file_size @@ -479,15 +484,15 @@ def actual_permissions let(:file_path) { @file_path } let(:permissions) { '0644' } - before :each do + before do @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) end - before(:each) do + before do File.open(file_path, 'w') { |f| f << '' } end - before(:each) do + before do @aruba.chmod(permissions, file_name) end @@ -498,6 +503,7 @@ def actual_permissions context 'and permissions are given as octal number' do let(:permissions) { 0o644 } + it { expect(actual_permissions).to eq('0644') } end @@ -511,8 +517,8 @@ def actual_permissions end end - context '#with_file_content' do - before :each do + describe '#with_file_content' do + before do @aruba.write_file(@file_name, 'foo bar baz') end @@ -556,14 +562,14 @@ def actual_permissions end describe '#create_directory' do - before(:each) do + before do @directory_name = 'test_dir' @directory_path = File.join(@aruba.aruba.current_directory, @directory_name) end it 'creates a directory' do @aruba.create_directory @directory_name - expect(File.exist?(File.expand_path(@directory_path))).to be_truthy + expect(File).to exist(File.expand_path(@directory_path)) end end @@ -572,7 +578,7 @@ def actual_permissions let(:path) { File.join(@aruba.aruba.current_directory, name) } let(:content) { 'asdf' } - before :each do + before do @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) end @@ -582,7 +588,7 @@ def actual_permissions context 'when it exists' do context 'when file' do - before :each do + before do File.open(File.expand_path(path), 'w') { |f| f << content } end @@ -592,11 +598,13 @@ def actual_permissions context 'when binary file' do let(:content) { "\u0000" } + it { expect(@aruba.read(name)).to eq [content] } end context 'when is empty file' do let(:content) { '' } + it { expect(@aruba.read(name)).to eq [] } end @@ -626,7 +634,7 @@ def actual_permissions let(:content) { %w(subdir.1.d subdir.2.d) } let(:path) { File.join(@aruba.aruba.current_directory, name) } - before :each do + before do @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) end @@ -638,7 +646,7 @@ def actual_permissions context 'when file' do let(:name) { 'test.txt' } - before :each do + before do File.open(File.expand_path(path), 'w') { |f| f << content } end @@ -675,6 +683,7 @@ def actual_permissions context 'when has no subdirectories' do let(:content) { [] } + it { expect(@aruba.list(name)).to eq [] } end end @@ -686,7 +695,7 @@ def actual_permissions let(:path) { File.join(@aruba.aruba.current_directory, name) } let(:options) { {} } - before :each do + before do @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) end @@ -739,7 +748,7 @@ def actual_permissions Array(path).each { |it| Aruba.platform.mkdir it } end - before :each do + before do @aruba.remove(name, options) end @@ -764,7 +773,7 @@ def actual_permissions end context 'when it does not exist' do - before :each do + before do @aruba.remove(name, options) end diff --git a/spec/aruba/api/runtime_spec.rb b/spec/aruba/api/runtime_spec.rb index 0417f1f61..709c35566 100644 --- a/spec/aruba/api/runtime_spec.rb +++ b/spec/aruba/api/runtime_spec.rb @@ -11,7 +11,8 @@ context 'when changed earlier' do context 'values when init' do let(:value) { 20 } - before(:each) { aruba.config.io_wait_timeout = value } + + before { aruba.config.io_wait_timeout = value } it { expect(config.io_wait_timeout).to eq value } end diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index 002e730a4..b79bfc758 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -8,24 +8,24 @@ describe 'tags' do describe '@announce_stdout' do - after(:each) { @aruba.all_commands.each(&:stop) } + after { @aruba.all_commands.each(&:stop) } context 'enabled' do - before :each do + before do @aruba.aruba.announcer = instance_double 'Aruba::Platforms::Announcer' expect(@aruba.aruba.announcer) - .to receive(:announce).with(:stdout) { "hello world\n" } + .to receive(:announce).with(:stdout).and_return("hello world\n") allow(@aruba.aruba.announcer).to receive(:announce) end - it 'should announce to stdout exactly once' do + it 'announces to stdout exactly once' do @aruba.run_command_and_stop('echo "hello world"', fail_on_error: false) expect(@aruba.last_command_started.output).to include('hello world') end end context 'disabled' do - it 'should not announce to stdout' do + it 'does not announce to stdout' do result = capture(:stdout) do @aruba.run_command_and_stop('echo "hello world"', fail_on_error: false) end @@ -52,7 +52,7 @@ def root_directory end describe '#set_environment_variable' do - after(:each) do + after do @aruba.all_commands.each(&:stop) end diff --git a/spec/aruba/in_config_wrapper_spec.rb b/spec/aruba/in_config_wrapper_spec.rb index 9161b1a19..a592ba2cb 100644 --- a/spec/aruba/in_config_wrapper_spec.rb +++ b/spec/aruba/in_config_wrapper_spec.rb @@ -6,7 +6,7 @@ let(:config) { {} } context 'when option is defined' do - before :each do + before do config[:opt] = true end diff --git a/spec/aruba/jruby_spec.rb b/spec/aruba/jruby_spec.rb index dc31c5f42..62cfa73ac 100644 --- a/spec/aruba/jruby_spec.rb +++ b/spec/aruba/jruby_spec.rb @@ -53,7 +53,7 @@ end context 'when running under JRuby on Solaris' do - before :each do + before do stub_const 'RUBY_PLATFORM', 'java' stub_const 'RbConfig::CONFIG', rb_config diff --git a/spec/aruba/matchers/command_spec.rb b/spec/aruba/matchers/command_spec.rb index ed6d5b699..26c4740a0 100644 --- a/spec/aruba/matchers/command_spec.rb +++ b/spec/aruba/matchers/command_spec.rb @@ -14,7 +14,7 @@ def announcer(*args) describe '#to_have_exit_status' do let(:cmd) { 'true' } - before(:each) { run_command(cmd) } + before { run_command(cmd) } context 'when has exit 0' do it { expect(last_command_started).to have_exit_status 0 } @@ -22,6 +22,7 @@ def announcer(*args) context 'when has exit 0' do let(:cmd) { 'false' } + it { expect(last_command_started).not_to have_exit_status 0 } end end @@ -29,7 +30,7 @@ def announcer(*args) describe '#to_be_successfully_executed_' do let(:cmd) { 'true' } - before(:each) { run_command(cmd) } + before { run_command(cmd) } context 'when has exit 0' do it { expect(last_command_started).to be_successfully_executed } @@ -37,6 +38,7 @@ def announcer(*args) context 'when has exit 0' do let(:cmd) { 'false' } + it { expect(last_command_started).not_to be_successfully_executed } end end @@ -46,13 +48,14 @@ def announcer(*args) let(:output) { 'hello world' } context 'when have output hello world on stdout' do - before(:each) { run_command(cmd) } + before { run_command(cmd) } + it { expect(last_command_started).to have_output output } end context 'when multiple commands output hello world on stdout' do context 'and all comands must have the output' do - before(:each) do + before do run_command(cmd) run_command(cmd) end @@ -61,7 +64,7 @@ def announcer(*args) end context 'and any comand can have the output' do - before(:each) do + before do run_command(cmd) run_command('echo hello universe') end @@ -73,13 +76,13 @@ def announcer(*args) context 'when have output hello world on stderr' do let(:cmd) { "ruby -e 'warn \"#{output}\"'" } - before(:each) { run_command(cmd) } + before { run_command(cmd) } it { expect(last_command_started).to have_output output } end context 'when not has output' do - before(:each) { run_command(cmd) } + before { run_command(cmd) } it { expect(last_command_started).not_to have_output 'hello universe' } end @@ -90,20 +93,21 @@ def announcer(*args) let(:output) { 'hello world' } context 'when have output hello world on stdout' do - before(:each) { run_command(cmd) } + before { run_command(cmd) } + it { expect(last_command_started).to have_output_on_stdout output } end context 'when have output hello world on stderr' do let(:cmd) { "ruby -e 'warn \"#{output}\"'" } - before(:each) { run_command(cmd) } + before { run_command(cmd) } it { expect(last_command_started).not_to have_output_on_stdout output } end context 'when not has output' do - before(:each) { run_command(cmd) } + before { run_command(cmd) } it { expect(last_command_started).not_to have_output_on_stdout 'hello universe' } end @@ -114,20 +118,21 @@ def announcer(*args) let(:output) { 'hello world' } context 'when have output hello world on stdout' do - before(:each) { run_command(cmd) } + before { run_command(cmd) } + it { expect(last_command_started).not_to have_output_on_stderr output } end context 'when have output hello world on stderr' do let(:cmd) { "ruby -e 'warn \"#{output}\"'" } - before(:each) { run_command(cmd) } + before { run_command(cmd) } it { expect(last_command_started).to have_output_on_stderr output } end context 'when not has output' do - before(:each) { run_command(cmd) } + before { run_command(cmd) } it { expect(last_command_started).not_to have_output_on_stderr 'hello universe' } end diff --git a/spec/aruba/matchers/directory_spec.rb b/spec/aruba/matchers/directory_spec.rb index 04adb3174..a4ec9e095 100644 --- a/spec/aruba/matchers/directory_spec.rb +++ b/spec/aruba/matchers/directory_spec.rb @@ -11,7 +11,7 @@ let(:path) { @aruba.expand_path(name) } context 'when directory exists' do - before :each do + before do FileUtils.mkdir_p path end @@ -29,11 +29,11 @@ let(:content) { %w(subdir.1.d subdir.2.d) } context 'when directory exists' do - before :each do + before do FileUtils.mkdir_p path end - before :each do + before do Array(content).each { |p| Dir.mkdir File.join(path, p) } end diff --git a/spec/aruba/matchers/file_spec.rb b/spec/aruba/matchers/file_spec.rb index eab25e52e..e914ba1eb 100644 --- a/spec/aruba/matchers/file_spec.rb +++ b/spec/aruba/matchers/file_spec.rb @@ -9,7 +9,7 @@ let(:name) { @file_name } context 'when file exists' do - before(:each) { create_test_files(name) } + before { create_test_files(name) } it { expect(name).to be_an_existing_file } end @@ -21,7 +21,7 @@ context 'when contains ~' do let(:name) { File.join('~', random_string) } - before(:each) do + before do @aruba.with_environment 'HOME' => expand_path('.') do create_test_files(name) end @@ -37,7 +37,7 @@ describe 'to_have_file_content' do context 'when file exists' do - before :each do + before do Aruba.platform.write_file(@file_path, 'aba') end @@ -113,7 +113,7 @@ def fail_with(message) let(:reference_file) { 'fixture' } - before :each do + before do @aruba.write_file(@file_name, 'foo bar baz') @aruba.write_file(reference_file, reference_file_content) end @@ -155,7 +155,7 @@ def fail_with(message) let(:file_with_same_content) { 'file_a.txt' } let(:file_with_different_content) { 'file_b.txt' } - before :each do + before do @aruba.write_file(file_with_same_content, reference_file_content) @aruba.write_file(reference_file, reference_file_content) @aruba.write_file(file_with_different_content, 'Some different content here...') @@ -192,7 +192,7 @@ def fail_with(message) describe 'to_have_file_size' do context 'when file exists' do - before :each do + before do Aruba.platform.write_file(@file_path, '') end diff --git a/spec/aruba/matchers/path_spec.rb b/spec/aruba/matchers/path_spec.rb index 367c49418..9b150da7d 100644 --- a/spec/aruba/matchers/path_spec.rb +++ b/spec/aruba/matchers/path_spec.rb @@ -26,7 +26,7 @@ def expand_path(*args) describe 'to_be_an_existing_path' do context 'when file' do context 'exists' do - before :each do + before do Aruba.platform.write_file(@file_path, '') end @@ -43,7 +43,7 @@ def expand_path(*args) let(:path) { @aruba.expand_path(name) } context 'exists' do - before :each do + before do FileUtils.mkdir_p path end @@ -62,15 +62,15 @@ def expand_path(*args) let(:permissions) { '0644' } - before :each do + before do @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) end - before(:each) do + before do File.open(file_path, 'w') { |f| f << '' } end - before(:each) do + before do @aruba.chmod(permissions, file_name) end diff --git a/spec/aruba/platform/windows_environment_variables_spec.rb b/spec/aruba/platform/windows_environment_variables_spec.rb index 82ab1a526..514b9cb4a 100644 --- a/spec/aruba/platform/windows_environment_variables_spec.rb +++ b/spec/aruba/platform/windows_environment_variables_spec.rb @@ -298,7 +298,7 @@ class KeyError < StandardError; end unless defined? KeyError context 'when environment contains uppercase variable' do let(:old_environment) { { 'MY_VARIABLE' => '1' } } - before(:each) { environment.append(variable, value) } + before { environment.append(variable, value) } context 'when uppercase key is given' do let(:variable) { 'MY_VARIABLE' } @@ -328,7 +328,7 @@ class KeyError < StandardError; end unless defined? KeyError context 'when environment contains lowercase variable' do let(:old_environment) { { 'my_variable' => '1' } } - before(:each) { environment.append(variable, value) } + before { environment.append(variable, value) } context 'when uppercase key is given' do let(:variable) { 'MY_VARIABLE' } @@ -358,7 +358,7 @@ class KeyError < StandardError; end unless defined? KeyError context 'when environment contains mixed case variable' do let(:old_environment) { { 'MY_variable' => '1' } } - before(:each) { environment.append(variable, value) } + before { environment.append(variable, value) } context 'when uppercase key is given' do let(:variable) { 'MY_VARIABLE' } @@ -392,7 +392,7 @@ class KeyError < StandardError; end unless defined? KeyError context 'when environment contains uppercase variable' do let(:old_environment) { { 'MY_VARIABLE' => '1' } } - before(:each) { environment.prepend(variable, value) } + before { environment.prepend(variable, value) } context 'when uppercase key is given' do let(:variable) { 'MY_VARIABLE' } @@ -422,7 +422,7 @@ class KeyError < StandardError; end unless defined? KeyError context 'when environment contains lowercase variable' do let(:old_environment) { { 'my_variable' => '1' } } - before(:each) { environment.prepend(variable, value) } + before { environment.prepend(variable, value) } context 'when uppercase key is given' do let(:variable) { 'MY_VARIABLE' } @@ -452,7 +452,7 @@ class KeyError < StandardError; end unless defined? KeyError context 'when environment contains mixed case variable' do let(:old_environment) { { 'MY_variable' => '1' } } - before(:each) { environment.prepend(variable, value) } + before { environment.prepend(variable, value) } context 'when uppercase key is given' do let(:variable) { 'MY_VARIABLE' } diff --git a/spec/aruba/platforms/unix_command_string_spec.rb b/spec/aruba/platforms/unix_command_string_spec.rb index 98a50df27..b790d0d55 100644 --- a/spec/aruba/platforms/unix_command_string_spec.rb +++ b/spec/aruba/platforms/unix_command_string_spec.rb @@ -7,17 +7,20 @@ describe '#to_a' do context 'with a command with a path' do let(:base_command) { '/foo/bar' } + it { expect(command_string.to_a).to eq [base_command] } end context 'with a command with a path containing spaces' do let(:base_command) { '/foo bar/baz' } + it { expect(command_string.to_a).to eq [base_command] } end context 'with a command and arguments' do let(:base_command) { '/foo/bar' } let(:arguments) { ['-w', 'baz quux'] } + it { expect(command_string.to_a).to eq [base_command, *arguments] } end end diff --git a/spec/aruba/platforms/windows_command_string_spec.rb b/spec/aruba/platforms/windows_command_string_spec.rb index 92ee71266..9bf75db08 100644 --- a/spec/aruba/platforms/windows_command_string_spec.rb +++ b/spec/aruba/platforms/windows_command_string_spec.rb @@ -12,17 +12,20 @@ describe '#to_a' do context 'with a command with a path' do let(:base_command) { 'C:\Foo\Bar' } + it { expect(command_string.to_a).to eq [cmd_path, '/c', base_command] } end context 'with a command with a path containing spaces' do let(:base_command) { 'C:\Foo Bar\Baz' } + it { expect(command_string.to_a).to eq [cmd_path, '/c', 'C:\Foo""" """Bar\Baz'] } end context 'with a command and arguments' do let(:base_command) { 'C:\Foo\Bar' } let(:arguments) { ['-w', 'baz quux'] } + it { expect(command_string.to_a) .to eq [cmd_path, '/c', "#{base_command} -w \"baz quux\""] diff --git a/spec/aruba/processes/basic_process_spec.rb b/spec/aruba/processes/basic_process_spec.rb index a73ea86e3..45d658130 100644 --- a/spec/aruba/processes/basic_process_spec.rb +++ b/spec/aruba/processes/basic_process_spec.rb @@ -1,13 +1,6 @@ require 'spec_helper' RSpec.describe Aruba::Processes::BasicProcess do - let(:cmd) { 'foobar' } - let(:exit_timeout) { 0 } - let(:io_wait_timeout) { 0 } - let(:working_directory) { Dir.pwd } - let(:stdout) { 'foo output' } - let(:stderr) { 'foo error output' } - subject do Class.new(described_class) do def initialize(*args) @@ -26,8 +19,15 @@ def stderr(*_args) end.new(stdout, stderr, cmd, exit_timeout, io_wait_timeout, working_directory) end + let(:cmd) { 'foobar' } + let(:exit_timeout) { 0 } + let(:io_wait_timeout) { 0 } + let(:working_directory) { Dir.pwd } + let(:stdout) { 'foo output' } + let(:stderr) { 'foo error output' } + describe '#inspect' do - it 'it shows useful info' do + it 'shows useful info' do expected = /commandline="foobar": stdout="foo output" stderr="foo error output"/ expect(subject.inspect).to match(expected) end @@ -35,7 +35,7 @@ def stderr(*_args) context 'with no stdout' do let(:stdout) { nil } - it 'it shows useful info' do + it 'shows useful info' do expected = /commandline="foobar": stdout=nil stderr="foo error output"/ expect(subject.inspect).to match(expected) end @@ -44,7 +44,7 @@ def stderr(*_args) context 'with no stderr' do let(:stderr) { nil } - it 'it shows useful info' do + it 'shows useful info' do expected = /commandline="foobar": stdout="foo output" stderr=nil/ expect(subject.inspect).to match(expected) end @@ -54,7 +54,7 @@ def stderr(*_args) let(:stderr) { nil } let(:stdout) { nil } - it 'it shows useful info' do + it 'shows useful info' do expected = /commandline="foobar": stdout=nil stderr=nil/ expect(subject.inspect).to match(expected) end diff --git a/spec/aruba/processes/spawn_process_spec.rb b/spec/aruba/processes/spawn_process_spec.rb index 9b2df4a89..b0e704d26 100644 --- a/spec/aruba/processes/spawn_process_spec.rb +++ b/spec/aruba/processes/spawn_process_spec.rb @@ -11,8 +11,9 @@ let(:working_directory) { Dir.getwd } describe '#stdout' do - before(:each) { process.start } - before(:each) { process.stop } + before { process.start } + + before { process.stop } context 'when invoked once' do it { expect(process.stdout.chomp).to eq 'yo' } @@ -42,7 +43,7 @@ end describe '#stop' do - before(:each) { process.start } + before { process.start } context 'when stopped successfully' do it { expect { process.stop }.not_to raise_error } diff --git a/spec/aruba/runtime_spec.rb b/spec/aruba/runtime_spec.rb index 56fde6556..6d664a291 100644 --- a/spec/aruba/runtime_spec.rb +++ b/spec/aruba/runtime_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Aruba::Runtime do describe '#fixtures_directory' do context 'when no fixtures directories exist' do - it 'should raise exception' do + it 'raises exception' do expect { api.fixtures_directory }.to raise_error end end diff --git a/spec/event_bus/name_resolver_spec.rb b/spec/event_bus/name_resolver_spec.rb index cf2e53828..f65b12c7b 100644 --- a/spec/event_bus/name_resolver_spec.rb +++ b/spec/event_bus/name_resolver_spec.rb @@ -2,10 +2,11 @@ describe Aruba::EventBus::NameResolver do subject(:resolver) { described_class.new(default_name_space) } + let(:default_name_space) { 'Events' } let(:resolved_name) { resolver.transform(original_name) } - before :each do + before do stub_const('Events::MyEvent', Class.new) stub_const('Events::MyEvent', Class.new) end @@ -14,11 +15,13 @@ context 'when name is string' do context 'when simple' do let(:original_name) { 'Events::MyEvent' } + it { expect(resolved_name).to eq Events::MyEvent } end context 'when prefixed' do let(:original_name) { '::Events::MyEvent' } + it { expect(resolved_name).to eq Events::MyEvent } end end @@ -26,22 +29,25 @@ context 'when name is class' do context 'when simple' do let(:original_name) { Events::MyEvent } + it { expect(resolved_name).to eq Events::MyEvent } end context 'when prefixed' do let(:original_name) { ::Events::MyEvent } + it { expect(resolved_name).to eq Events::MyEvent } end end context 'when name is symbol' do let(:original_name) { :my_event } + it { expect(resolved_name).to eq Events::MyEvent } end context 'when namespace ...' do - before :each do + before do stub_const('MyLib::Events::MyEvent', Class.new) end @@ -62,6 +68,7 @@ context 'when invalid' do let(:original_name) { 1 } + it { expect { resolved_name } .to raise_error Aruba::EventNameResolveError, /Transforming "1"/ diff --git a/spec/event_bus_spec.rb b/spec/event_bus_spec.rb index e3869ebb5..5e4bfdfa7 100644 --- a/spec/event_bus_spec.rb +++ b/spec/event_bus_spec.rb @@ -26,13 +26,13 @@ class MyMalformedHandler; end let!(:another_event_instance) { Events::AnotherTestEvent.new } describe '#notify' do - before(:each) do + before do allow(name_resolver) .to receive(:transform).with(event_name).and_return(event_klass) end context 'when subscribed to the event' do - before :each do + before do bus.register(event_klass) do |event| @received_payload = event end @@ -46,7 +46,7 @@ class MyMalformedHandler; end end context 'when not subscriber to event' do - before :each do + before do @received_payload = false bus.register(event_klass) { @received_payload = true } bus.notify another_event_instance @@ -59,7 +59,7 @@ class MyMalformedHandler; end let!(:event_name) { :test_event } let(:received_payload) { [] } - before :each do + before do bus.register(event_name, proc {}) end @@ -68,7 +68,7 @@ class MyMalformedHandler; end end describe '#register' do - before(:each) do + before do allow(name_resolver) .to receive(:transform).with(event_name).and_return(event_klass) end @@ -77,7 +77,7 @@ class MyMalformedHandler; end context 'when multiple instances are given' do let(:received_events) { [] } - before :each do + before do bus.register(Events::TestEvent) do |event| received_events << event end @@ -96,7 +96,7 @@ class MyMalformedHandler; end let!(:event_name) { event_klass.to_s } let(:received_payload) { [] } - before :each do + before do bus.register(event_klass.to_s) do |event| received_payload << event end @@ -111,7 +111,7 @@ class MyMalformedHandler; end let!(:event_name) { :test_event } let(:received_payload) { [] } - before :each do + before do bus.register(event_name) do |event| received_payload << event end @@ -125,12 +125,12 @@ class MyMalformedHandler; end context 'when valid custom handler' do context 'when single event class' do - before(:each) do + before do allow(name_resolver) .to receive(:transform).with(event_name).and_return(event_klass) end - before :each do + before do bus.register(event_klass, MyHandler.new) end @@ -138,14 +138,14 @@ class MyMalformedHandler; end end context 'when list of event classes' do - before(:each) do + before do allow(name_resolver) .to receive(:transform).with(event_name).and_return(event_klass) allow(name_resolver) .to receive(:transform).with(another_event_name).and_return(another_event_klass) end - before :each do + before do bus.register([event_klass, another_event_klass], MyHandler.new) end diff --git a/spec/support/configs/rspec.rb b/spec/support/configs/rspec.rb index 64d1cda58..a4316ce96 100644 --- a/spec/support/configs/rspec.rb +++ b/spec/support/configs/rspec.rb @@ -11,5 +11,5 @@ end config.include Aruba::Api - config.before(:each) { setup_aruba } + config.before { setup_aruba } end diff --git a/spec/support/shared_contexts/aruba.rb b/spec/support/shared_contexts/aruba.rb index 374b27ebd..c3a48d292 100644 --- a/spec/support/shared_contexts/aruba.rb +++ b/spec/support/shared_contexts/aruba.rb @@ -17,7 +17,7 @@ def create_test_files(files, data = 'a') end end - before(:each) do + before do klass = Class.new do include Aruba::Api diff --git a/spec/support/shared_examples/configuration.rb b/spec/support/shared_examples/configuration.rb index f44a93240..24983dea9 100644 --- a/spec/support/shared_examples/configuration.rb +++ b/spec/support/shared_examples/configuration.rb @@ -9,11 +9,11 @@ it { expect(config).not_to be_nil } describe '.option_reader' do - let(:config_klass) { Class.new(described_class) } - subject(:config) { config_klass.new } - before :each do + let(:config_klass) { Class.new(described_class) } + + before do config_klass.option_reader :new_opt, contract: { Contracts::Num => Contracts::Num }, default: 1 end @@ -27,7 +27,7 @@ end context 'when block is defined' do - before :each do + before do config_klass.option_reader( :new_opt2, contract: { Contracts::Num => Contracts::Num } @@ -51,11 +51,11 @@ end describe '.option_accessor' do - let(:config_klass) { Class.new(described_class) } - subject(:config) { config_klass.new } - before :each do + let(:config_klass) { Class.new(described_class) } + + before do config_klass.option_accessor :new_opt, contract: { Contracts::Num => Contracts::Num }, default: 1 end @@ -65,13 +65,13 @@ end context 'when is modified' do - before(:each) { config.new_opt = 2 } + before { config.new_opt = 2 } it { expect(config.new_opt).to eq 2 } end context 'when block is defined' do - before :each do + before do config_klass.option_accessor( :new_opt2, contract: { Contracts::Num => Contracts::Num } ) do |c| @@ -104,6 +104,7 @@ context 'when invalid_option' do let(:name) { :blub } + it { expect(name).not_to be_valid_option } end end @@ -113,7 +114,8 @@ let(:value) { true } context 'when valid option' do - before(:each) { config.set_if_option(name, value) } + before { config.set_if_option(name, value) } + it { expect(name).to have_option_value true } end From 4fd1c648fff1fffce41d825bf9eb97309b23a5fe Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 15:37:56 +0200 Subject: [PATCH 05/26] Regenerate RuboCop TODO file --- .rubocop_todo.yml | 171 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 163 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2dba218a8..10a0c9582 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-04-11 14:49:42 +0200 using RuboCop version 0.79.0. +# on 2020-05-31 15:37:19 +0200 using RuboCop version 0.84.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -12,6 +12,7 @@ Lint/AmbiguousBlockAssociation: - 'lib/aruba/platforms/announcer.rb' # Offense count: 12 +# Cop supports --auto-correct. Lint/AmbiguousRegexpLiteral: Exclude: - 'lib/aruba/cucumber/testing_frameworks.rb' @@ -24,10 +25,11 @@ Lint/Void: - 'lib/aruba/platforms/unix_environment_variables.rb' # Offense count: 27 +# Configuration parameters: IgnoredMethods. Metrics/AbcSize: Max: 116 -# Offense count: 75 +# Offense count: 72 # Configuration parameters: CountComments, ExcludedMethods. # ExcludedMethods: refine Metrics/BlockLength: @@ -39,6 +41,7 @@ Metrics/ClassLength: Max: 158 # Offense count: 5 +# Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 12 @@ -58,6 +61,7 @@ Metrics/ParameterLists: Max: 8 # Offense count: 5 +# Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: Max: 13 @@ -80,14 +84,13 @@ Naming/MemoizedInstanceVariableName: Exclude: - 'lib/aruba/api/core.rb' -# Offense count: 16 +# Offense count: 14 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: io, id, to, by, on, in, at, ip, db, os +# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp Naming/MethodParameterName: Exclude: - 'lib/aruba/aruba_path.rb' - 'lib/aruba/config_wrapper.rb' - - 'lib/aruba/matchers/base/object_formatter.rb' - 'lib/aruba/platforms/announcer.rb' - 'lib/aruba/platforms/aruba_logger.rb' - 'lib/aruba/platforms/unix_platform.rb' @@ -98,21 +101,173 @@ Performance/Caller: Exclude: - 'lib/aruba/platforms/unix_platform.rb' +# Offense count: 51 +# Configuration parameters: Prefixes. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/aruba/api/filesystem_spec.rb' + - 'spec/aruba/api/runtime_spec.rb' + - 'spec/aruba/api_spec.rb' + - 'spec/aruba/matchers/command_spec.rb' + - 'spec/aruba/matchers/file_spec.rb' + - 'spec/aruba/matchers/path_spec.rb' + - 'spec/aruba/platform/windows_environment_variables_spec.rb' + - 'spec/support/shared_contexts/aruba.rb' + +# Offense count: 10 +RSpec/DescribeClass: + Exclude: + - 'spec/aruba/api/runtime_spec.rb' + - 'spec/aruba/jruby_spec.rb' + - 'spec/aruba/matchers/collection_spec.rb' + - 'spec/aruba/matchers/command/have_output_size_spec.rb' + - 'spec/aruba/matchers/command_spec.rb' + - 'spec/aruba/matchers/directory_spec.rb' + - 'spec/aruba/matchers/file_spec.rb' + - 'spec/aruba/matchers/path_spec.rb' + - 'spec/aruba/platform/simple_table_spec.rb' + - 'spec/aruba/rspec_spec.rb' + +# Offense count: 1 +# Configuration parameters: CustomIncludeMethods. +RSpec/EmptyExampleGroup: + Exclude: + - 'spec/aruba/api_spec.rb' + +# Offense count: 19 +# Configuration parameters: Max. +RSpec/ExampleLength: + Exclude: + - 'spec/aruba/api/core_spec.rb' + - 'spec/aruba/api/filesystem_spec.rb' + - 'spec/aruba/aruba_path_spec.rb' + - 'spec/aruba/matchers/collection_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +RSpec/ExpectActual: + Exclude: + - 'spec/routing/**/*' + - 'spec/aruba/matchers/collection_spec.rb' + +# Offense count: 1 +RSpec/ExpectInHook: + Exclude: + - 'spec/aruba/api_spec.rb' + +# Offense count: 4 +# Configuration parameters: CustomTransform, IgnoreMethods. +RSpec/FilePath: + Exclude: + - 'spec/aruba/platform/windows_environment_variables_spec.rb' + - 'spec/aruba/platforms/command_monitor_spec.rb' + - 'spec/event_bus/name_resolver_spec.rb' + - 'spec/event_bus_spec.rb' + +# Offense count: 300 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - 'spec/aruba/api/bundler_spec.rb' + - 'spec/aruba/api/commands_spec.rb' + - 'spec/aruba/api/core_spec.rb' + - 'spec/aruba/api/filesystem_spec.rb' + - 'spec/aruba/api_spec.rb' + - 'spec/aruba/matchers/command/have_output_size_spec.rb' + - 'spec/aruba/matchers/command_spec.rb' + - 'spec/aruba/matchers/directory_spec.rb' + - 'spec/aruba/matchers/file_spec.rb' + - 'spec/aruba/matchers/path_spec.rb' + - 'spec/aruba/processes/in_process_spec.rb' + - 'spec/event_bus_spec.rb' + - 'spec/support/shared_contexts/aruba.rb' + +# Offense count: 7 +RSpec/LeakyConstantDeclaration: + Exclude: + - 'spec/aruba/platform/windows_environment_variables_spec.rb' + - 'spec/aruba/processes/in_process_spec.rb' + +# Offense count: 5 +RSpec/LetSetup: + Exclude: + - 'spec/event_bus/name_resolver_spec.rb' + - 'spec/event_bus_spec.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: have_received, receive +RSpec/MessageSpies: + Exclude: + - 'spec/aruba/api_spec.rb' + +# Offense count: 32 +RSpec/MultipleExpectations: + Max: 5 + +# Offense count: 10 +# Configuration parameters: IgnoreSharedExamples. +RSpec/NamedSubject: + Exclude: + - 'spec/aruba/hooks_spec.rb' + - 'spec/aruba/platforms/command_monitor_spec.rb' + - 'spec/aruba/processes/basic_process_spec.rb' + +# Offense count: 187 +RSpec/NestedGroups: + Max: 6 + +# Offense count: 2 +RSpec/RepeatedDescription: + Exclude: + - 'spec/aruba/matchers/file_spec.rb' + +# Offense count: 4 +RSpec/RepeatedExampleGroupDescription: + Exclude: + - 'spec/aruba/matchers/command_spec.rb' + +# Offense count: 22 +RSpec/ScatteredSetup: + Exclude: + - 'spec/aruba/api/filesystem_spec.rb' + - 'spec/aruba/matchers/directory_spec.rb' + - 'spec/aruba/matchers/path_spec.rb' + - 'spec/aruba/processes/spawn_process_spec.rb' + - 'spec/event_bus_spec.rb' + +# Offense count: 1 +RSpec/UnspecifiedException: + Exclude: + - 'spec/aruba/runtime_spec.rb' + +# Offense count: 1 +# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. +RSpec/VerifiedDoubles: + Exclude: + - 'spec/aruba/jruby_spec.rb' + +# Offense count: 2 +RSpec/VoidExpect: + Exclude: + - 'spec/aruba/matchers/file_spec.rb' + # Offense count: 2 Security/Open: Exclude: - 'lib/aruba/processes/spawn_process.rb' -# Offense count: 3 -# Configuration parameters: EnforcedStyle. +# Offense count: 2 +# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols. # SupportedStyles: inline, group Style/AccessModifierDeclarations: Exclude: - - 'lib/aruba/in_config_wrapper.rb' - 'lib/aruba/matchers/base/base_matcher.rb' - 'lib/aruba/matchers/collection/all.rb' # Offense count: 3 +# Configuration parameters: AllowOnConstant. Style/CaseEquality: Exclude: - 'lib/aruba/matchers/base/object_formatter.rb' From bc61e362ac2e6004f2bdfbfd963f20cf4cd6db3d Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 15:48:03 +0200 Subject: [PATCH 06/26] Autocorrect Lint/AmbiguousRegexpLiteral --- .rubocop_todo.yml | 6 ------ lib/aruba/cucumber/testing_frameworks.rb | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 10a0c9582..44f797b59 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -11,12 +11,6 @@ Lint/AmbiguousBlockAssociation: Exclude: - 'lib/aruba/platforms/announcer.rb' -# Offense count: 12 -# Cop supports --auto-correct. -Lint/AmbiguousRegexpLiteral: - Exclude: - - 'lib/aruba/cucumber/testing_frameworks.rb' - # Offense count: 2 # Configuration parameters: CheckForMethodsWithNoSideEffects. Lint/Void: diff --git a/lib/aruba/cucumber/testing_frameworks.rb b/lib/aruba/cucumber/testing_frameworks.rb index 5ab7cf1f4..9b5e529c1 100644 --- a/lib/aruba/cucumber/testing_frameworks.rb +++ b/lib/aruba/cucumber/testing_frameworks.rb @@ -1,18 +1,18 @@ # Cucumber -Then /^the feature(?:s)? should not(?: all)? pass$/ do +Then(/^the feature(?:s)? should not(?: all)? pass$/) do step 'the output should contain " failed)"' step 'the exit status should be 1' end # Cucumber -Then /^the feature(?:s)? should(?: all)? pass$/ do +Then(/^the feature(?:s)? should(?: all)? pass$/) do step 'the output should not contain " failed)"' step 'the output should not contain " undefined)"' step 'the exit status should be 0' end # Cucumber -Then /^the feature(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, string| +Then(/^the feature(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string| step 'the output should contain " failed)"' step 'the exit status should be 1' @@ -24,7 +24,7 @@ end # Cucumber -Then /^the feature(?:s)? should(?: all)? pass with( regex)?:$/ do |regex, string| +Then(/^the feature(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string| step 'the output should not contain " failed)"' step 'the output should not contain " undefined)"' step 'the exit status should be 0' @@ -37,7 +37,7 @@ end # RSpec -Then /^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/ do |count_failures| +Then(/^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) do |count_failures| if count_failures.nil? step 'the output should not contain "0 failures"' else @@ -48,13 +48,13 @@ end # RSpec -Then /^the spec(?:s)? should all pass$/ do +Then(/^the spec(?:s)? should all pass$/) do step 'the output should contain "0 failures"' step 'the exit status should be 0' end # RSpec -Then /^the spec(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, string| +Then(/^the spec(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string| step 'the output should not contain "0 failures"' step 'the exit status should be 1' @@ -66,7 +66,7 @@ end # RSpec -Then /^the spec(?:s)? should(?: all)? pass with( regex)?:$/ do |regex, string| +Then(/^the spec(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string| step 'the output should contain "0 failures"' step 'the exit status should be 0' @@ -78,7 +78,7 @@ end # Minitest -Then /^the tests(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/ \ +Then(/^the tests(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \ do |count_failures| if count_failures.nil? step 'the output should not contain "0 errors"' @@ -90,13 +90,13 @@ end # Minitest -Then /^the tests(?:s)? should all pass$/ do +Then(/^the tests(?:s)? should all pass$/) do step 'the output should contain "0 errors"' step 'the exit status should be 0' end # Minitest -Then /^the test(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, string| +Then(/^the test(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string| step 'the output should contain "0 errors"' step 'the exit status should be 1' @@ -108,7 +108,7 @@ end # Minitest -Then /^the test(?:s)? should(?: all)? pass with( regex)?:$/ do |regex, string| +Then(/^the test(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string| step 'the output should not contain "0 errors"' step 'the exit status should be 0' From d2dd134f509fe720d9ae0a8a17b26b489cfa7830 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 15:51:57 +0200 Subject: [PATCH 07/26] Correct RSpec/ExpectActual offense --- .rubocop_todo.yml | 7 ------- spec/aruba/matchers/collection_spec.rb | 9 ++++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 44f797b59..4f5cce859 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -138,13 +138,6 @@ RSpec/ExampleLength: - 'spec/aruba/aruba_path_spec.rb' - 'spec/aruba/matchers/collection_spec.rb' -# Offense count: 3 -# Cop supports --auto-correct. -RSpec/ExpectActual: - Exclude: - - 'spec/routing/**/*' - - 'spec/aruba/matchers/collection_spec.rb' - # Offense count: 1 RSpec/ExpectInHook: Exclude: diff --git a/spec/aruba/matchers/collection_spec.rb b/spec/aruba/matchers/collection_spec.rb index fdb1b7b07..dbde84e5f 100644 --- a/spec/aruba/matchers/collection_spec.rb +++ b/spec/aruba/matchers/collection_spec.rb @@ -16,7 +16,8 @@ context 'when failing' do it 'emits failure messages for all candidate objects' do - expect { expect([14, 'a']).to include_an_object(be_odd) } + no_oddity = [14, 'a'] + expect { expect(no_oddity).to include_an_object(be_odd) } .to fail_with <<-MESSAGE.strip_heredoc.strip expected [14, "a"] to include an object be odd @@ -29,12 +30,14 @@ end it 'emits plain failure message when negated' do - expect { expect([14, 'a']).not_to include_an_object(be_even) } + contains_evens = [14, 'a'] + expect { expect(contains_evens).not_to include_an_object(be_even) } .to fail_with 'expected [14, "a"] not to include an object be even' end it 'skips boiler plate if only one candidate object is given' do - expect { expect([14]).to include_an_object(be_odd) } + only_one = [14] + expect { expect(only_one).to include_an_object(be_odd) } .to fail_with 'expected `14.odd?` to return true, got false' end end From 49284a4db932e8cc2b2e43441f3b8150f63a759f Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 15:52:34 +0200 Subject: [PATCH 08/26] Autocorrect Style/RegexpLiteral --- .rubocop_todo.yml | 9 --------- lib/aruba/cucumber/command.rb | 2 +- lib/aruba/cucumber/file.rb | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4f5cce859..070ef276d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -310,12 +310,3 @@ Style/NumericPredicate: Exclude: - 'spec/**/*' - 'lib/aruba/contracts/is_power_of_two.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, AllowInnerSlashes. -# SupportedStyles: slashes, percent_r, mixed -Style/RegexpLiteral: - Exclude: - - 'lib/aruba/cucumber/command.rb' - - 'lib/aruba/cucumber/file.rb' diff --git a/lib/aruba/cucumber/command.rb b/lib/aruba/cucumber/command.rb index a2b6876a2..d4c03eada 100644 --- a/lib/aruba/cucumber/command.rb +++ b/lib/aruba/cucumber/command.rb @@ -252,7 +252,7 @@ # you don't need regex, use "the output should contain" instead since # that way, you don't have to escape regex characters that # appear naturally in the output -Then(/^the output should( not)? match \/([^\/]*)\/$/) do |negated, expected| +Then(%r{^the output should( not)? match /([^/]*)/$}) do |negated, expected| if negated expect(all_commands) .not_to include_an_object have_output an_output_string_matching(expected) diff --git a/lib/aruba/cucumber/file.rb b/lib/aruba/cucumber/file.rb index 722b40d16..96b3bc727 100644 --- a/lib/aruba/cucumber/file.rb +++ b/lib/aruba/cucumber/file.rb @@ -176,7 +176,7 @@ end end -Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match \/([^\/]*)\/$/) \ +Then(%r{^(?:a|the) file(?: named)? "([^"]*)" should (not )?match /([^/]*)/$}) \ do |file, negated, content| if negated expect(file).not_to have_file_content file_content_matching(content) From a0b9361aa0499a8ded316c7db633318943980879 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 16:02:37 +0200 Subject: [PATCH 09/26] Fix Style/NumericPredicate offense --- .rubocop_todo.yml | 9 --------- lib/aruba/contracts/is_power_of_two.rb | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 070ef276d..d837e7d81 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -301,12 +301,3 @@ Style/MethodMissingSuper: - 'lib/aruba/in_config_wrapper.rb' - 'lib/aruba/platforms/command_monitor.rb' - 'lib/aruba/tasks/docker_helpers.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: - Exclude: - - 'spec/**/*' - - 'lib/aruba/contracts/is_power_of_two.rb' diff --git a/lib/aruba/contracts/is_power_of_two.rb b/lib/aruba/contracts/is_power_of_two.rb index a6dbec263..2bc88a947 100644 --- a/lib/aruba/contracts/is_power_of_two.rb +++ b/lib/aruba/contracts/is_power_of_two.rb @@ -13,7 +13,7 @@ class IsPowerOfTwo def self.valid?(value) # explanation for algorithm can be found here: # http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/ - value != 0 && (value & (value - 1)) == 0 ? true : false + value.positive? && (value & (value - 1)).zero? rescue StandardError false end From fc44042c9bc59d25561309efef419feb7c1a7c6e Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 16:10:27 +0200 Subject: [PATCH 10/26] Correct several Style/MethodMissingSuper offenses --- .rubocop_todo.yml | 3 --- lib/aruba/config_wrapper.rb | 4 +++- lib/aruba/in_config_wrapper.rb | 15 +++++++-------- lib/aruba/tasks/docker_helpers.rb | 4 +++- spec/aruba/in_config_wrapper_spec.rb | 4 +--- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d837e7d81..77dffc5b7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -297,7 +297,4 @@ Style/IdenticalConditionalBranches: # Offense count: 5 Style/MethodMissingSuper: Exclude: - - 'lib/aruba/config_wrapper.rb' - - 'lib/aruba/in_config_wrapper.rb' - 'lib/aruba/platforms/command_monitor.rb' - - 'lib/aruba/tasks/docker_helpers.rb' diff --git a/lib/aruba/config_wrapper.rb b/lib/aruba/config_wrapper.rb index 24db7d655..fcd191323 100644 --- a/lib/aruba/config_wrapper.rb +++ b/lib/aruba/config_wrapper.rb @@ -32,7 +32,9 @@ def initialize(config, event_bus) def method_missing(name, *args, &block) notify(name, args) if name.to_s.end_with?('=') - config.send(name, *args, &block) + return config.send(name, *args, &block) if config.respond_to? name + + super end # Pass on respond_to?-calls diff --git a/lib/aruba/in_config_wrapper.rb b/lib/aruba/in_config_wrapper.rb index c4c6ac21f..47f1a1207 100644 --- a/lib/aruba/in_config_wrapper.rb +++ b/lib/aruba/in_config_wrapper.rb @@ -15,18 +15,17 @@ def initialize(config) end def method_missing(name, *args) - raise ArgumentError, 'Options take no argument' if args.any? + if config.key? name + raise ArgumentError, 'Options take no argument' if args.any? - unless config.key? name - raise UnknownOptionError, - %(Option "#{name}" is unknown. Please use only earlier defined options) + config[name] + else + super end - - config[name] end - def respond_to_missing?(*) - true + def respond_to_missing?(name, _include_private) + config.key? name end end end diff --git a/lib/aruba/tasks/docker_helpers.rb b/lib/aruba/tasks/docker_helpers.rb index 8f83c94ac..bcd3f8829 100644 --- a/lib/aruba/tasks/docker_helpers.rb +++ b/lib/aruba/tasks/docker_helpers.rb @@ -14,7 +14,9 @@ def initialize(file, instance) end def method_missing(m, *_args) - @file.public_send m, instance + return @file.public_send m, instance if @file.respond_to?(m) + + super end def respond_to_missing?(m) diff --git a/spec/aruba/in_config_wrapper_spec.rb b/spec/aruba/in_config_wrapper_spec.rb index a592ba2cb..19f0bad94 100644 --- a/spec/aruba/in_config_wrapper_spec.rb +++ b/spec/aruba/in_config_wrapper_spec.rb @@ -24,9 +24,7 @@ context 'when option is not defined' do it 'raises an error' do - expect { wrapper.opt } - .to raise_error ArgumentError, - 'Option "opt" is unknown. Please use only earlier defined options' + expect { wrapper.opt }.to raise_error NoMethodError end end end From 233740a383b8d1ea022f8dcc60c313b9d5320f2e Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 16:12:03 +0200 Subject: [PATCH 11/26] Fix Style/IdenticalConditionalBranches offense --- .rubocop_todo.yml | 5 ----- lib/aruba/hooks.rb | 6 ++---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 77dffc5b7..52f7bf00a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -289,11 +289,6 @@ Style/EvalWithLocation: Style/FormatStringToken: Enabled: false -# Offense count: 2 -Style/IdenticalConditionalBranches: - Exclude: - - 'lib/aruba/hooks.rb' - # Offense count: 5 Style/MethodMissingSuper: Exclude: diff --git a/lib/aruba/hooks.rb b/lib/aruba/hooks.rb index ec2a7280b..dc07fa3da 100644 --- a/lib/aruba/hooks.rb +++ b/lib/aruba/hooks.rb @@ -21,12 +21,10 @@ def initialize # @param [Proc] block # The block which should be run for the hook def append(label, block) - if store.key?(label.to_sym) && store[label.to_sym].respond_to?(:<<) - store[label.to_sym] << block - else + unless store.key?(label.to_sym) && store[label.to_sym].respond_to?(:<<) store[label.to_sym] = [] - store[label.to_sym] << block end + store[label.to_sym] << block end # Run hook From d6dee7eeef38be7a329d9cc773b63ae31a841d08 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 16:20:24 +0200 Subject: [PATCH 12/26] Replace eval with simple case statement --- .rubocop.yml | 5 ----- .rubocop_todo.yml | 5 ----- spec/support/helpers/reporting.rb | 13 ++++++++++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a3977a2af..922b48b40 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -49,9 +49,4 @@ Style/HashTransformValues: Style/SlicingWithRange: Enabled: true -# We only permit it in this one area which is internal code testing. Never exposed to users -Security/Eval: - Exclude: - - spec/support/helpers/reporting.rb - inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 52f7bf00a..5b384702d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -278,11 +278,6 @@ Style/Documentation: - 'lib/aruba/setup.rb' - 'lib/aruba/tasks/docker_helpers.rb' -# Offense count: 1 -Style/EvalWithLocation: - Exclude: - - 'spec/support/helpers/reporting.rb' - # Offense count: 83 # Configuration parameters: EnforcedStyle. # SupportedStyles: annotated, template, unannotated diff --git a/spec/support/helpers/reporting.rb b/spec/support/helpers/reporting.rb index 3e811cd08..3788635ba 100644 --- a/spec/support/helpers/reporting.rb +++ b/spec/support/helpers/reporting.rb @@ -16,10 +16,17 @@ module Reporting # stream = capture(:stderr) { system('echo error 1>&2') } # stream # => "error\n" def capture(stream) - stream = stream.to_s - captured_stream = Tempfile.new(stream) + captured_stream = Tempfile.new(stream.to_s) - stream_io = eval("$#{stream}") + stream_io = case stream + when :stdout + $stdout + when :stderr + $stderr + else + raise ArgumentError, + "Expected stream to be :stdout or :stderr, got #{stream.inspect}" + end origin_stream = stream_io.dup stream_io.reopen(captured_stream) From 858c4252c915fa2dc81704cdde8197f6aeaf344d Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 16:22:02 +0200 Subject: [PATCH 13/26] Fix Style/CommentedKeyword offense --- .rubocop_todo.yml | 5 ----- spec/aruba/api_spec.rb | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5b384702d..6a37b3b33 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -259,11 +259,6 @@ Style/CaseEquality: Exclude: - 'lib/aruba/matchers/base/object_formatter.rb' -# Offense count: 1 -Style/CommentedKeyword: - Exclude: - - 'spec/aruba/api_spec.rb' - # Offense count: 12 Style/Documentation: Exclude: diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index b79bfc758..10aecd8ce 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -71,4 +71,4 @@ def root_directory .to include('LONG_LONG_ENV_VARIABLE=false') end end -end # Aruba::Api +end From 917cdc34a7aa7e2b30b7ae990a46c056cde962d2 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 17:17:14 +0200 Subject: [PATCH 14/26] Correct one Style/AccessModifierDeclarations offense --- .rubocop_todo.yml | 1 - lib/aruba/matchers/base/base_matcher.rb | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6a37b3b33..8710242c9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -250,7 +250,6 @@ Security/Open: # SupportedStyles: inline, group Style/AccessModifierDeclarations: Exclude: - - 'lib/aruba/matchers/base/base_matcher.rb' - 'lib/aruba/matchers/collection/all.rb' # Offense count: 3 diff --git a/lib/aruba/matchers/base/base_matcher.rb b/lib/aruba/matchers/base/base_matcher.rb index a82948910..abc91c4fd 100644 --- a/lib/aruba/matchers/base/base_matcher.rb +++ b/lib/aruba/matchers/base/base_matcher.rb @@ -33,6 +33,8 @@ def iterable? # @private module HashFormatting + module_function + # `{ :a => 5, :b => 2 }.inspect` produces: # # {:a=>5, :b=>2} @@ -45,7 +47,6 @@ module HashFormatting def improve_hash_formatting(inspect_string) inspect_string.gsub(/(\S)=>(\S)/, '\1 => \2') end - module_function :improve_hash_formatting end include HashFormatting From 5e739ae54ea246909984219fc07426406d1b5ba6 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 17:21:07 +0200 Subject: [PATCH 15/26] Correct RSpec/VoidExpect offenses --- .rubocop_todo.yml | 5 ----- spec/aruba/matchers/file_spec.rb | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8710242c9..e25cf6644 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -235,11 +235,6 @@ RSpec/VerifiedDoubles: Exclude: - 'spec/aruba/jruby_spec.rb' -# Offense count: 2 -RSpec/VoidExpect: - Exclude: - - 'spec/aruba/matchers/file_spec.rb' - # Offense count: 2 Security/Open: Exclude: diff --git a/spec/aruba/matchers/file_spec.rb b/spec/aruba/matchers/file_spec.rb index e914ba1eb..073d29d06 100644 --- a/spec/aruba/matchers/file_spec.rb +++ b/spec/aruba/matchers/file_spec.rb @@ -171,6 +171,7 @@ def fail_with(message) context 'and this is not expected' do it do expect { expect(files).not_to include a_file_with_same_content_as reference_file } + .to raise_error RSpec::Expectations::ExpectationNotMetError end end end @@ -185,6 +186,7 @@ def fail_with(message) context 'and this is not expected' do it do expect { expect(files).to include a_file_with_same_content_as reference_file } + .to raise_error RSpec::Expectations::ExpectationNotMetError end end end From a00bf63b2e471f67b4b0f66a63080aa577e62f61 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 17:49:18 +0200 Subject: [PATCH 16/26] Fix RSpec/ScatteredSetup offenses --- .rubocop_todo.yml | 9 --------- spec/aruba/api/filesystem_spec.rb | 18 +----------------- spec/aruba/matchers/directory_spec.rb | 3 --- spec/aruba/matchers/path_spec.rb | 6 ------ spec/aruba/processes/spawn_process_spec.rb | 7 ++++--- spec/event_bus_spec.rb | 6 ------ 6 files changed, 5 insertions(+), 44 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e25cf6644..e1733cda3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -215,15 +215,6 @@ RSpec/RepeatedExampleGroupDescription: Exclude: - 'spec/aruba/matchers/command_spec.rb' -# Offense count: 22 -RSpec/ScatteredSetup: - Exclude: - - 'spec/aruba/api/filesystem_spec.rb' - - 'spec/aruba/matchers/directory_spec.rb' - - 'spec/aruba/matchers/path_spec.rb' - - 'spec/aruba/processes/spawn_process_spec.rb' - - 'spec/event_bus_spec.rb' - # Offense count: 1 RSpec/UnspecifiedException: Exclude: diff --git a/spec/aruba/api/filesystem_spec.rb b/spec/aruba/api/filesystem_spec.rb index 56b431929..5a9e0e4b9 100644 --- a/spec/aruba/api/filesystem_spec.rb +++ b/spec/aruba/api/filesystem_spec.rb @@ -321,9 +321,8 @@ context 'when source is existing' do context 'when destination is non-existing' do context 'when source is file' do - before { create_test_files(source) } - before do + create_test_files(source) @aruba.copy source, destination end @@ -359,9 +358,6 @@ before do Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, source)) - end - - before do @aruba.copy source, destination end @@ -389,9 +385,6 @@ before do Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, destination)) - end - - before do @aruba.copy source, destination end @@ -486,13 +479,7 @@ def actual_permissions before do @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) - end - - before do File.open(file_path, 'w') { |f| f << '' } - end - - before do @aruba.chmod(permissions, file_name) end @@ -746,9 +733,6 @@ def actual_permissions context 'when it exists' do before do Array(path).each { |it| Aruba.platform.mkdir it } - end - - before do @aruba.remove(name, options) end diff --git a/spec/aruba/matchers/directory_spec.rb b/spec/aruba/matchers/directory_spec.rb index a4ec9e095..66e701a67 100644 --- a/spec/aruba/matchers/directory_spec.rb +++ b/spec/aruba/matchers/directory_spec.rb @@ -31,9 +31,6 @@ context 'when directory exists' do before do FileUtils.mkdir_p path - end - - before do Array(content).each { |p| Dir.mkdir File.join(path, p) } end diff --git a/spec/aruba/matchers/path_spec.rb b/spec/aruba/matchers/path_spec.rb index 9b150da7d..584422e99 100644 --- a/spec/aruba/matchers/path_spec.rb +++ b/spec/aruba/matchers/path_spec.rb @@ -64,13 +64,7 @@ def expand_path(*args) before do @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) - end - - before do File.open(file_path, 'w') { |f| f << '' } - end - - before do @aruba.chmod(permissions, file_name) end diff --git a/spec/aruba/processes/spawn_process_spec.rb b/spec/aruba/processes/spawn_process_spec.rb index b0e704d26..e1c6fb1d2 100644 --- a/spec/aruba/processes/spawn_process_spec.rb +++ b/spec/aruba/processes/spawn_process_spec.rb @@ -11,9 +11,10 @@ let(:working_directory) { Dir.getwd } describe '#stdout' do - before { process.start } - - before { process.stop } + before do + process.start + process.stop + end context 'when invoked once' do it { expect(process.stdout.chomp).to eq 'yo' } diff --git a/spec/event_bus_spec.rb b/spec/event_bus_spec.rb index 5e4bfdfa7..3b898a8f9 100644 --- a/spec/event_bus_spec.rb +++ b/spec/event_bus_spec.rb @@ -128,9 +128,6 @@ class MyMalformedHandler; end before do allow(name_resolver) .to receive(:transform).with(event_name).and_return(event_klass) - end - - before do bus.register(event_klass, MyHandler.new) end @@ -143,9 +140,6 @@ class MyMalformedHandler; end .to receive(:transform).with(event_name).and_return(event_klass) allow(name_resolver) .to receive(:transform).with(another_event_name).and_return(another_event_klass) - end - - before do bus.register([event_klass, another_event_klass], MyHandler.new) end From dbe959a09ead2d681507c70819a1fd6617030cb3 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 17:49:39 +0200 Subject: [PATCH 17/26] Wrap long line --- lib/aruba/cucumber/testing_frameworks.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/aruba/cucumber/testing_frameworks.rb b/lib/aruba/cucumber/testing_frameworks.rb index 9b5e529c1..564a57565 100644 --- a/lib/aruba/cucumber/testing_frameworks.rb +++ b/lib/aruba/cucumber/testing_frameworks.rb @@ -37,7 +37,8 @@ end # RSpec -Then(/^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) do |count_failures| +Then(/^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \ + do |count_failures| if count_failures.nil? step 'the output should not contain "0 failures"' else @@ -79,7 +80,7 @@ # Minitest Then(/^the tests(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \ -do |count_failures| + do |count_failures| if count_failures.nil? step 'the output should not contain "0 errors"' else From b59d30f629fcc9ad80748ac864a099f33f65e996 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 17:52:03 +0200 Subject: [PATCH 18/26] Fix RSpec/RepeatedExampleGroupDescription offenses --- .rubocop_todo.yml | 5 ----- spec/aruba/matchers/command_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e1733cda3..d02f4bccc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -210,11 +210,6 @@ RSpec/RepeatedDescription: Exclude: - 'spec/aruba/matchers/file_spec.rb' -# Offense count: 4 -RSpec/RepeatedExampleGroupDescription: - Exclude: - - 'spec/aruba/matchers/command_spec.rb' - # Offense count: 1 RSpec/UnspecifiedException: Exclude: diff --git a/spec/aruba/matchers/command_spec.rb b/spec/aruba/matchers/command_spec.rb index 26c4740a0..3e57f892a 100644 --- a/spec/aruba/matchers/command_spec.rb +++ b/spec/aruba/matchers/command_spec.rb @@ -20,7 +20,7 @@ def announcer(*args) it { expect(last_command_started).to have_exit_status 0 } end - context 'when has exit 0' do + context 'when does not have exit 0' do let(:cmd) { 'false' } it { expect(last_command_started).not_to have_exit_status 0 } @@ -36,7 +36,7 @@ def announcer(*args) it { expect(last_command_started).to be_successfully_executed } end - context 'when has exit 0' do + context 'when does not have exit 0' do let(:cmd) { 'false' } it { expect(last_command_started).not_to be_successfully_executed } From 1d3aaa8f8ec149728b0ff629aa87d27de21a829a Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 17:53:10 +0200 Subject: [PATCH 19/26] Fix RSpec/RepeatedDescription offense --- .rubocop_todo.yml | 5 ----- spec/aruba/matchers/file_spec.rb | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d02f4bccc..9240bfcc6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -205,11 +205,6 @@ RSpec/NamedSubject: RSpec/NestedGroups: Max: 6 -# Offense count: 2 -RSpec/RepeatedDescription: - Exclude: - - 'spec/aruba/matchers/file_spec.rb' - # Offense count: 1 RSpec/UnspecifiedException: Exclude: diff --git a/spec/aruba/matchers/file_spec.rb b/spec/aruba/matchers/file_spec.rb index 073d29d06..8fe277afa 100644 --- a/spec/aruba/matchers/file_spec.rb +++ b/spec/aruba/matchers/file_spec.rb @@ -92,7 +92,7 @@ def fail_with(message) end.to fail_with('expected "test.txt" to have file content: "z"') end - example 'for a string' do + example 'for a regular expression' do expect do expect(@file_name).to have_file_content(/z/) end.to fail_with('expected "test.txt" to have file content: /z/') From 9117a1ad403fe079dc129168b7fb2b0704a48582 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 17:56:39 +0200 Subject: [PATCH 20/26] Fix RSpec/VerifiedDoubles offense --- .rubocop_todo.yml | 6 ------ spec/aruba/jruby_spec.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9240bfcc6..f3a5371e6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -210,12 +210,6 @@ RSpec/UnspecifiedException: Exclude: - 'spec/aruba/runtime_spec.rb' -# Offense count: 1 -# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. -RSpec/VerifiedDoubles: - Exclude: - - 'spec/aruba/jruby_spec.rb' - # Offense count: 2 Security/Open: Exclude: diff --git a/spec/aruba/jruby_spec.rb b/spec/aruba/jruby_spec.rb index 62cfa73ac..988fda6a5 100644 --- a/spec/aruba/jruby_spec.rb +++ b/spec/aruba/jruby_spec.rb @@ -4,7 +4,7 @@ describe 'Aruba JRuby Startup Helper' do include Aruba::Api - let(:rb_config) { double('RbConfig::CONFIG') } + let(:rb_config) { instance_double(Hash) } let(:command) do instance_double(Aruba::Processes::BasicProcess, environment: command_environment) end From bab8af340ed58b16982f002b60f3f3e5a452385f Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 18:26:41 +0200 Subject: [PATCH 21/26] Fix RSpec/NamedSubject offenses --- .rubocop_todo.yml | 8 -------- spec/aruba/hooks_spec.rb | 10 ++++++---- spec/aruba/platforms/command_monitor_spec.rb | 10 +++------- spec/aruba/processes/basic_process_spec.rb | 10 +++++----- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f3a5371e6..671c0fcc1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -193,14 +193,6 @@ RSpec/MessageSpies: RSpec/MultipleExpectations: Max: 5 -# Offense count: 10 -# Configuration parameters: IgnoreSharedExamples. -RSpec/NamedSubject: - Exclude: - - 'spec/aruba/hooks_spec.rb' - - 'spec/aruba/platforms/command_monitor_spec.rb' - - 'spec/aruba/processes/basic_process_spec.rb' - # Offense count: 187 RSpec/NestedGroups: Max: 6 diff --git a/spec/aruba/hooks_spec.rb b/spec/aruba/hooks_spec.rb index a56137f4f..ed0124d29 100644 --- a/spec/aruba/hooks_spec.rb +++ b/spec/aruba/hooks_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper' describe Aruba::Hooks do + let(:hooks) { described_class.new } + it 'executes a stored hook' do hook_was_run = false - subject.append :hook_label, -> { hook_was_run = true } - subject.execute :hook_label, self + hooks.append :hook_label, -> { hook_was_run = true } + hooks.execute :hook_label, self expect(hook_was_run).to be_truthy end it 'executes a stored hook that takes multiple arguments' do hook_values = [] - subject.append :hook_label, ->(a, b, c) { hook_values = [a, b, c] } - subject.execute :hook_label, self, 1, 2, 3 + hooks.append :hook_label, ->(a, b, c) { hook_values = [a, b, c] } + hooks.execute :hook_label, self, 1, 2, 3 expect(hook_values).to eq [1, 2, 3] end end diff --git a/spec/aruba/platforms/command_monitor_spec.rb b/spec/aruba/platforms/command_monitor_spec.rb index 4818bef48..4bba3ca84 100644 --- a/spec/aruba/platforms/command_monitor_spec.rb +++ b/spec/aruba/platforms/command_monitor_spec.rb @@ -1,22 +1,18 @@ require 'spec_helper' RSpec.describe Aruba::CommandMonitor do - subject do - described_class.new(announcer: announcer) - end - + let(:monitor) { described_class.new(announcer: announcer) } let(:announcer) { instance_double(Aruba::Platforms::Announcer) } - let(:process) { instance_double(Aruba::Processes::BasicProcess) } before do allow(process).to receive(:commandline).and_return('foobar') - subject.register_command(process) + monitor.register_command(process) end describe '#find' do it 'works' do - expect(subject.find('foobar')).to eq(process) + expect(monitor.find('foobar')).to eq(process) end end end diff --git a/spec/aruba/processes/basic_process_spec.rb b/spec/aruba/processes/basic_process_spec.rb index 45d658130..1c4c72b67 100644 --- a/spec/aruba/processes/basic_process_spec.rb +++ b/spec/aruba/processes/basic_process_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' RSpec.describe Aruba::Processes::BasicProcess do - subject do + let(:process) do Class.new(described_class) do def initialize(*args) @stdout = args.shift @@ -29,7 +29,7 @@ def stderr(*_args) describe '#inspect' do it 'shows useful info' do expected = /commandline="foobar": stdout="foo output" stderr="foo error output"/ - expect(subject.inspect).to match(expected) + expect(process.inspect).to match(expected) end context 'with no stdout' do @@ -37,7 +37,7 @@ def stderr(*_args) it 'shows useful info' do expected = /commandline="foobar": stdout=nil stderr="foo error output"/ - expect(subject.inspect).to match(expected) + expect(process.inspect).to match(expected) end end @@ -46,7 +46,7 @@ def stderr(*_args) it 'shows useful info' do expected = /commandline="foobar": stdout="foo output" stderr=nil/ - expect(subject.inspect).to match(expected) + expect(process.inspect).to match(expected) end end @@ -56,7 +56,7 @@ def stderr(*_args) it 'shows useful info' do expected = /commandline="foobar": stdout=nil stderr=nil/ - expect(subject.inspect).to match(expected) + expect(process.inspect).to match(expected) end end end From ea0053c7538d18acd550c3032b9fbe14c754800c Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 18:38:01 +0200 Subject: [PATCH 22/26] Fix RSpec/MessageSpies offense --- .rubocop_todo.yml | 7 ------- spec/aruba/api_spec.rb | 8 +++++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 671c0fcc1..91ab55440 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -182,13 +182,6 @@ RSpec/LetSetup: - 'spec/event_bus/name_resolver_spec.rb' - 'spec/event_bus_spec.rb' -# Offense count: 1 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: have_received, receive -RSpec/MessageSpies: - Exclude: - - 'spec/aruba/api_spec.rb' - # Offense count: 32 RSpec/MultipleExpectations: Max: 5 diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index 10aecd8ce..f17d56a4a 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -13,14 +13,16 @@ context 'enabled' do before do @aruba.aruba.announcer = instance_double 'Aruba::Platforms::Announcer' - expect(@aruba.aruba.announcer) - .to receive(:announce).with(:stdout).and_return("hello world\n") allow(@aruba.aruba.announcer).to receive(:announce) end it 'announces to stdout exactly once' do @aruba.run_command_and_stop('echo "hello world"', fail_on_error: false) - expect(@aruba.last_command_started.output).to include('hello world') + + aggregate_failures do + expect(@aruba.last_command_started.output).to include('hello world') + expect(@aruba.aruba.announcer).to have_received(:announce).with(:stdout).once + end end end From 92d2c960a6d140040fbfe39e878f519d210b9d36 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 20:44:53 +0200 Subject: [PATCH 23/26] Fix RSpec/LetSetup offenses --- .rubocop_todo.yml | 6 ------ spec/event_bus/name_resolver_spec.rb | 8 ++++---- spec/event_bus_spec.rb | 18 +++++++++--------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 91ab55440..a7c7b104b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -176,12 +176,6 @@ RSpec/LeakyConstantDeclaration: - 'spec/aruba/platform/windows_environment_variables_spec.rb' - 'spec/aruba/processes/in_process_spec.rb' -# Offense count: 5 -RSpec/LetSetup: - Exclude: - - 'spec/event_bus/name_resolver_spec.rb' - - 'spec/event_bus_spec.rb' - # Offense count: 32 RSpec/MultipleExpectations: Max: 5 diff --git a/spec/event_bus/name_resolver_spec.rb b/spec/event_bus/name_resolver_spec.rb index f65b12c7b..e9644da2e 100644 --- a/spec/event_bus/name_resolver_spec.rb +++ b/spec/event_bus/name_resolver_spec.rb @@ -52,15 +52,15 @@ end context 'when is string' do - let!(:default_name_space) { 'MyLib::Events' } - let!(:original_name) { :my_event } + let(:default_name_space) { 'MyLib::Events' } + let(:original_name) { :my_event } it { expect(resolved_name).to eq MyLib::Events::MyEvent } end context 'when is module' do - let!(:default_name_space) { MyLib::Events } - let!(:original_name) { :my_event } + let(:default_name_space) { MyLib::Events } + let(:original_name) { :my_event } it { expect(resolved_name).to eq MyLib::Events::MyEvent } end diff --git a/spec/event_bus_spec.rb b/spec/event_bus_spec.rb index 3b898a8f9..153229306 100644 --- a/spec/event_bus_spec.rb +++ b/spec/event_bus_spec.rb @@ -17,13 +17,13 @@ class MyMalformedHandler; end let(:name_resolver) { instance_double('Events::NameResolver') } - let!(:event_klass) { Events::TestEvent } - let!(:event_name) { event_klass } - let!(:event_instance) { Events::TestEvent.new } + let(:event_klass) { Events::TestEvent } + let(:event_name) { event_klass } + let(:event_instance) { Events::TestEvent.new } - let!(:another_event_klass) { Events::AnotherTestEvent } - let!(:another_event_name) { another_event_klass } - let!(:another_event_instance) { Events::AnotherTestEvent.new } + let(:another_event_klass) { Events::AnotherTestEvent } + let(:another_event_name) { another_event_klass } + let(:another_event_instance) { Events::AnotherTestEvent.new } describe '#notify' do before do @@ -56,7 +56,7 @@ class MyMalformedHandler; end end context 'when event is not an instance of event class' do - let!(:event_name) { :test_event } + let(:event_name) { :test_event } let(:received_payload) { [] } before do @@ -93,7 +93,7 @@ class MyMalformedHandler; end end context 'when is string' do - let!(:event_name) { event_klass.to_s } + let(:event_name) { event_klass.to_s } let(:received_payload) { [] } before do @@ -108,7 +108,7 @@ class MyMalformedHandler; end end context 'when is symbol and event is defined in the default namespace' do - let!(:event_name) { :test_event } + let(:event_name) { :test_event } let(:received_payload) { [] } before do From 3b46baa792e8580bc9b9b640080db294e5a686dd Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 22:30:55 +0200 Subject: [PATCH 24/26] Fix RSpec/LeakyConstantDeclaration offenses --- .rubocop_todo.yml | 6 --- .../windows_environment_variables_spec.rb | 6 --- spec/aruba/processes/in_process_spec.rb | 52 +++++++++++-------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a7c7b104b..0a1c59aaa 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -170,12 +170,6 @@ RSpec/InstanceVariable: - 'spec/event_bus_spec.rb' - 'spec/support/shared_contexts/aruba.rb' -# Offense count: 7 -RSpec/LeakyConstantDeclaration: - Exclude: - - 'spec/aruba/platform/windows_environment_variables_spec.rb' - - 'spec/aruba/processes/in_process_spec.rb' - # Offense count: 32 RSpec/MultipleExpectations: Max: 5 diff --git a/spec/aruba/platform/windows_environment_variables_spec.rb b/spec/aruba/platform/windows_environment_variables_spec.rb index 514b9cb4a..883f247f0 100644 --- a/spec/aruba/platform/windows_environment_variables_spec.rb +++ b/spec/aruba/platform/windows_environment_variables_spec.rb @@ -116,8 +116,6 @@ let(:variable) { 'unknown' } context 'and no default is given' do - class KeyError < StandardError; end unless defined? KeyError - it { expect { environment.fetch(variable) }.to raise_error KeyError } end @@ -154,8 +152,6 @@ class KeyError < StandardError; end unless defined? KeyError let(:variable) { 'unknown' } context 'and no default is given' do - class KeyError < StandardError; end unless defined? KeyError - it { expect { environment.fetch(variable) }.to raise_error KeyError } end @@ -192,8 +188,6 @@ class KeyError < StandardError; end unless defined? KeyError let(:variable) { 'unknown' } context 'and no default is given' do - class KeyError < StandardError; end unless defined? KeyError - it { expect { environment.fetch(variable) }.to raise_error KeyError } end diff --git a/spec/aruba/processes/in_process_spec.rb b/spec/aruba/processes/in_process_spec.rb index c86402b6d..52c54aaa5 100644 --- a/spec/aruba/processes/in_process_spec.rb +++ b/spec/aruba/processes/in_process_spec.rb @@ -1,35 +1,43 @@ require 'spec_helper' RSpec.describe Aruba::Processes::InProcess do - class Runner - def initialize(_argv, _stdin, stdout, stderr, kernel) - @stdout = stdout - @stderr = stderr - @kernel = kernel - end + let(:base_runner) do + Class.new do + def initialize(_argv, _stdin, stdout, stderr, kernel) + @stdout = stdout + @stderr = stderr + @kernel = kernel + end - def execute!; end + def execute!; end + end end - class StdoutRunner < Runner - def execute! - @stdout.puts 'yo' + let(:stdout_runner) do + Class.new(base_runner) do + def execute! + @stdout.puts 'yo' + end end end - class StderrRunner < Runner - def execute! - @stderr.puts 'yo' + let(:stderr_runner) do + Class.new(base_runner) do + def execute! + @stderr.puts 'yo' + end end end - class FailedRunner < Runner - def execute! - raise 'Oops' + let(:failed_runner) do + Class.new(base_runner) do + def execute! + raise 'Oops' + end end end - subject(:process) do + let(:process) do described_class.new(command, exit_timeout, io_wait, working_directory, environment, main_class) end @@ -39,10 +47,10 @@ def execute! let(:io_wait) { 1 } let(:working_directory) { Dir.getwd } let(:environment) { ENV.to_hash.dup } - let(:main_class) { Runner } + let(:main_class) { base_runner } describe '#stdout' do - let(:main_class) { StdoutRunner } + let(:main_class) { stdout_runner } before do process.start @@ -59,7 +67,7 @@ def execute! end describe '#stderr' do - let(:main_class) { StderrRunner } + let(:main_class) { stderr_runner } before do process.start @@ -99,7 +107,7 @@ def execute! end context 'when process run fails' do - let(:main_class) { FailedRunner } + let(:main_class) { failed_runner } it { expect { process.start }.to raise_error RuntimeError, 'Oops' } end @@ -109,7 +117,7 @@ def execute! def run_process(&block) process = described_class.new( command, exit_timeout, io_wait, working_directory, - environment, Class.new(Runner) { define_method(:execute!, &block) } + environment, Class.new(base_runner) { define_method(:execute!, &block) } ) process.start process.stop From 62766b5f6e457e8ee36066d824ac26a729d92f82 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 22:50:43 +0200 Subject: [PATCH 25/26] Move old spec setup to where it belongs This setup was left behind when the specs were moved and commented out --- .rubocop_todo.yml | 6 ------ spec/aruba/api_spec.rb | 14 -------------- spec/aruba/runtime_spec.rb | 12 ++++++++++++ 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0a1c59aaa..bdabb091f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -123,12 +123,6 @@ RSpec/DescribeClass: - 'spec/aruba/platform/simple_table_spec.rb' - 'spec/aruba/rspec_spec.rb' -# Offense count: 1 -# Configuration parameters: CustomIncludeMethods. -RSpec/EmptyExampleGroup: - Exclude: - - 'spec/aruba/api_spec.rb' - # Offense count: 19 # Configuration parameters: Max. RSpec/ExampleLength: diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index f17d56a4a..141af13e5 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -39,20 +39,6 @@ end end - describe 'fixtures' do - let(:api) do - klass = Class.new do - include Aruba::Api - - def root_directory - expand_path('.') - end - end - - klass.new - end - end - describe '#set_environment_variable' do after do @aruba.all_commands.each(&:stop) diff --git a/spec/aruba/runtime_spec.rb b/spec/aruba/runtime_spec.rb index 6d664a291..a1e185bcb 100644 --- a/spec/aruba/runtime_spec.rb +++ b/spec/aruba/runtime_spec.rb @@ -2,6 +2,18 @@ RSpec.describe Aruba::Runtime do describe '#fixtures_directory' do + let(:api) do + klass = Class.new do + include Aruba::Api + + def root_directory + expand_path('.') + end + end + + klass.new + end + context 'when no fixtures directories exist' do it 'raises exception' do expect { api.fixtures_directory }.to raise_error From 8da2b6a5adeb22b0437dc20a5ff6ce230336fbf4 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 31 May 2020 23:13:02 +0200 Subject: [PATCH 26/26] Regenerate RuboCop TODO file --- .rubocop_todo.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bdabb091f..fd71bbcb0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-05-31 15:37:19 +0200 using RuboCop version 0.84.0. +# on 2020-05-31 23:12:24 +0200 using RuboCop version 0.84.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -18,7 +18,7 @@ Lint/Void: - 'lib/aruba/platforms/announcer.rb' - 'lib/aruba/platforms/unix_environment_variables.rb' -# Offense count: 27 +# Offense count: 26 # Configuration parameters: IgnoredMethods. Metrics/AbcSize: Max: 116 @@ -27,7 +27,7 @@ Metrics/AbcSize: # Configuration parameters: CountComments, ExcludedMethods. # ExcludedMethods: refine Metrics/BlockLength: - Max: 604 + Max: 594 # Offense count: 2 # Configuration parameters: CountComments. @@ -132,11 +132,6 @@ RSpec/ExampleLength: - 'spec/aruba/aruba_path_spec.rb' - 'spec/aruba/matchers/collection_spec.rb' -# Offense count: 1 -RSpec/ExpectInHook: - Exclude: - - 'spec/aruba/api_spec.rb' - # Offense count: 4 # Configuration parameters: CustomTransform, IgnoreMethods. RSpec/FilePath: @@ -146,7 +141,7 @@ RSpec/FilePath: - 'spec/event_bus/name_resolver_spec.rb' - 'spec/event_bus_spec.rb' -# Offense count: 300 +# Offense count: 298 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: @@ -182,7 +177,7 @@ Security/Open: Exclude: - 'lib/aruba/processes/spawn_process.rb' -# Offense count: 2 +# Offense count: 1 # Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols. # SupportedStyles: inline, group Style/AccessModifierDeclarations: @@ -215,7 +210,7 @@ Style/Documentation: Style/FormatStringToken: Enabled: false -# Offense count: 5 +# Offense count: 2 Style/MethodMissingSuper: Exclude: - 'lib/aruba/platforms/command_monitor.rb'