From ce58d5509a29783672e3160b337593ec7e63de95 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sat, 31 Aug 2024 19:43:34 +0200 Subject: [PATCH 1/6] Switch to default RuboCop StringLiterals style This brings Aruba more in line with other Cucumber Ruby code. --- .rubocop.yml | 4 - .simplecov | 14 +- Appraisals | 8 +- Gemfile | 6 +- Rakefile | 28 +- aruba.gemspec | 80 ++-- bin/console | 4 +- exe/aruba | 4 +- features/step_definitions/hooks.rb | 40 +- features/support/aruba.rb | 2 +- features/support/env.rb | 20 +- features/support/jruby.rb | 2 +- features/support/simplecov_setup.rb | 10 +- features/support/timing.rb | 2 +- fixtures/cli-app/Gemfile | 2 +- fixtures/cli-app/Rakefile | 2 +- fixtures/cli-app/bin/aruba-test-cli | 4 +- fixtures/cli-app/cli-app.gemspec | 32 +- fixtures/cli-app/features/support/aruba.rb | 2 +- fixtures/cli-app/features/support/env.rb | 2 +- fixtures/cli-app/lib/cli/app.rb | 4 +- .../lib/cli/app/suppress_simple_cov_output.rb | 6 +- fixtures/cli-app/lib/cli/app/version.rb | 2 +- fixtures/cli-app/script/console | 6 +- fixtures/cli-app/spec/spec_helper.rb | 8 +- fixtures/cli-app/spec/support/aruba.rb | 2 +- fixtures/empty-app/Rakefile | 2 +- fixtures/empty-app/cli-app.gemspec | 28 +- fixtures/empty-app/lib/cli/app.rb | 2 +- fixtures/empty-app/lib/cli/app/version.rb | 2 +- fixtures/getting-started-app/Gemfile | 6 +- .../features/support/env.rb | 2 +- gemfiles/cucumber_8.gemfile | 6 +- gemfiles/cucumber_9.gemfile | 6 +- lib/aruba.rb | 2 +- lib/aruba/api.rb | 22 +- lib/aruba/api/bundler.rb | 4 +- lib/aruba/api/commands.rb | 14 +- lib/aruba/api/core.rb | 42 +- lib/aruba/api/environment.rb | 4 +- lib/aruba/api/filesystem.rb | 28 +- lib/aruba/api/text.rb | 6 +- lib/aruba/aruba_logger.rb | 2 +- lib/aruba/aruba_path.rb | 4 +- lib/aruba/basic_configuration.rb | 22 +- lib/aruba/cli.rb | 14 +- lib/aruba/command.rb | 8 +- lib/aruba/command_monitor.rb | 6 +- lib/aruba/config/jruby.rb | 18 +- lib/aruba/config_wrapper.rb | 4 +- lib/aruba/configuration.rb | 28 +- lib/aruba/console.rb | 20 +- lib/aruba/console/help.rb | 10 +- lib/aruba/contracts/absolute_path.rb | 2 +- lib/aruba/contracts/enum.rb | 2 +- lib/aruba/contracts/is_power_of_two.rb | 2 +- lib/aruba/contracts/relative_path.rb | 2 +- lib/aruba/cucumber.rb | 16 +- lib/aruba/cucumber/command.rb | 144 +++--- lib/aruba/cucumber/environment.rb | 14 +- lib/aruba/cucumber/file.rb | 4 +- lib/aruba/cucumber/hooks.rb | 58 +-- lib/aruba/cucumber/parameter_types.rb | 2 +- lib/aruba/cucumber/testing_frameworks.rb | 36 +- lib/aruba/event_bus.rb | 2 +- lib/aruba/events.rb | 2 +- lib/aruba/file_size.rb | 2 +- lib/aruba/generators/script_file.rb | 4 +- lib/aruba/in_config_wrapper.rb | 2 +- lib/aruba/initializer.rb | 20 +- lib/aruba/matchers/base/message_indenter.rb | 2 +- lib/aruba/matchers/command.rb | 2 +- .../command/be_successfully_executed.rb | 6 +- lib/aruba/matchers/command/have_output.rb | 2 +- .../matchers/command/have_output_size.rb | 4 +- lib/aruba/matchers/directory.rb | 2 +- .../directory/be_an_existing_directory.rb | 2 +- .../matchers/directory/have_sub_directory.rb | 4 +- lib/aruba/matchers/environment.rb | 2 +- lib/aruba/matchers/file.rb | 2 +- .../file/be_a_command_found_in_path.rb | 4 +- .../file/be_an_existing_executable.rb | 2 +- .../matchers/file/be_an_existing_file.rb | 2 +- .../matchers/file/have_same_file_content.rb | 2 +- lib/aruba/matchers/path.rb | 2 +- lib/aruba/matchers/path/have_permissions.rb | 2 +- lib/aruba/matchers/string.rb | 2 +- .../matchers/string/include_output_string.rb | 2 +- .../matchers/string/match_output_string.rb | 2 +- lib/aruba/matchers/string/output_string_eq.rb | 2 +- lib/aruba/platform.rb | 4 +- lib/aruba/platforms/announcer.rb | 28 +- .../aruba_fixed_size_file_creator.rb | 2 +- lib/aruba/platforms/determine_disk_usage.rb | 2 +- lib/aruba/platforms/filesystem_status.rb | 2 +- lib/aruba/platforms/simple_table.rb | 4 +- lib/aruba/platforms/unix_command_string.rb | 4 +- lib/aruba/platforms/unix_platform.rb | 46 +- lib/aruba/platforms/unix_which.rb | 2 +- .../windows_environment_variables.rb | 2 +- lib/aruba/platforms/windows_platform.rb | 10 +- lib/aruba/platforms/windows_which.rb | 10 +- lib/aruba/processes/basic_process.rb | 4 +- lib/aruba/processes/debug_process.rb | 10 +- lib/aruba/processes/in_process.rb | 14 +- lib/aruba/processes/spawn_process.rb | 30 +- lib/aruba/rspec.rb | 12 +- lib/aruba/runtime.rb | 12 +- lib/aruba/setup.rb | 6 +- lib/aruba/version.rb | 2 +- spec/aruba/api/bundler_spec.rb | 12 +- spec/aruba/api/commands_spec.rb | 46 +- spec/aruba/api/core_spec.rb | 196 ++++---- spec/aruba/api/filesystem_spec.rb | 396 ++++++++-------- spec/aruba/api/runtime_spec.rb | 14 +- spec/aruba/api_spec.rb | 48 +- spec/aruba/aruba_path_spec.rb | 60 +-- spec/aruba/basic_configuration_spec.rb | 4 +- spec/aruba/command_monitor_spec.rb | 28 +- spec/aruba/command_spec.rb | 30 +- spec/aruba/configuration_spec.rb | 8 +- spec/aruba/event_bus_spec.rb | 42 +- spec/aruba/hooks_spec.rb | 6 +- spec/aruba/in_config_wrapper_spec.rb | 16 +- spec/aruba/jruby_spec.rb | 56 +-- .../matchers/command/have_output_size_spec.rb | 24 +- spec/aruba/matchers/command_spec.rb | 70 +-- spec/aruba/matchers/directory_spec.rb | 40 +- spec/aruba/matchers/file_spec.rb | 212 ++++----- spec/aruba/matchers/path_spec.rb | 62 +-- spec/aruba/platforms/announcer_spec.rb | 10 +- spec/aruba/platforms/simple_table_spec.rb | 24 +- .../platforms/unix_command_string_spec.rb | 18 +- spec/aruba/platforms/unix_platform_spec.rb | 12 +- .../platforms/windows_command_string_spec.rb | 18 +- .../windows_environment_variables_spec.rb | 432 +++++++++--------- spec/aruba/platforms/windows_platform_spec.rb | 12 +- spec/aruba/processes/basic_process_spec.rb | 24 +- spec/aruba/processes/in_process_spec.rb | 52 +-- spec/aruba/processes/spawn_process_spec.rb | 174 +++---- spec/aruba/rspec_spec.rb | 18 +- spec/aruba/runtime_spec.rb | 20 +- spec/spec_helper.rb | 14 +- spec/support/configs/aruba.rb | 4 +- spec/support/configs/pry.rb | 2 +- spec/support/configs/rspec.rb | 6 +- spec/support/shared_contexts/aruba.rb | 18 +- spec/support/shared_examples/configuration.rb | 46 +- 148 files changed, 1724 insertions(+), 1728 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 14c89afd4..a4844c8d4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -64,10 +64,6 @@ Style/PercentLiteralDelimiters: PreferredDelimiters: '%w': () -# Do not commit to use of interpolation -Style/StringLiterals: - EnforcedStyle: double_quotes - # SupportedStyles: percent, brackets Style/SymbolArray: EnforcedStyle: brackets diff --git a/.simplecov b/.simplecov index 6fe22f24d..eab75c89c 100644 --- a/.simplecov +++ b/.simplecov @@ -5,12 +5,12 @@ SimpleCov.configure do enable_coverage :branch # ignore this file - add_filter ".simplecov" - add_filter "features" + add_filter '.simplecov' + add_filter 'features' # Rake tasks aren't tested with rspec - add_filter "Rakefile" - add_filter "lib/tasks" + add_filter 'Rakefile' + add_filter 'lib/tasks' # # Changed Files in Git Group @@ -21,15 +21,15 @@ SimpleCov.configure do all = untracked + unstaged + staged changed_filenames = all.split("\n") - add_group "Changed" do |source_file| + add_group 'Changed' do |source_file| changed_filenames.select do |changed_filename| source_file.filename.end_with?(changed_filename) end end - add_group "Libraries", "lib" + add_group 'Libraries', 'lib' # Specs are reported on to ensure that all examples are being run and all # lets, befores, afters, etc are being used. - add_group "Specs", "spec/" + add_group 'Specs', 'spec/' end diff --git a/Appraisals b/Appraisals index cf71bf9ae..7dce1b0d7 100644 --- a/Appraisals +++ b/Appraisals @@ -9,10 +9,10 @@ Customize.new heading: <<~HEADING.chomp This file was generated by Appraisal HEADING -appraise "cucumber_8" do - gem "cucumber", "~> 8.0" +appraise 'cucumber_8' do + gem 'cucumber', '~> 8.0' end -appraise "cucumber_9" do - gem "cucumber", ["~> 9.0", ">= 9.0.1"] +appraise 'cucumber_9' do + gem 'cucumber', ['~> 9.0', '>= 9.0.1'] end diff --git a/Gemfile b/Gemfile index 505ac864d..2717c0b9f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,11 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' # Use dependencies from gemspec gemspec # Load local Gemfile -if File.file? File.expand_path("Gemfile.local", __dir__) - load File.expand_path("Gemfile.local", __dir__) +if File.file? File.expand_path('Gemfile.local', __dir__) + load File.expand_path('Gemfile.local', __dir__) end diff --git a/Rakefile b/Rakefile index 848ca81f4..70ca1c927 100644 --- a/Rakefile +++ b/Rakefile @@ -2,45 +2,45 @@ $LOAD_PATH << File.expand_path(__dir__) -require "aruba/platform" +require 'aruba/platform' -require "bundler" +require 'bundler' Bundler.setup -require "cucumber/rake/task" -require "rspec/core/rake_task" -require "rubocop/rake_task" +require 'cucumber/rake/task' +require 'rspec/core/rake_task' +require 'rubocop/rake_task' Cucumber::Rake::Task.new do |t| t.cucumber_opts = %w(--format progress) end -Cucumber::Rake::Task.new("cucumber:wip", "Run Cucumber features" \ - " which are \"WORK IN PROGRESS\" and" \ - " are allowed to fail") do |t| +Cucumber::Rake::Task.new('cucumber:wip', 'Run Cucumber features' \ + ' which are "WORK IN PROGRESS" and' \ + ' are allowed to fail') do |t| t.cucumber_opts = %w(--tags @wip:3 --wip) end RSpec::Core::RakeTask.new -desc "Run the whole test suite." +desc 'Run the whole test suite.' task test: [:spec, :cucumber] RuboCop::RakeTask.new Bundler::GemHelper.install_tasks -require "rake/manifest/task" +require 'rake/manifest/task' Rake::Manifest::Task.new do |t| - t.patterns = ["lib/**/*", "exe/*", "CHANGELOG.md", "CONTRIBUTING.md", - "LICENSE", "README.md"] + t.patterns = ['lib/**/*', 'exe/*', 'CHANGELOG.md', 'CONTRIBUTING.md', + 'LICENSE', 'README.md'] end # Check the manifest before building the gem -task build: "manifest:check" +task build: 'manifest:check' -desc "Run checks" +desc 'Run checks' task lint: %w(rubocop manifest:check) task default: :test diff --git a/aruba.gemspec b/aruba.gemspec index d73476219..7c651afcf 100644 --- a/aruba.gemspec +++ b/aruba.gemspec @@ -1,55 +1,55 @@ # frozen_string_literal: true -require_relative "lib/aruba/version" +require_relative 'lib/aruba/version' Gem::Specification.new do |spec| - spec.name = "aruba" + spec.name = 'aruba' spec.version = Aruba::VERSION - spec.author = "Aslak Hellesøy, Matt Wynne and other Aruba Contributors" + spec.author = 'Aslak Hellesøy, Matt Wynne and other Aruba Contributors' spec.description = <<~TEXT Extension for popular TDD and BDD frameworks like "Cucumber", "RSpec" and "Minitest", to make testing command line applications meaningful, easy and fun. TEXT spec.summary = "aruba-#{spec.version}" - spec.license = "MIT" - spec.email = "cukes@googlegroups.com" - spec.homepage = "https://github.com/cucumber/aruba" + spec.license = 'MIT' + spec.email = 'cukes@googlegroups.com' + spec.homepage = 'https://github.com/cucumber/aruba' spec.metadata = { - "bug_tracker_uri" => "https://github.com/cucumber/aruba/issues", - "changelog_uri" => "https://www.rubydoc.info/gems/aruba/file/CHANGELOG.md", - "documentation_uri" => "https://www.rubydoc.info/gems/aruba", - "homepage_uri" => spec.homepage, - "source_code_uri" => "https://github.com/cucumber/aruba" + 'bug_tracker_uri' => 'https://github.com/cucumber/aruba/issues', + 'changelog_uri' => 'https://www.rubydoc.info/gems/aruba/file/CHANGELOG.md', + 'documentation_uri' => 'https://www.rubydoc.info/gems/aruba', + 'homepage_uri' => spec.homepage, + 'source_code_uri' => 'https://github.com/cucumber/aruba' } - spec.add_dependency "bundler", [">= 1.17", "< 3.0"] - spec.add_dependency "contracts", [">= 0.16.0", "< 0.18.0"] - spec.add_dependency "cucumber", ">= 8.0", "< 10.0" - spec.add_dependency "rspec-expectations", "~> 3.4" - spec.add_dependency "thor", "~> 1.0" - - spec.add_development_dependency "appraisal", "~> 2.4" - spec.add_development_dependency "json", "~> 2.1" - spec.add_development_dependency "kramdown", "~> 2.1" - spec.add_development_dependency "minitest", "~> 5.10" - spec.add_development_dependency "pry", [">= 0.13.0", "< 0.15.0"] - spec.add_development_dependency "rake", [">= 12.0", "< 14.0"] - spec.add_development_dependency "rake-manifest", "~> 0.2.0" - spec.add_development_dependency "rspec", "~> 3.11" - spec.add_development_dependency "rubocop", "~> 1.62" - spec.add_development_dependency "rubocop-packaging", "~> 0.5.2" - spec.add_development_dependency "rubocop-performance", "~> 1.21" - spec.add_development_dependency "rubocop-rspec", "~> 3.0" - spec.add_development_dependency "simplecov", ">= 0.18.0", "< 0.23.0" - - spec.required_ruby_version = ">= 3.0.0" - - spec.files = File.readlines("Manifest.txt", chomp: true) - - spec.executables = ["aruba"] - spec.rdoc_options = ["--charset", "UTF-8", "--main", "README.md"] - spec.extra_rdoc_files = ["CHANGELOG.md", "CONTRIBUTING.md", "README.md", "LICENSE"] - spec.bindir = "exe" - spec.require_paths = ["lib"] + spec.add_dependency 'bundler', ['>= 1.17', '< 3.0'] + spec.add_dependency 'contracts', ['>= 0.16.0', '< 0.18.0'] + spec.add_dependency 'cucumber', '>= 8.0', '< 10.0' + spec.add_dependency 'rspec-expectations', '~> 3.4' + spec.add_dependency 'thor', '~> 1.0' + + spec.add_development_dependency 'appraisal', '~> 2.4' + spec.add_development_dependency 'json', '~> 2.1' + spec.add_development_dependency 'kramdown', '~> 2.1' + spec.add_development_dependency 'minitest', '~> 5.10' + spec.add_development_dependency 'pry', ['>= 0.13.0', '< 0.15.0'] + spec.add_development_dependency 'rake', ['>= 12.0', '< 14.0'] + spec.add_development_dependency 'rake-manifest', '~> 0.2.0' + spec.add_development_dependency 'rspec', '~> 3.11' + spec.add_development_dependency 'rubocop', '~> 1.62' + spec.add_development_dependency 'rubocop-packaging', '~> 0.5.2' + spec.add_development_dependency 'rubocop-performance', '~> 1.21' + spec.add_development_dependency 'rubocop-rspec', '~> 3.0' + spec.add_development_dependency 'simplecov', '>= 0.18.0', '< 0.23.0' + + spec.required_ruby_version = '>= 3.0.0' + + spec.files = File.readlines('Manifest.txt', chomp: true) + + spec.executables = ['aruba'] + spec.rdoc_options = ['--charset', 'UTF-8', '--main', 'README.md'] + spec.extra_rdoc_files = ['CHANGELOG.md', 'CONTRIBUTING.md', 'README.md', 'LICENSE'] + spec.bindir = 'exe' + spec.require_paths = ['lib'] end diff --git a/bin/console b/bin/console index 11f3ee2ee..ae91bface 100755 --- a/bin/console +++ b/bin/console @@ -1,8 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path("../lib", __dir__) +$LOAD_PATH.unshift File.expand_path('../lib', __dir__) -require "aruba/console" +require 'aruba/console' Aruba::Console.new.start diff --git a/exe/aruba b/exe/aruba index 9e3365d21..90aa256d4 100755 --- a/exe/aruba +++ b/exe/aruba @@ -1,8 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH << File.expand_path("../lib", __dir__) +$LOAD_PATH << File.expand_path('../lib', __dir__) -require "aruba/cli" +require 'aruba/cli' Aruba::Cli.start diff --git a/features/step_definitions/hooks.rb b/features/step_definitions/hooks.rb index e65a52c59..317f8a354 100644 --- a/features/step_definitions/hooks.rb +++ b/features/step_definitions/hooks.rb @@ -1,65 +1,65 @@ # frozen_string_literal: true -require "cucumber/platform" +require 'cucumber/platform' -Before "@requires-python" do - next unless Aruba.platform.which("python").nil? +Before '@requires-python' do + next unless Aruba.platform.which('python').nil? skip_this_scenario end -Before "@requires-zsh" do - next unless Aruba.platform.which("zsh").nil? +Before '@requires-zsh' do + next unless Aruba.platform.which('zsh').nil? skip_this_scenario end -Before "@requires-java" do - next unless Aruba.platform.which("javac").nil? +Before '@requires-java' do + next unless Aruba.platform.which('javac').nil? skip_this_scenario end -Before "@requires-perl" do - next unless Aruba.platform.which("perl").nil? +Before '@requires-perl' do + next unless Aruba.platform.which('perl').nil? skip_this_scenario end -Before "@requires-ruby" do - next unless Aruba.platform.which("ruby").nil? +Before '@requires-ruby' do + next unless Aruba.platform.which('ruby').nil? skip_this_scenario end -Before "@requires-posix-standard-tools" do - next unless Aruba.platform.which("printf").nil? +Before '@requires-posix-standard-tools' do + next unless Aruba.platform.which('printf').nil? skip_this_scenario end -Before "@requires-ruby-platform-java" do +Before '@requires-ruby-platform-java' do skip_this_scenario unless Cucumber::JRUBY end -Before "@unsupported-on-platform-java" do +Before '@unsupported-on-platform-java' do skip_this_scenario if Cucumber::JRUBY end -Before "@unsupported-on-platform-windows" do +Before '@unsupported-on-platform-windows' do skip_this_scenario if Cucumber::WINDOWS end -Before "@requires-readline" do - require "readline" +Before '@requires-readline' do + require 'readline' rescue LoadError skip_this_scenario end -Before "@unsupported-on-platform-unix" do +Before '@unsupported-on-platform-unix' do skip_this_scenario unless Cucumber::WINDOWS end -Before "@unsupported-on-platform-mac" do +Before '@unsupported-on-platform-mac' do skip_this_scenario if Cucumber::OS_X end diff --git a/features/support/aruba.rb b/features/support/aruba.rb index 1533e51ad..57c903533 100644 --- a/features/support/aruba.rb +++ b/features/support/aruba.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/cucumber" +require 'aruba/cucumber' Aruba.configure do |config| config.exit_timeout = 120 diff --git a/features/support/env.rb b/features/support/env.rb index 27efd8bfe..e918fc8d0 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path("../../lib", __dir__) +$LOAD_PATH.unshift File.expand_path('../../lib', __dir__) # Has to be the first file required so that all other files show coverage information -require "simplecov" unless RUBY_PLATFORM.include?("java") +require 'simplecov' unless RUBY_PLATFORM.include?('java') # Standard Library -require "fileutils" -require "pathname" +require 'fileutils' +require 'pathname' # Gems -require "aruba/cucumber" -require "aruba/config/jruby" -require "rspec/expectations" +require 'aruba/cucumber' +require 'aruba/config/jruby' +require 'rspec/expectations' Before do |test_case| command_name = "#{test_case.location.file}:#{test_case.location.line} # #{test_case.name}" @@ -20,12 +20,12 @@ # Used in simplecov_setup so that each scenario has a different name and # their coverage results are merged instead of overwriting each other as # 'Cucumber Features' - ENV["SIMPLECOV_COMMAND_NAME"] = command_name.to_s + ENV['SIMPLECOV_COMMAND_NAME'] = command_name.to_s simplecov_setup_pathname = - Pathname.new(__FILE__).expand_path.parent.join("simplecov_setup") + Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup') # set environment variable so child processes will merge their coverage data # with parent process's coverage data. - ENV["RUBYOPT"] = "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}" + ENV['RUBYOPT'] = "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}" end diff --git a/features/support/jruby.rb b/features/support/jruby.rb index 47bede405..63038a16d 100644 --- a/features/support/jruby.rb +++ b/features/support/jruby.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -if RUBY_PLATFORM == "java" +if RUBY_PLATFORM == 'java' Before do @aruba_timeout_seconds = 15 end diff --git a/features/support/simplecov_setup.rb b/features/support/simplecov_setup.rb index 41d96ce74..ef26b4d48 100644 --- a/features/support/simplecov_setup.rb +++ b/features/support/simplecov_setup.rb @@ -2,13 +2,13 @@ # @note this file is loaded in env.rb to setup simplecov using RUBYOPTs for # child processes and @in-process -unless RUBY_PLATFORM.include?("java") - require "simplecov" - root = File.expand_path("../..", __dir__) - command_name = ENV["SIMPLECOV_COMMAND_NAME"] || "Cucumber Features" +unless RUBY_PLATFORM.include?('java') + require 'simplecov' + root = File.expand_path('../..', __dir__) + command_name = ENV['SIMPLECOV_COMMAND_NAME'] || 'Cucumber Features' SimpleCov.command_name(command_name) SimpleCov.root(root) # Run simplecov by default - SimpleCov.start unless ENV.key? "ARUBA_NO_COVERAGE" + SimpleCov.start unless ENV.key? 'ARUBA_NO_COVERAGE' end diff --git a/features/support/timing.rb b/features/support/timing.rb index 4ff1470ef..c8cd2a9d3 100644 --- a/features/support/timing.rb +++ b/features/support/timing.rb @@ -18,6 +18,6 @@ slowest_times = sorted_times.first(20) puts "------------- Top #{slowest_times.size} slowest scenarios -------------" slowest_times.each do |key, value| - puts format("%.2f %s", value, key) + puts format('%.2f %s', value, key) end end diff --git a/fixtures/cli-app/Gemfile b/fixtures/cli-app/Gemfile index 1a48fccdf..e0d718303 100644 --- a/fixtures/cli-app/Gemfile +++ b/fixtures/cli-app/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' # Use dependencies from gemspec gemspec diff --git a/fixtures/cli-app/Rakefile b/fixtures/cli-app/Rakefile index 5263b5839..7398a9005 100644 --- a/fixtures/cli-app/Rakefile +++ b/fixtures/cli-app/Rakefile @@ -1,3 +1,3 @@ # frozen_string_literal: true -require "bundler/gem_tasks" +require 'bundler/gem_tasks' diff --git a/fixtures/cli-app/bin/aruba-test-cli b/fixtures/cli-app/bin/aruba-test-cli index c4ab1d75d..5bcbdb3fb 100755 --- a/fixtures/cli-app/bin/aruba-test-cli +++ b/fixtures/cli-app/bin/aruba-test-cli @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH << File.expand_path("../lib", __dir__) -require "cli/app" +$LOAD_PATH << File.expand_path('../lib', __dir__) +require 'cli/app' exit 0 diff --git a/fixtures/cli-app/cli-app.gemspec b/fixtures/cli-app/cli-app.gemspec index f4b99a262..a5fcd202f 100644 --- a/fixtures/cli-app/cli-app.gemspec +++ b/fixtures/cli-app/cli-app.gemspec @@ -1,30 +1,30 @@ # frozen_string_literal: true -lib = File.expand_path("lib", __dir__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "cli/app/version" +require 'cli/app/version' Gem::Specification.new do |spec| - spec.name = "cli-app" + spec.name = 'cli-app' spec.version = Cli::App::VERSION - spec.authors = ["Aruba Developers"] - spec.email = "cukes@googlegroups.com" + spec.authors = ['Aruba Developers'] + spec.email = 'cukes@googlegroups.com' - spec.summary = "Summary" - spec.description = "Description" - spec.homepage = "http://example.com" + spec.summary = 'Summary' + spec.description = 'Description' + spec.homepage = 'http://example.com' - spec.required_ruby_version = ">= 3.0" + spec.required_ruby_version = '>= 3.0' # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or # delete this section to allow pushing this gem to any host. - spec.files = Dir["lib/**/*", "README.md"] - spec.bindir = "exe" - spec.executables = ["bin/aruba-test-cli"] - spec.require_paths = ["lib"] + spec.files = Dir['lib/**/*', 'README.md'] + spec.bindir = 'exe' + spec.executables = ['bin/aruba-test-cli'] + spec.require_paths = ['lib'] - spec.add_development_dependency "aruba" - spec.add_development_dependency "bundler" - spec.add_development_dependency "rake" + spec.add_development_dependency 'aruba' + spec.add_development_dependency 'bundler' + spec.add_development_dependency 'rake' end diff --git a/fixtures/cli-app/features/support/aruba.rb b/fixtures/cli-app/features/support/aruba.rb index 25a3b5d1d..751674fc0 100644 --- a/fixtures/cli-app/features/support/aruba.rb +++ b/fixtures/cli-app/features/support/aruba.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require "aruba/cucumber" +require 'aruba/cucumber' diff --git a/fixtures/cli-app/features/support/env.rb b/fixtures/cli-app/features/support/env.rb index deebd5269..bcc12c29d 100644 --- a/fixtures/cli-app/features/support/env.rb +++ b/fixtures/cli-app/features/support/env.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require_relative "aruba" +require_relative 'aruba' diff --git a/fixtures/cli-app/lib/cli/app.rb b/fixtures/cli-app/lib/cli/app.rb index 532ae4c72..d5ec82f7e 100644 --- a/fixtures/cli-app/lib/cli/app.rb +++ b/fixtures/cli-app/lib/cli/app.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require "cli/app/version" +require 'cli/app/version' -Dir.glob(File.expand_path("**/*.rb", __dir__)).each { |f| require_relative f } +Dir.glob(File.expand_path('**/*.rb', __dir__)).each { |f| require_relative f } module Cli module App diff --git a/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb b/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb index 506aa449c..66766c060 100644 --- a/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +++ b/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb @@ -4,12 +4,12 @@ module SimpleCov module Formatter class HTMLFormatter def format(result) - Dir[File.join(File.dirname(__FILE__), "../public/*")].each do |path| + Dir[File.join(File.dirname(__FILE__), '../public/*')].each do |path| FileUtils.cp_r(path, asset_output_path) end - File.open(File.join(output_path, "index.html"), "wb") do |file| - file.puts template("layout").result(binding) + File.open(File.join(output_path, 'index.html'), 'wb') do |file| + file.puts template('layout').result(binding) end end end diff --git a/fixtures/cli-app/lib/cli/app/version.rb b/fixtures/cli-app/lib/cli/app/version.rb index 69e6983ae..140105bcc 100644 --- a/fixtures/cli-app/lib/cli/app/version.rb +++ b/fixtures/cli-app/lib/cli/app/version.rb @@ -2,6 +2,6 @@ module Cli module App - VERSION = "0.1.0" + VERSION = '0.1.0' end end diff --git a/fixtures/cli-app/script/console b/fixtures/cli-app/script/console index b7f138e67..147473a63 100755 --- a/fixtures/cli-app/script/console +++ b/fixtures/cli-app/script/console @@ -1,8 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require "bundler/setup" -require "cli/app" +require 'bundler/setup' +require 'cli/app' # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. @@ -11,5 +11,5 @@ require "cli/app" # require "pry" # Pry.start -require "irb" +require 'irb' IRB.start diff --git a/fixtures/cli-app/spec/spec_helper.rb b/fixtures/cli-app/spec/spec_helper.rb index b8b3e7bec..8057136f7 100644 --- a/fixtures/cli-app/spec/spec_helper.rb +++ b/fixtures/cli-app/spec/spec_helper.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path("../lib", __dir__) +$LOAD_PATH.unshift File.expand_path('../lib', __dir__) -require "cli/app" +require 'cli/app' -require_relative "support/aruba" +require_relative 'support/aruba' -Dir.glob(File.expand_path("support/**/*.rb", __dir__)) +Dir.glob(File.expand_path('support/**/*.rb', __dir__)) .each { |f| require_relative f } diff --git a/fixtures/cli-app/spec/support/aruba.rb b/fixtures/cli-app/spec/support/aruba.rb index c3219676d..1b003d565 100644 --- a/fixtures/cli-app/spec/support/aruba.rb +++ b/fixtures/cli-app/spec/support/aruba.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require "aruba/rspec" +require 'aruba/rspec' diff --git a/fixtures/empty-app/Rakefile b/fixtures/empty-app/Rakefile index 5263b5839..7398a9005 100644 --- a/fixtures/empty-app/Rakefile +++ b/fixtures/empty-app/Rakefile @@ -1,3 +1,3 @@ # frozen_string_literal: true -require "bundler/gem_tasks" +require 'bundler/gem_tasks' diff --git a/fixtures/empty-app/cli-app.gemspec b/fixtures/empty-app/cli-app.gemspec index 511e69af2..9274e1ec0 100644 --- a/fixtures/empty-app/cli-app.gemspec +++ b/fixtures/empty-app/cli-app.gemspec @@ -1,28 +1,28 @@ # frozen_string_literal: true -lib = File.expand_path("lib", __dir__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "cli/app/version" +require 'cli/app/version' Gem::Specification.new do |spec| - spec.name = "cli-app" + spec.name = 'cli-app' spec.version = Cli::App::VERSION - spec.authors = ["Aruba Developers"] - spec.email = "cukes@googlegroups.com" + spec.authors = ['Aruba Developers'] + spec.email = 'cukes@googlegroups.com' - spec.summary = "Summary" - spec.description = "Description" - spec.homepage = "http://example.com" + spec.summary = 'Summary' + spec.description = 'Description' + spec.homepage = 'http://example.com' - spec.required_ruby_version = ">= 3.0" + spec.required_ruby_version = '>= 3.0' # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or # delete this section to allow pushing this gem to any host. - spec.files = Dir["lib/**/*", "README.md"] - spec.bindir = "exe" - spec.require_paths = ["lib"] + spec.files = Dir['lib/**/*', 'README.md'] + spec.bindir = 'exe' + spec.require_paths = ['lib'] - spec.add_development_dependency "bundler" - spec.add_development_dependency "rake" + spec.add_development_dependency 'bundler' + spec.add_development_dependency 'rake' end diff --git a/fixtures/empty-app/lib/cli/app.rb b/fixtures/empty-app/lib/cli/app.rb index 9c3e322b7..36bbcdecf 100644 --- a/fixtures/empty-app/lib/cli/app.rb +++ b/fixtures/empty-app/lib/cli/app.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "cli/app/version" +require 'cli/app/version' module Cli module App diff --git a/fixtures/empty-app/lib/cli/app/version.rb b/fixtures/empty-app/lib/cli/app/version.rb index 69e6983ae..140105bcc 100644 --- a/fixtures/empty-app/lib/cli/app/version.rb +++ b/fixtures/empty-app/lib/cli/app/version.rb @@ -2,6 +2,6 @@ module Cli module App - VERSION = "0.1.0" + VERSION = '0.1.0' end end diff --git a/fixtures/getting-started-app/Gemfile b/fixtures/getting-started-app/Gemfile index f0ad83604..0d514f27c 100644 --- a/fixtures/getting-started-app/Gemfile +++ b/fixtures/getting-started-app/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' -gem "aruba", path: File.expand_path("../../..", __dir__) -gem "cucumber" +gem 'aruba', path: File.expand_path('../../..', __dir__) +gem 'cucumber' diff --git a/fixtures/getting-started-app/features/support/env.rb b/fixtures/getting-started-app/features/support/env.rb index 25a3b5d1d..751674fc0 100644 --- a/fixtures/getting-started-app/features/support/env.rb +++ b/fixtures/getting-started-app/features/support/env.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require "aruba/cucumber" +require 'aruba/cucumber' diff --git a/gemfiles/cucumber_8.gemfile b/gemfiles/cucumber_8.gemfile index 1a63a295e..44f14e04f 100644 --- a/gemfiles/cucumber_8.gemfile +++ b/gemfiles/cucumber_8.gemfile @@ -2,8 +2,8 @@ # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "cucumber", "~> 8.0" +gem 'cucumber', '~> 8.0' -gemspec path: "../" +gemspec path: '../' diff --git a/gemfiles/cucumber_9.gemfile b/gemfiles/cucumber_9.gemfile index 99d460de6..08d1350c7 100644 --- a/gemfiles/cucumber_9.gemfile +++ b/gemfiles/cucumber_9.gemfile @@ -2,8 +2,8 @@ # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "cucumber", ["~> 9.0", ">= 9.0.1"] +gem 'cucumber', ['~> 9.0', '>= 9.0.1'] -gemspec path: "../" +gemspec path: '../' diff --git a/lib/aruba.rb b/lib/aruba.rb index e4afa9406..6967a9a5b 100644 --- a/lib/aruba.rb +++ b/lib/aruba.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require "aruba/api" +require 'aruba/api' diff --git a/lib/aruba/api.rb b/lib/aruba/api.rb index 1fc2b4299..8682d2bcd 100644 --- a/lib/aruba/api.rb +++ b/lib/aruba/api.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require "rspec/expectations" -require "shellwords" +require 'rspec/expectations' +require 'shellwords' -require "aruba/version" +require 'aruba/version' -require "aruba/platform" -require "aruba/api/core" -require "aruba/api/commands" +require 'aruba/platform' +require 'aruba/api/core' +require 'aruba/api/commands' -require "aruba/api/environment" -require "aruba/api/filesystem" -require "aruba/api/text" -require "aruba/api/bundler" +require 'aruba/api/environment' +require 'aruba/api/filesystem' +require 'aruba/api/text' +require 'aruba/api/bundler' -Aruba.platform.require_matching_files("../matchers/**/*.rb", __FILE__) +Aruba.platform.require_matching_files('../matchers/**/*.rb', __FILE__) # Aruba module Aruba diff --git a/lib/aruba/api/bundler.rb b/lib/aruba/api/bundler.rb index 50e4e2e0c..50982f246 100644 --- a/lib/aruba/api/bundler.rb +++ b/lib/aruba/api/bundler.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "aruba/api/environment" -require "bundler" +require 'aruba/api/environment' +require 'bundler' module Aruba module Api diff --git a/lib/aruba/api/commands.rb b/lib/aruba/api/commands.rb index 3273f3ca2..76be32723 100644 --- a/lib/aruba/api/commands.rb +++ b/lib/aruba/api/commands.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "pathname" +require 'pathname' -require "aruba/platform" -require "aruba/command" +require 'aruba/platform' +require 'aruba/command' # require 'win32/file' if File::ALT_SEPARATOR @@ -24,7 +24,7 @@ module Commands def which(program, path = nil) with_environment do # ENV is set within this block - path = ENV["PATH"] if path.nil? + path = ENV['PATH'] if path.nil? Aruba.platform.which(program, path) end @@ -37,7 +37,7 @@ def which(program, path = nil) def pipe_in_file(file_name) file_name = expand_path(file_name) - File.open(file_name, "r").each_line do |line| + File.open(file_name, 'r').each_line do |line| last_command_started.write(line) end end @@ -154,7 +154,7 @@ def run_command(cmd, opts = {}) unless command.interactive? raise NotImplementedError, - "Running interactively is not supported with this process launcher." + 'Running interactively is not supported with this process launcher.' end start_command(command) @@ -232,7 +232,7 @@ def prepare_command(cmd, opts) @commands << cmd environment = aruba.environment - working_directory = expand_path(".") + working_directory = expand_path('.') event_bus = aruba.event_bus cmd = Aruba.platform.detect_ruby(cmd) diff --git a/lib/aruba/api/core.rb b/lib/aruba/api/core.rb index 573d51291..06e785cb3 100644 --- a/lib/aruba/api/core.rb +++ b/lib/aruba/api/core.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "rspec/expectations" -require "aruba/runtime" -require "aruba/errors" -require "aruba/setup" +require 'rspec/expectations' +require 'aruba/runtime' +require 'aruba/errors' +require 'aruba/setup' # Aruba module Aruba @@ -40,8 +40,8 @@ def setup_aruba(clobber = true) # @yield # The block which should be run in current directory def in_current_directory(&block) - create_directory "." unless directory?(".") - cd(".", &block) + create_directory '.' unless directory?('.') + cd('.', &block) end # Switch to directory @@ -66,9 +66,9 @@ def cd(dir, &block) "#{expand_path(dir)} is not a directory or does not exist." end - old_directory = expand_path(".") + old_directory = expand_path('.') aruba.current_directory << dir - new_directory = expand_path(".") + new_directory = expand_path('.') aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory, new: new_directory) @@ -80,8 +80,8 @@ def cd(dir, &block) Aruba.platform.chdir real_new_directory result = with_environment( - "OLDPWD" => old_dir, - "PWD" => real_new_directory, + 'OLDPWD' => old_dir, + 'PWD' => real_new_directory, &block ) ensure @@ -96,9 +96,9 @@ def cd(dir, &block) raise ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." end - old_directory = expand_path(".") + old_directory = expand_path('.') aruba.current_directory << dir - new_directory = expand_path(".") + new_directory = expand_path('.') aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory, new: new_directory) @@ -146,9 +146,9 @@ def cd(dir, &block) def expand_path(file_name, dir_string = nil) unless file_name.is_a?(String) && !file_name.empty? message = "Filename #{file_name} needs to be a string." \ - " It cannot be nil or empty either." \ + ' It cannot be nil or empty either.' \ " Please use `expand_path('.')` if you want" \ - " the current directory to be expanded." + ' the current directory to be expanded.' raise ArgumentError, message end @@ -156,7 +156,7 @@ def expand_path(file_name, dir_string = nil) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory) raise "Aruba's working directory does not exist." \ - " Maybe you forgot to run `setup_aruba` before using its API." + ' Maybe you forgot to run `setup_aruba` before using its API.' end prefix = file_name[0] @@ -166,22 +166,22 @@ def expand_path(file_name, dir_string = nil) path = File.join(*[aruba.fixtures_directory, rest].compact) unless Aruba.platform.exist? path aruba_fixture_candidates = aruba.config.fixtures_directories - .map { |p| format('"%s"', p) }.join(", ") + .map { |p| format('"%s"', p) }.join(', ') raise ArgumentError, "Fixture \"#{rest}\" does not exist" \ " in fixtures directory \"#{aruba.fixtures_directory}\"." \ - " This was the one we found first on your system from all possible" \ + ' This was the one we found first on your system from all possible' \ " candidates: #{aruba_fixture_candidates}." end path - elsif prefix == "~" + elsif prefix == '~' path = with_environment do File.expand_path(file_name) end - raise ArgumentError, 'Expanding "~/" to "/" is not allowed' if path == "/" + raise ArgumentError, 'Expanding "~/" to "/" is not allowed' if path == '/' unless Aruba.platform.absolute_path? path raise ArgumentError, @@ -197,8 +197,8 @@ def expand_path(file_name, dir_string = nil) "Aruba's `expand_path` method was called with an absolute path" \ " at #{caller_file_line}, which is not recommended." \ " The path passed was '#{file_name}'." \ - " Change the call to pass a relative path or set" \ - " `config.allow_absolute_paths = true` to silence this warning" + ' Change the call to pass a relative path or set' \ + ' `config.allow_absolute_paths = true` to silence this warning' raise UserError, message end file_name diff --git a/lib/aruba/api/environment.rb b/lib/aruba/api/environment.rb index 42bf28bc8..fb9797c7e 100644 --- a/lib/aruba/api/environment.rb +++ b/lib/aruba/api/environment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/platform" +require 'aruba/platform' # Aruba module Aruba @@ -98,7 +98,7 @@ def delete_environment_variable(name) environment_change = { old: old_environment, new: new_environment, - changed: { name: name, value: "" } } + changed: { name: name, value: '' } } aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change) self diff --git a/lib/aruba/api/filesystem.rb b/lib/aruba/api/filesystem.rb index 4f2593be3..55505b734 100644 --- a/lib/aruba/api/filesystem.rb +++ b/lib/aruba/api/filesystem.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "pathname" +require 'pathname' -require "aruba/platform" +require 'aruba/platform' -Aruba.platform.require_matching_files("../matchers/file/*.rb", __FILE__) -Aruba.platform.require_matching_files("../matchers/directory/*.rb", __FILE__) -Aruba.platform.require_matching_files("../matchers/path/*.rb", __FILE__) +Aruba.platform.require_matching_files('../matchers/file/*.rb', __FILE__) +Aruba.platform.require_matching_files('../matchers/directory/*.rb', __FILE__) +Aruba.platform.require_matching_files('../matchers/path/*.rb', __FILE__) # Aruba module Aruba @@ -69,7 +69,7 @@ def relative?(path) # @return [Array] # List of files and directories def all_paths - list(".").map { |path| expand_path(path) } + list('.').map { |path| expand_path(path) } end # Return all existing files in current directory @@ -77,7 +77,7 @@ def all_paths # @return [Array] # List of files def all_files - list(".").select { |p| file? p }.map { |p| expand_path(p) } + list('.').select { |p| file? p }.map { |p| expand_path(p) } end # Return all existing directories in current directory @@ -85,7 +85,7 @@ def all_files # @return [Array] # List of files def all_directories - list(".").select { |p| directory? p }.map { |p| expand_path(p) } + list('.').select { |p| directory? p }.map { |p| expand_path(p) } end # Create directory object @@ -110,8 +110,8 @@ def list(name) %(Only directories are supported. Path "#{name}" is not a directory.) end - existing_files = Dir.glob(expand_path(File.join(name, "**", "*"))) - current_working_directory = Pathname.new(expand_path(".")) + existing_files = Dir.glob(expand_path(File.join(name, '**', '*'))) + current_working_directory = Pathname.new(expand_path('.')) existing_files.map do |d| Pathname.new(d).relative_path_from(current_working_directory).to_s @@ -193,7 +193,7 @@ def copy(*args) end if source.count > 1 && exist?(destination) && !directory?(destination) - raise ArgumentError, "Multiples sources can only be copied to a directory" + raise ArgumentError, 'Multiples sources can only be copied to a directory' end source_paths = source.map { |f| expand_path(f) } @@ -242,7 +242,7 @@ def move(*args) end if source.count > 1 && exist?(destination) && !directory?(destination) - raise ArgumentError, "Multiple sources can only be copied to a directory" + raise ArgumentError, 'Multiple sources can only be copied to a directory' end source_paths = source.map { |f| expand_path(f) } @@ -324,7 +324,7 @@ def chmod(*args) def append_to_file(file_name, file_content) file_name = expand_path(file_name) - File.open(file_name, "a") { |f| f << file_content } + File.open(file_name, 'a') { |f| f << file_content } end # Append lines to a (text) file. This will make sure a newline is present @@ -343,7 +343,7 @@ def append_lines_to_file(file_name, file_content) f.read end - File.open(file_name, "a") do |f| + File.open(file_name, 'a') do |f| f << "\n" unless last.end_with? "\n" f << file_content end diff --git a/lib/aruba/api/text.rb b/lib/aruba/api/text.rb index 9aa837578..efc14529e 100644 --- a/lib/aruba/api/text.rb +++ b/lib/aruba/api/text.rb @@ -32,9 +32,9 @@ def unescape_text(text) # Input def extract_text(text) text - .gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, "") - .gsub(/\\\[|\\\]/, "") - .gsub(/\007|\016|\017/, "") + .gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '') + .gsub(/\\\[|\\\]/, '') + .gsub(/\007|\016|\017/, '') end # Unescape special characters and remove ANSI characters diff --git a/lib/aruba/aruba_logger.rb b/lib/aruba/aruba_logger.rb index 4cc792ba8..2c20ed4a0 100644 --- a/lib/aruba/aruba_logger.rb +++ b/lib/aruba/aruba_logger.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "logger" +require 'logger' # Aruba module Aruba diff --git a/lib/aruba/aruba_path.rb b/lib/aruba/aruba_path.rb index d32af22de..51339cc07 100644 --- a/lib/aruba/aruba_path.rb +++ b/lib/aruba/aruba_path.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "pathname" +require 'pathname' # Aruba module Aruba @@ -59,7 +59,7 @@ def [](index) # Get path def to_pathname current_path = @obj.inject do |path, element| - if element.start_with?("~") || + if element.start_with?('~') || Aruba.platform.absolute_path?(element) element else diff --git a/lib/aruba/basic_configuration.rb b/lib/aruba/basic_configuration.rb index 2f2577412..fad62ba54 100644 --- a/lib/aruba/basic_configuration.rb +++ b/lib/aruba/basic_configuration.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require "contracts" -require "aruba/basic_configuration/option" -require "aruba/in_config_wrapper" +require 'contracts' +require 'aruba/basic_configuration/option' +require 'aruba/in_config_wrapper' # Aruba module Aruba @@ -28,7 +28,7 @@ def known_options # @option [Object] default # The default value def option_reader(name, type:, default: nil) - raise ArgumentError, "Either use block or default value" if block_given? && default + raise ArgumentError, 'Either use block or default value' if block_given? && default add_option(name, block_given? ? yield(InConfigWrapper.new(known_options)) : default) @@ -48,7 +48,7 @@ def option_reader(name, type:, default: nil) # The default value # def option_accessor(name, type:, default: nil) - raise ArgumentError, "Either use block or default value" if block_given? && default + raise ArgumentError, 'Either use block or default value' if block_given? && default # Add writer add_option(name, block_given? ? yield(InConfigWrapper.new(known_options)) : default) @@ -112,8 +112,8 @@ def make_copy # @yield # The code block which should be run. This is a configure time only option def before(name, &block) - name = format("%s_%s", "before_", name.to_s).to_sym - raise ArgumentError, "A block is required" unless block + name = format('%s_%s', 'before_', name.to_s).to_sym + raise ArgumentError, 'A block is required' unless block @hooks.append(name, block) @@ -131,7 +131,7 @@ def before(name, &block) # @param [Array] args # Arguments for the run of hook def run_before_hook(name, context, *args) - name = format("%s_%s", "before_", name.to_s).to_sym + name = format('%s_%s', 'before_', name.to_s).to_sym @hooks.execute(name, context, *args) end @@ -144,8 +144,8 @@ def run_before_hook(name, context, *args) # @yield # The code block which should be run. This is a configure time only option def after(name, &block) - name = format("%s_%s", "after_", name.to_s).to_sym - raise ArgumentError, "A block is required" unless block + name = format('%s_%s', 'after_', name.to_s).to_sym + raise ArgumentError, 'A block is required' unless block @hooks.append(name, block) @@ -163,7 +163,7 @@ def after(name, &block) # @param [Array] args # Arguments for the run of hook def run_after_hook(name, context, *args) - name = format("%s_%s", "after_", name.to_s).to_sym + name = format('%s_%s', 'after_', name.to_s).to_sym @hooks.execute(name, context, *args) end diff --git a/lib/aruba/cli.rb b/lib/aruba/cli.rb index 241229a35..0f381cf77 100644 --- a/lib/aruba/cli.rb +++ b/lib/aruba/cli.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require "thor" -require "aruba/console" -require "aruba/initializer" +require 'thor' +require 'aruba/console' +require 'aruba/initializer' # Aruba module Aruba @@ -14,16 +14,16 @@ def self.exit_on_failure? true end - desc "console", "Start aruba's console" + desc 'console', "Start aruba's console" def console Aruba::Console.new.start end - desc "init", "Initialize aruba" + desc 'init', 'Initialize aruba' option :test_framework, - default: "cucumber", + default: 'cucumber', enum: %w(cucumber rspec minitest), - desc: "Choose which test framework to use" + desc: 'Choose which test framework to use' def init Aruba::Initializer.new.call(options[:test_framework]) end diff --git a/lib/aruba/command.rb b/lib/aruba/command.rb index e60db47d8..5cceb37fb 100644 --- a/lib/aruba/command.rb +++ b/lib/aruba/command.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "delegate" -require "aruba/processes/spawn_process" -require "aruba/processes/in_process" -require "aruba/processes/debug_process" +require 'delegate' +require 'aruba/processes/spawn_process' +require 'aruba/processes/in_process' +require 'aruba/processes/debug_process' # Aruba module Aruba diff --git a/lib/aruba/command_monitor.rb b/lib/aruba/command_monitor.rb index 2ac19e5a0..ead4f01d6 100644 --- a/lib/aruba/command_monitor.rb +++ b/lib/aruba/command_monitor.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/errors" +require 'aruba/errors' # Aruba module Aruba @@ -22,7 +22,7 @@ def empty? end def method_missing(*) - raise NoCommandHasBeenStoppedError, "No last command stopped available" + raise NoCommandHasBeenStoppedError, 'No last command stopped available' end def respond_to_missing?(*) @@ -36,7 +36,7 @@ def empty? end def method_missing(*) - raise NoCommandHasBeenStartedError, "No last command started available" + raise NoCommandHasBeenStartedError, 'No last command started available' end def respond_to_missing?(*) diff --git a/lib/aruba/config/jruby.rb b/lib/aruba/config/jruby.rb index 86fc597b8..c7d1024fc 100644 --- a/lib/aruba/config/jruby.rb +++ b/lib/aruba/config/jruby.rb @@ -1,29 +1,29 @@ # frozen_string_literal: true -require "rbconfig" +require 'rbconfig' # ideas taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html Aruba.configure do |config| config.before :command do |command| - next unless RUBY_PLATFORM == "java" + next unless RUBY_PLATFORM == 'java' env = command.environment - jruby_opts = env["JRUBY_OPTS"] || "" + jruby_opts = env['JRUBY_OPTS'] || '' # disable JIT since these processes are so short lived - jruby_opts = "-X-C #{jruby_opts}" unless jruby_opts.include? "-X-C" + jruby_opts = "-X-C #{jruby_opts}" unless jruby_opts.include? '-X-C' # Faster startup for jruby - jruby_opts = "--dev #{jruby_opts}" unless jruby_opts.include? "--dev" + jruby_opts = "--dev #{jruby_opts}" unless jruby_opts.include? '--dev' - env["JRUBY_OPTS"] = jruby_opts + env['JRUBY_OPTS'] = jruby_opts - if /solaris|sunos/i.match?(RbConfig::CONFIG["host_os"]) - java_opts = env["JAVA_OPTS"] || "" + if /solaris|sunos/i.match?(RbConfig::CONFIG['host_os']) + java_opts = env['JAVA_OPTS'] || '' # force jRuby to use client JVM for faster startup times - env["JAVA_OPTS"] = "-d32 #{java_opts}" unless java_opts.include?("-d32") + env['JAVA_OPTS'] = "-d32 #{java_opts}" unless java_opts.include?('-d32') end end end diff --git a/lib/aruba/config_wrapper.rb b/lib/aruba/config_wrapper.rb index 492bdfd91..806110006 100644 --- a/lib/aruba/config_wrapper.rb +++ b/lib/aruba/config_wrapper.rb @@ -32,7 +32,7 @@ def initialize(config, event_bus) # If one method ends with "=", e.g. ":option1=", then notify the event # queue, that the user changes the value of "option1" def method_missing(name, *args, &block) - notify(name, args) if name.to_s.end_with?("=") + notify(name, args) if name.to_s.end_with?('=') return config.send(name, *args, &block) if config.respond_to? name @@ -65,7 +65,7 @@ def notify(name, args) event_bus.notify( Events::ChangedConfiguration.new( changed: { - name: name.to_s.gsub(/=$/, ""), + name: name.to_s.gsub(/=$/, ''), value: args.first } ) diff --git a/lib/aruba/configuration.rb b/lib/aruba/configuration.rb index 61f985b49..027d162e7 100644 --- a/lib/aruba/configuration.rb +++ b/lib/aruba/configuration.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -require "contracts" +require 'contracts' -require "aruba/version" -require "aruba/basic_configuration" -require "aruba/in_config_wrapper" -require "aruba/hooks" +require 'aruba/version' +require 'aruba/basic_configuration' +require 'aruba/in_config_wrapper' +require 'aruba/hooks' -require "aruba/contracts/relative_path" -require "aruba/contracts/absolute_path" -require "aruba/contracts/enum" +require 'aruba/contracts/relative_path' +require 'aruba/contracts/absolute_path' +require 'aruba/contracts/enum' -require "aruba/contracts/is_power_of_two" +require 'aruba/contracts/is_power_of_two' # Aruba module Aruba @@ -23,9 +23,9 @@ class Configuration < BasicConfiguration option_accessor :working_directory, type: Aruba::Contracts::RelativePath, - default: "tmp/aruba" + default: 'tmp/aruba' - option_reader :fixtures_path_prefix, type: String, default: "%" + option_reader :fixtures_path_prefix, type: String, default: '%' option_accessor :exit_timeout, type: Num, default: 15 option_accessor :stop_signal, type: Maybe[String], default: nil @@ -38,8 +38,8 @@ class Configuration < BasicConfiguration option_accessor :command_runtime_environment, type: Hash, default: {} option_accessor :command_search_paths, type: ArrayOf[String] do |config| - [File.join(config.root_directory.value, "bin"), - File.join(config.root_directory.value, "exe")] + [File.join(config.root_directory.value, 'bin'), + File.join(config.root_directory.value, 'exe')] end option_accessor :remove_ansi_escape_sequences, type: Bool, default: true option_accessor :command_launcher, @@ -66,7 +66,7 @@ class Configuration < BasicConfiguration type: Aruba::Contracts::IsPowerOfTwo, default: 512 option_accessor :console_history_file, type: String, - default: "~/.aruba_history" + default: '~/.aruba_history' option_accessor :activate_announcer_on_command_failure, type: ArrayOf[Symbol], diff --git a/lib/aruba/console.rb b/lib/aruba/console.rb index 0f44bcaaf..15885c54c 100644 --- a/lib/aruba/console.rb +++ b/lib/aruba/console.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "irb" +require 'irb' -require "aruba/api" -require "aruba/console/help" +require 'aruba/api' +require 'aruba/console/help' # Aruba module Aruba @@ -17,20 +17,20 @@ def start ARGV.clear IRB.setup nil - IRB.conf[:IRB_NAME] = "aruba" + IRB.conf[:IRB_NAME] = 'aruba' IRB.conf[:PROMPT] = {} IRB.conf[:PROMPT][:ARUBA] = { - PROMPT_I: "%N:%03n:%i> ", - PROMPT_S: "%N:%03n:%i%l ", - PROMPT_C: "%N:%03n:%i* ", + PROMPT_I: '%N:%03n:%i> ', + PROMPT_S: '%N:%03n:%i%l ', + PROMPT_C: '%N:%03n:%i* ', RETURN: "# => %s\n" } IRB.conf[:PROMPT_MODE] = :ARUBA IRB.conf[:RC] = false - require "irb/completion" + require 'irb/completion' IRB.conf[:READLINE] = true IRB.conf[:SAVE_HISTORY] = 1000 IRB.conf[:HISTORY_FILE] = Aruba.config.console_history_file @@ -44,14 +44,14 @@ def initialize end def inspect - "aruba console" + 'aruba console' end end irb = IRB::Irb.new(IRB::WorkSpace.new(context.new)) IRB.conf[:MAIN_CONTEXT] = irb.context - trap("SIGINT") do + trap('SIGINT') do irb.signal_handle end diff --git a/lib/aruba/console/help.rb b/lib/aruba/console/help.rb index 052bf8cc7..7849070e0 100644 --- a/lib/aruba/console/help.rb +++ b/lib/aruba/console/help.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/api" +require 'aruba/api' # Aruba module Aruba @@ -11,9 +11,9 @@ module Help # Output help information def aruba_help puts "Aruba Version: #{Aruba::VERSION}" - puts "Issue Tracker: https://github.com/cucumber/aruba/issues" - puts "Documentation:" - puts "* http://www.rubydoc.info/gems/aruba" + puts 'Issue Tracker: https://github.com/cucumber/aruba/issues' + puts 'Documentation:' + puts '* http://www.rubydoc.info/gems/aruba' puts nil @@ -22,7 +22,7 @@ def aruba_help # List available methods in aruba def aruba_methods ms = (Aruba::Api.instance_methods - Module.instance_methods) - .each_with_object([]) { |e, a| a << format("* %s", e) } + .each_with_object([]) { |e, a| a << format('* %s', e) } .sort puts "Available Methods:\n#{ms.join("\n")}" diff --git a/lib/aruba/contracts/absolute_path.rb b/lib/aruba/contracts/absolute_path.rb index a72c06382..ef3ece35b 100644 --- a/lib/aruba/contracts/absolute_path.rb +++ b/lib/aruba/contracts/absolute_path.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/platform" +require 'aruba/platform' # Aruba module Aruba diff --git a/lib/aruba/contracts/enum.rb b/lib/aruba/contracts/enum.rb index 044478334..24737e55c 100644 --- a/lib/aruba/contracts/enum.rb +++ b/lib/aruba/contracts/enum.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "contracts" +require 'contracts' # Aruba module Aruba diff --git a/lib/aruba/contracts/is_power_of_two.rb b/lib/aruba/contracts/is_power_of_two.rb index 13864ca9b..adfd739e6 100644 --- a/lib/aruba/contracts/is_power_of_two.rb +++ b/lib/aruba/contracts/is_power_of_two.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/aruba_path" +require 'aruba/aruba_path' # Aruba module Aruba diff --git a/lib/aruba/contracts/relative_path.rb b/lib/aruba/contracts/relative_path.rb index 034111740..358512c61 100644 --- a/lib/aruba/contracts/relative_path.rb +++ b/lib/aruba/contracts/relative_path.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/platform" +require 'aruba/platform' # Aruba module Aruba diff --git a/lib/aruba/cucumber.rb b/lib/aruba/cucumber.rb index e179847f7..7d606d9f3 100644 --- a/lib/aruba/cucumber.rb +++ b/lib/aruba/cucumber.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require "aruba/version" +require 'aruba/version' -require "aruba/api" -require "aruba/cucumber/hooks" -require "aruba/cucumber/parameter_types" -require "aruba/cucumber/command" -require "aruba/cucumber/environment" -require "aruba/cucumber/file" -require "aruba/cucumber/testing_frameworks" +require 'aruba/api' +require 'aruba/cucumber/hooks' +require 'aruba/cucumber/parameter_types' +require 'aruba/cucumber/command' +require 'aruba/cucumber/environment' +require 'aruba/cucumber/file' +require 'aruba/cucumber/testing_frameworks' diff --git a/lib/aruba/cucumber/command.rb b/lib/aruba/cucumber/command.rb index a06bb2754..619ebad13 100644 --- a/lib/aruba/cucumber/command.rb +++ b/lib/aruba/cucumber/command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/generators/script_file" +require 'aruba/generators/script_file' When(/^I run `([^`]*)`$/) do |cmd| cmd = sanitize_text(cmd) @@ -16,9 +16,9 @@ When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) \ do |shell, commands| - full_path = expand_path("bin/myscript") + full_path = expand_path('bin/myscript') - Aruba.platform.mkdir(expand_path("bin")) + Aruba.platform.mkdir(expand_path('bin')) shell ||= Aruba.platform.default_shell Aruba::ScriptFile.new(interpreter: shell, content: commands, path: full_path).call @@ -34,33 +34,33 @@ run_command(sanitize_text(cmd)) end -When "I type {string}" do |input| +When 'I type {string}' do |input| type(unescape_text(input)) end -When "I close the stdin stream" do +When 'I close the stdin stream' do close_input end -When "I pipe in a/the file( named) {string}" do |file| +When 'I pipe in a/the file( named) {string}' do |file| pipe_in_file(file) close_input end -When "I stop the command started last" do +When 'I stop the command started last' do last_command_started.stop end -When "I stop the command {string}" do |command| +When 'I stop the command {string}' do |command| aruba.command_monitor.find(command).stop end -When "I terminate the command started last" do +When 'I terminate the command started last' do last_command_started.terminate end -When "I terminate the command {string}" do |command| +When 'I terminate the command {string}' do |command| aruba.command_monitor.find(command).terminate end @@ -87,7 +87,7 @@ last_command_started.terminate end -When "I wait for output/stdout to contain:" do |expected| +When 'I wait for output/stdout to contain:' do |expected| Timeout.timeout(aruba.config.exit_timeout) do loop do output = last_command_started.stdout wait_for_io: 0 @@ -102,7 +102,7 @@ end end -When "I wait for output/stdout to contain {string}" do |expected| +When 'I wait for output/stdout to contain {string}' do |expected| Timeout.timeout(aruba.config.exit_timeout) do loop do output = last_command_started.stdout wait_for_io: 0 @@ -117,44 +117,44 @@ end end -Then "the output should be {int} bytes long" do |size| +Then 'the output should be {int} bytes long' do |size| expect(last_command_started).to have_output_size size.to_i end ## the stderr should contain "hello" -Then "(the ){channel} should contain {string}" do |channel, expected| +Then '(the ){channel} should contain {string}' do |channel, expected| combined_output = send(:"all_#{channel}") expect(combined_output).to include_output_string expected end ## the stderr should not contain "hello" -Then "(the ){channel} should not contain {string}" do |channel, expected| +Then '(the ){channel} should not contain {string}' do |channel, expected| combined_output = send(:"all_#{channel}") expect(combined_output).not_to include_output_string expected end ## the stderr should contain exactly "hello" -Then "(the ){channel} should contain exactly {string}" do |channel, expected| +Then '(the ){channel} should contain exactly {string}' do |channel, expected| combined_output = send(:"all_#{channel}") expect(combined_output).to output_string_eq expected end ## the stderr should not contain exactly "hello" -Then "(the ){channel} should not contain exactly {string}" do |channel, expected| +Then '(the ){channel} should not contain exactly {string}' do |channel, expected| combined_output = send(:"all_#{channel}") expect(combined_output).not_to output_string_eq expected end ## the stderr from "echo -n 'Hello'" should contain "hello" -Then "(the ){channel} from {string} should contain {string}" do |channel, cmd, expected| +Then '(the ){channel} from {string} should contain {string}' do |channel, cmd, expected| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)) @@ -165,12 +165,12 @@ end ## the stderr from "echo -n 'Hello'" should contain exactly "hello" -Then "(the ){channel} from {string} should contain exactly {string}" \ +Then '(the ){channel} from {string} should contain exactly {string}' \ do |channel, cmd, expected| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)) @@ -181,11 +181,11 @@ end ## the stderr from "echo -n 'Hello'" should not contain "hello" -Then "(the ){channel} from {string} should not contain {string}" do |channel, cmd, expected| +Then '(the ){channel} from {string} should not contain {string}' do |channel, cmd, expected| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)) @@ -196,12 +196,12 @@ end ## the stderr from "echo -n 'Hello'" should not contain exactly "hello" -Then "(the ){channel} from {string} should not contain exactly {string}" \ +Then '(the ){channel} from {string} should not contain exactly {string}' \ do |channel, cmd, expected| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)) @@ -212,39 +212,39 @@ end ## the stderr should contain: -Then "(the ){channel} should contain:" do |channel, expected| +Then '(the ){channel} should contain:' do |channel, expected| combined_output = send(:"all_#{channel}") expect(combined_output).to include_output_string(expected) end ## the stderr should not contain: -Then "(the ){channel} should not contain:" do |channel, expected| +Then '(the ){channel} should not contain:' do |channel, expected| combined_output = send(:"all_#{channel}") expect(combined_output).not_to include_output_string(expected) end ## the stderr should contain exactly: -Then "(the ){channel} should contain exactly:" do |channel, expected| +Then '(the ){channel} should contain exactly:' do |channel, expected| combined_output = send(:"all_#{channel}") expect(combined_output).to output_string_eq(expected) end ## the stderr should not contain exactly: -Then "(the ){channel} should not contain exactly:" do |channel, expected| +Then '(the ){channel} should not contain exactly:' do |channel, expected| combined_output = send(:"all_#{channel}") expect(combined_output).not_to output_string_eq(expected) end ## the stderr from "echo -n 'Hello'" should not contain: -Then "(the ){channel} from {string} should not contain:" do |channel, cmd, expected| +Then '(the ){channel} from {string} should not contain:' do |channel, cmd, expected| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)) @@ -255,11 +255,11 @@ end ## the stderr from "echo -n 'Hello'" should not contain exactly: -Then "(the ){channel} from {string} should not contain exactly:" do |channel, cmd, expected| +Then '(the ){channel} from {string} should not contain exactly:' do |channel, cmd, expected| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)) @@ -270,11 +270,11 @@ end ## the stderr from "echo -n 'Hello'" should contain: -Then "(the ){channel} from {string} should contain:" do |channel, cmd, expected| +Then '(the ){channel} from {string} should contain:' do |channel, cmd, expected| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)) @@ -285,11 +285,11 @@ end ## the stderr from "echo -n 'Hello'" should contain exactly: -Then "(the ){channel} from {string} should contain exactly:" do |channel, cmd, expected| +Then '(the ){channel} from {string} should contain exactly:' do |channel, cmd, expected| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)) @@ -346,7 +346,7 @@ Then(/^it should not (pass|fail) with "(.*?)"$/) do |pass_fail, expected| last_command_started.stop - if pass_fail == "pass" + if pass_fail == 'pass' expect(last_command_stopped).to be_successfully_executed else expect(last_command_stopped).not_to be_successfully_executed @@ -358,7 +358,7 @@ Then(/^it should (pass|fail) with "(.*?)"$/) do |pass_fail, expected| last_command_started.stop - if pass_fail == "pass" + if pass_fail == 'pass' expect(last_command_stopped).to be_successfully_executed else expect(last_command_stopped).not_to be_successfully_executed @@ -370,7 +370,7 @@ Then(/^it should not (pass|fail) with:$/) do |pass_fail, expected| last_command_started.stop - if pass_fail == "pass" + if pass_fail == 'pass' expect(last_command_stopped).to be_successfully_executed else expect(last_command_stopped).not_to be_successfully_executed @@ -382,7 +382,7 @@ Then(/^it should (pass|fail) with:$/) do |pass_fail, expected| last_command_started.stop - if pass_fail == "pass" + if pass_fail == 'pass' expect(last_command_stopped).to be_successfully_executed else expect(last_command_stopped).not_to be_successfully_executed @@ -394,7 +394,7 @@ Then(/^it should not (pass|fail) with exactly:$/) do |pass_fail, expected| last_command_started.stop - if pass_fail == "pass" + if pass_fail == 'pass' expect(last_command_stopped).to be_successfully_executed else expect(last_command_stopped).not_to be_successfully_executed @@ -406,7 +406,7 @@ Then(/^it should (pass|fail) with exactly:$/) do |pass_fail, expected| last_command_started.stop - if pass_fail == "pass" + if pass_fail == 'pass' expect(last_command_stopped).to be_successfully_executed else expect(last_command_stopped).not_to be_successfully_executed @@ -418,7 +418,7 @@ Then(/^it should not (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected| last_command_started.stop - if pass_fail == "pass" + if pass_fail == 'pass' expect(last_command_stopped).to be_successfully_executed else expect(last_command_stopped).not_to be_successfully_executed @@ -430,7 +430,7 @@ Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected| last_command_started.stop - if pass_fail == "pass" + if pass_fail == 'pass' expect(last_command_stopped).to be_successfully_executed else expect(last_command_stopped).not_to be_successfully_executed @@ -441,9 +441,9 @@ Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel| matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end expect(all_commands).to include send(matcher, be_nil.or(be_empty)) @@ -453,9 +453,9 @@ do |channel, negated, table| table.raw.flatten.each do |expected| _matcher = case channel - when "output"; then :have_output - when "stderr"; then :have_output_on_stderr - when "stdout"; then :have_output_on_stdout + when 'output'; then :have_output + when 'stderr'; then :have_output_on_stderr + when 'stdout'; then :have_output_on_stdout end # TODO: This isn't actually using the above. It's hardcoded to use have_output only @@ -478,7 +478,7 @@ aruba.config.exit_timeout = seconds.to_f end -Given "the( default) aruba stop signal is {string}" do |signal| +Given 'the( default) aruba stop signal is {string}' do |signal| aruba.config.stop_signal = signal end @@ -486,17 +486,17 @@ aruba.config.startup_wait_time = seconds.to_f end -When "I send the signal {string} to the command {string}" do |signal, command| +When 'I send the signal {string} to the command {string}' do |signal, command| cmd = all_commands.find { |c| c.commandline == command } raise ArgumentError, %(No command "#{command}" found) if cmd.nil? cmd.send_signal signal end -When "I send the signal {string} to the command started last" do |signal| +When 'I send the signal {string} to the command started last' do |signal| last_command_started.send_signal signal end -Given "I look for executables in {string} within the current directory" do |directory| - prepend_environment_variable "PATH", expand_path(directory) + File::PATH_SEPARATOR +Given 'I look for executables in {string} within the current directory' do |directory| + prepend_environment_variable 'PATH', expand_path(directory) + File::PATH_SEPARATOR end diff --git a/lib/aruba/cucumber/environment.rb b/lib/aruba/cucumber/environment.rb index db82fb63b..0bd67bb55 100644 --- a/lib/aruba/cucumber/environment.rb +++ b/lib/aruba/cucumber/environment.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Given(/^a mocked home directory$/) do - set_environment_variable "HOME", expand_path(".") + set_environment_variable 'HOME', expand_path('.') end Given(/^I set the environment variable "(.*)" to "(.*)"/) do |variable, value| @@ -18,8 +18,8 @@ Given(/^I set the environment variables? to:/) do |table| table.hashes.each do |row| - variable = row["variable"].to_s - value = row["value"].to_s + variable = row['variable'].to_s + value = row['value'].to_s set_environment_variable(variable, value) end @@ -27,8 +27,8 @@ Given(/^I append the values? to the environment variables?:/) do |table| table.hashes.each do |row| - variable = row["variable"].to_s - value = row["value"].to_s + variable = row['variable'].to_s + value = row['value'].to_s append_environment_variable(variable, value) end @@ -36,8 +36,8 @@ Given(/^I prepend the values? to the environment variables?:/) do |table| table.hashes.each do |row| - variable = row["variable"].to_s - value = row["value"].to_s + variable = row['variable'].to_s + value = row['value'].to_s prepend_environment_variable(variable, value) end diff --git a/lib/aruba/cucumber/file.rb b/lib/aruba/cucumber/file.rb index cf0d6be3c..ac96f2d42 100644 --- a/lib/aruba/cucumber/file.rb +++ b/lib/aruba/cucumber/file.rb @@ -48,12 +48,12 @@ end Given(/^(?:an|the) empty file(?: named)? "([^"]*)"$/) do |file_name| - write_file(file_name, "") + write_file(file_name, '') end Given(/^(?:an|the) empty file(?: named)? "([^"]*)" with mode "([^"]*)"$/) \ do |file_name, file_mode| - write_file(file_name, "") + write_file(file_name, '') chmod(file_mode, file_name) end diff --git a/lib/aruba/cucumber/hooks.rb b/lib/aruba/cucumber/hooks.rb index 54f5eb804..ec124c089 100644 --- a/lib/aruba/cucumber/hooks.rb +++ b/lib/aruba/cucumber/hooks.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require "aruba/aruba_path" -require "aruba/api" -require "aruba/platform" +require 'aruba/aruba_path' +require 'aruba/api' +require 'aruba/platform' World(Aruba::Api) Around do |_, block| @@ -12,10 +12,10 @@ Before do # ... so every change needs to be done later prepend_environment_variable( - "PATH", + 'PATH', aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR ) - set_environment_variable "HOME", aruba.config.home_directory + set_environment_variable 'HOME', aruba.config.home_directory end After do @@ -23,68 +23,68 @@ aruba.command_monitor.clear end -Before("@no-clobber") do +Before('@no-clobber') do setup_aruba(false) end -Before("~@no-clobber") do +Before('~@no-clobber') do setup_aruba end -Before("@puts") do +Before('@puts') do aruba.announcer.mode = :puts end -Before("@announce-command") do +Before('@announce-command') do aruba.announcer.activate :command end -Before("@announce-command-content") do +Before('@announce-command-content') do aruba.announcer.activate :command_content end -Before("@announce-command-filesystem-status") do +Before('@announce-command-filesystem-status') do aruba.announcer.activate :command_filesystem_status end -Before("@announce-output") do +Before('@announce-output') do aruba.announcer.activate :stdout aruba.announcer.activate :stderr end -Before("@announce-stdout") do +Before('@announce-stdout') do aruba.announcer.activate :stdout end -Before("@announce-stderr") do +Before('@announce-stderr') do aruba.announcer.activate :stderr end -Before("@announce-directory") do +Before('@announce-directory') do aruba.announcer.activate :directory end -Before("@announce-stop-signal") do +Before('@announce-stop-signal') do aruba.announcer.activate :stop_signal end -Before("@announce-full-environment") do +Before('@announce-full-environment') do aruba.announcer.activate :full_environment end -Before("@announce-changed-environment") do +Before('@announce-changed-environment') do aruba.announcer.activate :changed_environment end -Before("@announce-timeout") do +Before('@announce-timeout') do aruba.announcer.activate :timeout end -Before("@announce-wait-time") do +Before('@announce-wait-time') do aruba.announcer.activate :wait_time end -Before("@announce") do +Before('@announce') do aruba.announcer.activate :changed_environment aruba.announcer.activate :command aruba.announcer.activate :directory @@ -100,30 +100,30 @@ aruba.announcer.activate :command_filesystem_status end -Before("@keep-ansi-escape-sequences") do +Before('@keep-ansi-escape-sequences') do aruba.config.remove_ansi_escape_sequences = false end -Before "@mocked-home-directory" do - set_environment_variable "HOME", expand_path(".") +Before '@mocked-home-directory' do + set_environment_variable 'HOME', expand_path('.') end -Before("@disable-bundler") do +Before('@disable-bundler') do unset_bundler_env_vars end -Before("@debug") do +Before('@debug') do aruba.config.command_launcher = :debug end -Before("@command-launcher-spawn") do +Before('@command-launcher-spawn') do aruba.config.command_launcher = :spawn end -Before("@command-launcher-in-process") do +Before('@command-launcher-in-process') do aruba.config.command_launcher = :in_process end -Before("@command-launcher-debug") do +Before('@command-launcher-debug') do aruba.config.command_launcher = :debug end diff --git a/lib/aruba/cucumber/parameter_types.rb b/lib/aruba/cucumber/parameter_types.rb index e11ff543b..5680893b4 100644 --- a/lib/aruba/cucumber/parameter_types.rb +++ b/lib/aruba/cucumber/parameter_types.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -ParameterType(name: "channel", regexp: "output|stderr|stdout", transformer: ->(name) { name }) +ParameterType(name: 'channel', regexp: 'output|stderr|stdout', transformer: ->(name) { name }) diff --git a/lib/aruba/cucumber/testing_frameworks.rb b/lib/aruba/cucumber/testing_frameworks.rb index ded7cd1a5..5016893f9 100644 --- a/lib/aruba/cucumber/testing_frameworks.rb +++ b/lib/aruba/cucumber/testing_frameworks.rb @@ -3,25 +3,25 @@ # Cucumber Then(/^the feature(?:s)? should not(?: all)? pass$/) do step 'the output should contain " failed)"' - step "the exit status should be 1" + step 'the exit status should be 1' end # Cucumber 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" + step 'the exit status should be 0' end # Cucumber 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" + step 'the exit status should be 1' if regex step "the output should match %r<#{string}>" else - step "the output should contain:", string + step 'the output should contain:', string end end @@ -29,12 +29,12 @@ 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" + step 'the exit status should be 0' if regex step "the output should match %r<#{string}>" else - step "the output should contain:", string + step 'the output should contain:', string end end @@ -47,36 +47,36 @@ step %(the output should contain "#{count_failures} failures") end - step "the exit status should be 1" + step 'the exit status should be 1' end # RSpec Then(/^the spec(?:s)? should all pass$/) do step 'the output should contain "0 failures"' - step "the exit status should be 0" + step 'the exit status should be 0' end # RSpec 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" + step 'the exit status should be 1' if regex step "the output should match %r<#{string}>" else - step "the output should contain:", string + step 'the output should contain:', string end end # RSpec 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" + step 'the exit status should be 0' if regex step "the output should match %r<#{string}>" else - step "the output should contain:", string + step 'the output should contain:', string end end @@ -89,35 +89,35 @@ step %(the output should contain "#{count_failures} errors") end - step "the exit status should be 1" + step 'the exit status should be 1' end # Minitest Then(/^the tests(?:s)? should all pass$/) do step 'the output should contain "0 errors"' - step "the exit status should be 0" + step 'the exit status should be 0' end # Minitest 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" + step 'the exit status should be 1' if regex step "the output should match %r<#{string}>" else - step "the output should contain:", string + step 'the output should contain:', string end end # Minitest 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" + step 'the exit status should be 0' if regex step "the output should match %r<#{string}>" else - step "the output should contain:", string + step 'the output should contain:', string end end diff --git a/lib/aruba/event_bus.rb b/lib/aruba/event_bus.rb index 069aa6574..b8f9cf749 100644 --- a/lib/aruba/event_bus.rb +++ b/lib/aruba/event_bus.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "cucumber/core/event_bus" +require 'cucumber/core/event_bus' module Aruba # Event bus diff --git a/lib/aruba/events.rb b/lib/aruba/events.rb index 6ee270fea..99e2cad7f 100644 --- a/lib/aruba/events.rb +++ b/lib/aruba/events.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "cucumber/core/event" +require 'cucumber/core/event' # Aruba module Aruba diff --git a/lib/aruba/file_size.rb b/lib/aruba/file_size.rb index 5b0a7f7e4..52eab2303 100644 --- a/lib/aruba/file_size.rb +++ b/lib/aruba/file_size.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "delegate" +require 'delegate' # Aruba module Aruba diff --git a/lib/aruba/generators/script_file.rb b/lib/aruba/generators/script_file.rb index 3c4cc5bb1..e8a5a0783 100644 --- a/lib/aruba/generators/script_file.rb +++ b/lib/aruba/generators/script_file.rb @@ -25,7 +25,7 @@ def call def header if script_starts_with_shebang? - "" + '' elsif interpreter_is_absolute_path? format("#!%s\n", interpreter) elsif interpreter_is_just_the_name_of_shell? @@ -42,7 +42,7 @@ def interpreter_is_just_the_name_of_shell? end def script_starts_with_shebang? - content.start_with? "#!" + content.start_with? '#!' end end end diff --git a/lib/aruba/in_config_wrapper.rb b/lib/aruba/in_config_wrapper.rb index 49b447473..87e385c8e 100644 --- a/lib/aruba/in_config_wrapper.rb +++ b/lib/aruba/in_config_wrapper.rb @@ -18,7 +18,7 @@ def initialize(config) def method_missing(name, *args) if config.key? name - raise ArgumentError, "Options take no argument" if args.any? + raise ArgumentError, 'Options take no argument' if args.any? config[name] else diff --git a/lib/aruba/initializer.rb b/lib/aruba/initializer.rb index 1a816e493..0f0ddbe7d 100644 --- a/lib/aruba/initializer.rb +++ b/lib/aruba/initializer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "thor/group" -require "thor/actions" +require 'thor/group' +require 'thor/actions' # Aruba module Aruba @@ -18,7 +18,7 @@ class CommonInitializer < Thor::Group # Add gem to gemfile def add_gem - file = "Gemfile" + file = 'Gemfile' creator = if File.exist? file :append_to_file else @@ -27,9 +27,9 @@ def add_gem content = if File.exist? file file_ends_with_carriage_return = - File.open(file, "r").readlines.last.match(/.*\n$/) + File.open(file, 'r').readlines.last.match(/.*\n$/) - prefix = file_ends_with_carriage_return ? "" : "\n" + prefix = file_ends_with_carriage_return ? '' : "\n" %(#{prefix}gem 'aruba', '~> #{Aruba::VERSION}') else @@ -71,7 +71,7 @@ def self.match?(framework) end def create_helper - file = "spec/spec_helper.rb" + file = 'spec/spec_helper.rb' creator = if File.exist? file :append_to_file else @@ -87,7 +87,7 @@ def create_helper end def create_support_file - create_file "spec/support/aruba.rb", <<~EOS + create_file 'spec/support/aruba.rb', <<~EOS require 'aruba/rspec' EOS end @@ -107,7 +107,7 @@ def self.match?(framework) end def create_support_file - create_file "features/support/aruba.rb", <<~EOS + create_file 'features/support/aruba.rb', <<~EOS require 'aruba/cucumber' EOS end @@ -127,7 +127,7 @@ def self.match?(framework) end def create_helper - file = "test/test_helper.rb" + file = 'test/test_helper.rb' creator = if File.exist? file :append_to_file else @@ -143,7 +143,7 @@ def create_helper end def create_example - create_file "test/use_aruba_with_minitest.rb", <<~EOS + create_file 'test/use_aruba_with_minitest.rb', <<~EOS $LOAD_PATH.unshift File.expand_path('../test', __FILE__) require 'test_helper' diff --git a/lib/aruba/matchers/base/message_indenter.rb b/lib/aruba/matchers/base/message_indenter.rb index 91dd50731..51e648785 100644 --- a/lib/aruba/matchers/base/message_indenter.rb +++ b/lib/aruba/matchers/base/message_indenter.rb @@ -10,7 +10,7 @@ module MessageIndenter module_function def indent_multiline_message(message) - message = message.sub(/\n+\z/, "") + message = message.sub(/\n+\z/, '') message.lines.map do |line| /\S/.match?(line) ? " #{line}" : line end.join diff --git a/lib/aruba/matchers/command.rb b/lib/aruba/matchers/command.rb index 0ce27b869..8d69362aa 100644 --- a/lib/aruba/matchers/command.rb +++ b/lib/aruba/matchers/command.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -Aruba.platform.require_matching_files("../command/**/*.rb", __FILE__) +Aruba.platform.require_matching_files('../command/**/*.rb', __FILE__) diff --git a/lib/aruba/matchers/command/be_successfully_executed.rb b/lib/aruba/matchers/command/be_successfully_executed.rb index f746dd59b..d794ce228 100644 --- a/lib/aruba/matchers/command/be_successfully_executed.rb +++ b/lib/aruba/matchers/command/be_successfully_executed.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "aruba/matchers/command/have_exit_status" -require "aruba/matchers/command/have_finished_in_time" +require 'aruba/matchers/command/have_exit_status' +require 'aruba/matchers/command/have_finished_in_time' # @!method be_successfuly_executed # This matchers checks if execution of was successful @@ -30,7 +30,7 @@ failure_message do |_actual| "Expected `#{@actual}` to succeed" \ - " but got non-zero exit status and the following output:" \ + ' but got non-zero exit status and the following output:' \ "\n\n#{@old_actual.output}\n" end end diff --git a/lib/aruba/matchers/command/have_output.rb b/lib/aruba/matchers/command/have_output.rb index f6cdf70e6..d300693aa 100644 --- a/lib/aruba/matchers/command/have_output.rb +++ b/lib/aruba/matchers/command/have_output.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/matchers/base/message_indenter" +require 'aruba/matchers/base/message_indenter' # @!method have_output # This matchers checks if has created output diff --git a/lib/aruba/matchers/command/have_output_size.rb b/lib/aruba/matchers/command/have_output_size.rb index efc30b721..e2b6ca037 100644 --- a/lib/aruba/matchers/command/have_output_size.rb +++ b/lib/aruba/matchers/command/have_output_size.rb @@ -28,8 +28,8 @@ match do |actual| if actual.respond_to? :size Aruba.platform.deprecated \ - "Application of the have_output_size matcher to a string is deprecated." \ - " Apply the matcher directly to the process object instead" + 'Application of the have_output_size matcher to a string is deprecated.' \ + ' Apply the matcher directly to the process object instead' actual_size = actual.size elsif actual.respond_to? :output actual_size = actual.output.size diff --git a/lib/aruba/matchers/directory.rb b/lib/aruba/matchers/directory.rb index 82c93eb37..a6bb80c15 100644 --- a/lib/aruba/matchers/directory.rb +++ b/lib/aruba/matchers/directory.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -Aruba.platform.require_matching_files("../directory/**/*.rb", __FILE__) +Aruba.platform.require_matching_files('../directory/**/*.rb', __FILE__) diff --git a/lib/aruba/matchers/directory/be_an_existing_directory.rb b/lib/aruba/matchers/directory/be_an_existing_directory.rb index a7ba61c8b..9fc29bc39 100644 --- a/lib/aruba/matchers/directory/be_an_existing_directory.rb +++ b/lib/aruba/matchers/directory/be_an_existing_directory.rb @@ -19,7 +19,7 @@ match do |actual| stop_all_commands - raise "String expected" unless actual.is_a? String + raise 'String expected' unless actual.is_a? String directory?(actual) end diff --git a/lib/aruba/matchers/directory/have_sub_directory.rb b/lib/aruba/matchers/directory/have_sub_directory.rb index 2c8f0b544..a66e935c1 100644 --- a/lib/aruba/matchers/directory/have_sub_directory.rb +++ b/lib/aruba/matchers/directory/have_sub_directory.rb @@ -42,13 +42,13 @@ failure_message do |actual| format('expected that directory "%s" has the following sub-directories: %s.', - actual.join(", "), + actual.join(', '), expected) end failure_message_when_negated do |actual| format('expected that directory "%s" does not have the following sub-directories: %s.', - actual.join(", "), + actual.join(', '), expected) end end diff --git a/lib/aruba/matchers/environment.rb b/lib/aruba/matchers/environment.rb index 78e9c7626..802fb3781 100644 --- a/lib/aruba/matchers/environment.rb +++ b/lib/aruba/matchers/environment.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -Aruba.platform.require_matching_files("../matchers/environment/*.rb", __FILE__) +Aruba.platform.require_matching_files('../matchers/environment/*.rb', __FILE__) diff --git a/lib/aruba/matchers/file.rb b/lib/aruba/matchers/file.rb index b92a6a101..c774e7add 100644 --- a/lib/aruba/matchers/file.rb +++ b/lib/aruba/matchers/file.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -Aruba.platform.require_matching_files("../file/**/*.rb", __FILE__) +Aruba.platform.require_matching_files('../file/**/*.rb', __FILE__) diff --git a/lib/aruba/matchers/file/be_a_command_found_in_path.rb b/lib/aruba/matchers/file/be_a_command_found_in_path.rb index 2896af961..d4e6bb66c 100644 --- a/lib/aruba/matchers/file/be_a_command_found_in_path.rb +++ b/lib/aruba/matchers/file/be_a_command_found_in_path.rb @@ -22,12 +22,12 @@ failure_message do |actual| format(%(expected that command "%s" can be found in PATH "%s".), - actual, aruba.environment["PATH"]) + actual, aruba.environment['PATH']) end failure_message_when_negated do |actual| format(%(expected that command "%s" cannot be found in PATH "%s".), - actual, aruba.environment["PATH"]) + actual, aruba.environment['PATH']) end end diff --git a/lib/aruba/matchers/file/be_an_existing_executable.rb b/lib/aruba/matchers/file/be_an_existing_executable.rb index 94ad408ec..3d05c5591 100644 --- a/lib/aruba/matchers/file/be_an_existing_executable.rb +++ b/lib/aruba/matchers/file/be_an_existing_executable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "shellwords" +require 'shellwords' # @!method be_an_existing_executable # This matchers checks if exists in filesystem diff --git a/lib/aruba/matchers/file/be_an_existing_file.rb b/lib/aruba/matchers/file/be_an_existing_file.rb index 406a6589e..111cd282a 100644 --- a/lib/aruba/matchers/file/be_an_existing_file.rb +++ b/lib/aruba/matchers/file/be_an_existing_file.rb @@ -19,7 +19,7 @@ match do |actual| stop_all_commands - raise "String expected" unless actual.is_a? String + raise 'String expected' unless actual.is_a? String file?(actual) end diff --git a/lib/aruba/matchers/file/have_same_file_content.rb b/lib/aruba/matchers/file/have_same_file_content.rb index ebbca9989..4bd592c2e 100644 --- a/lib/aruba/matchers/file/have_same_file_content.rb +++ b/lib/aruba/matchers/file/have_same_file_content.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "fileutils" +require 'fileutils' # @!method have_same_file_content_as(file_name) # This matchers checks if has the same content like diff --git a/lib/aruba/matchers/path.rb b/lib/aruba/matchers/path.rb index 1ca38942c..b9b78a7e5 100644 --- a/lib/aruba/matchers/path.rb +++ b/lib/aruba/matchers/path.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -Aruba.platform.require_matching_files("../path/**/*.rb", __FILE__) +Aruba.platform.require_matching_files('../path/**/*.rb', __FILE__) diff --git a/lib/aruba/matchers/path/have_permissions.rb b/lib/aruba/matchers/path/have_permissions.rb index b4a14f6ec..f7fc106f5 100644 --- a/lib/aruba/matchers/path/have_permissions.rb +++ b/lib/aruba/matchers/path/have_permissions.rb @@ -43,7 +43,7 @@ def permissions(file) when Integer expected.to_s(8) when String - expected.gsub(/^0*/, "") + expected.gsub(/^0*/, '') else expected end diff --git a/lib/aruba/matchers/string.rb b/lib/aruba/matchers/string.rb index b5444ac82..c41aecfba 100644 --- a/lib/aruba/matchers/string.rb +++ b/lib/aruba/matchers/string.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -Aruba.platform.require_matching_files("../string/**/*.rb", __FILE__) +Aruba.platform.require_matching_files('../string/**/*.rb', __FILE__) diff --git a/lib/aruba/matchers/string/include_output_string.rb b/lib/aruba/matchers/string/include_output_string.rb index 245774e6c..29dcbb8fa 100644 --- a/lib/aruba/matchers/string/include_output_string.rb +++ b/lib/aruba/matchers/string/include_output_string.rb @@ -20,7 +20,7 @@ # end RSpec::Matchers.define :include_output_string do |expected| match do |actual| - actual.force_encoding("UTF-8") + actual.force_encoding('UTF-8') @expected = Regexp.new(Regexp.escape(sanitize_text(expected.to_s)), Regexp::MULTILINE) @actual = sanitize_text(actual) diff --git a/lib/aruba/matchers/string/match_output_string.rb b/lib/aruba/matchers/string/match_output_string.rb index 1f45aa081..895e59fc7 100644 --- a/lib/aruba/matchers/string/match_output_string.rb +++ b/lib/aruba/matchers/string/match_output_string.rb @@ -20,7 +20,7 @@ # end RSpec::Matchers.define :match_output_string do |expected| match do |actual| - actual.force_encoding("UTF-8") + actual.force_encoding('UTF-8') @expected = Regexp.new(unescape_text(expected), Regexp::MULTILINE) @actual = sanitize_text(actual) diff --git a/lib/aruba/matchers/string/output_string_eq.rb b/lib/aruba/matchers/string/output_string_eq.rb index dc0e44c43..97182cdfe 100644 --- a/lib/aruba/matchers/string/output_string_eq.rb +++ b/lib/aruba/matchers/string/output_string_eq.rb @@ -20,7 +20,7 @@ # end RSpec::Matchers.define :output_string_eq do |expected| match do |actual| - actual.force_encoding("UTF-8") + actual.force_encoding('UTF-8') @expected = sanitize_text(expected.to_s) @actual = sanitize_text(actual.to_s) diff --git a/lib/aruba/platform.rb b/lib/aruba/platform.rb index f6600fbe0..00fd6b899 100644 --- a/lib/aruba/platform.rb +++ b/lib/aruba/platform.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "aruba/platforms/unix_platform" -require "aruba/platforms/windows_platform" +require 'aruba/platforms/unix_platform' +require 'aruba/platforms/windows_platform' # Aruba module Aruba diff --git a/lib/aruba/platforms/announcer.rb b/lib/aruba/platforms/announcer.rb index 2968263f9..c1ab75ce0 100644 --- a/lib/aruba/platforms/announcer.rb +++ b/lib/aruba/platforms/announcer.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "shellwords" -require "aruba/colorizer" +require 'shellwords' +require 'aruba/colorizer' -Aruba::Colorizer.coloring = false if !$stdout.tty? && !ENV.key?("AUTOTEST") +Aruba::Colorizer.coloring = false if !$stdout.tty? && !ENV.key?('AUTOTEST') # Aruba module Aruba @@ -83,29 +83,29 @@ def initialize private def after_init - output_format :changed_configuration, proc { |n, v| format("# %s = %s", n, v) } + output_format :changed_configuration, proc { |n, v| format('# %s = %s', n, v) } output_format :changed_environment, - proc { |n, v| format("$ export %s=%s", n, Shellwords.escape(v)) } - output_format :command, "$ %s" - output_format :directory, "$ cd %s" + proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) } + output_format :command, '$ %s' + output_format :directory, '$ cd %s' output_format :environment, - proc { |n, v| format("$ export %s=%s", n, Shellwords.escape(v)) } + proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) } output_format :full_environment, proc { |h| format("<<-ENVIRONMENT\n%s\nENVIRONMENT", Aruba.platform.simple_table(h)) } output_format :modified_environment, - proc { |n, v| format("$ export %s=%s", n, Shellwords.escape(v)) } + proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) } output_format :stderr, "<<-STDERR\n%s\nSTDERR" output_format :stdout, "<<-STDOUT\n%s\nSTDOUT" output_format :command_content, "<<-COMMAND\n%s\nCOMMAND" output_format :stop_signal, proc { |p, s| - format("Command will be stopped with `kill -%s %s`", s, p) + format('Command will be stopped with `kill -%s %s`', s, p) } - output_format :timeout, "# %s-timeout: %s seconds" - output_format :wait_time, "# %s: %s seconds" + output_format :timeout, '# %s-timeout: %s seconds' + output_format :wait_time, '# %s: %s seconds' output_format :command_filesystem_status, proc { |status| format("<<-COMMAND FILESYSTEM STATUS\n%s\nCOMMAND FILESYSTEM STATUS", @@ -113,7 +113,7 @@ def after_init } end - def output_format(channel, string = "%s", &block) + def output_format(channel, string = '%s', &block) output_formats[channel.to_sym] = if block block elsif string.is_a?(Proc) @@ -180,7 +180,7 @@ def announce(channel, *args) the_output_format = if output_formats.key? channel output_formats[channel] else - proc { |v| format("%s", v) } + proc { |v| format('%s', v) } end return unless activated?(channel) diff --git a/lib/aruba/platforms/aruba_fixed_size_file_creator.rb b/lib/aruba/platforms/aruba_fixed_size_file_creator.rb index 6117da083..bbe5ea87b 100644 --- a/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +++ b/lib/aruba/platforms/aruba_fixed_size_file_creator.rb @@ -30,7 +30,7 @@ def call(path, size, check_presence) Aruba.platform.mkdir(File.dirname(path)) - File.open(path, "wb") do |f| + File.open(path, 'wb') do |f| f.seek(size - 1) f.write("\0") end diff --git a/lib/aruba/platforms/determine_disk_usage.rb b/lib/aruba/platforms/determine_disk_usage.rb index ca501e75b..c09b9c50d 100644 --- a/lib/aruba/platforms/determine_disk_usage.rb +++ b/lib/aruba/platforms/determine_disk_usage.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/file_size" +require 'aruba/file_size' module Aruba module Platforms diff --git a/lib/aruba/platforms/filesystem_status.rb b/lib/aruba/platforms/filesystem_status.rb index bbc8a9f9d..5573c8914 100644 --- a/lib/aruba/platforms/filesystem_status.rb +++ b/lib/aruba/platforms/filesystem_status.rb @@ -38,7 +38,7 @@ def initialize(path) # Return permissions def mode - format("%o", status.mode)[-4, 4].gsub(/^0*/, "") + format('%o', status.mode)[-4, 4].gsub(/^0*/, '') end # Return owner diff --git a/lib/aruba/platforms/simple_table.rb b/lib/aruba/platforms/simple_table.rb index ffe3c921c..6432de6aa 100644 --- a/lib/aruba/platforms/simple_table.rb +++ b/lib/aruba/platforms/simple_table.rb @@ -29,12 +29,12 @@ def initialize(hash, opts) # The table def to_s longest_key = hash.keys.map(&:to_s).max_by(&:length) - return "" if longest_key.nil? + return '' if longest_key.nil? name_size = longest_key.length rows = hash.map do |k, v| - format("# %-*s => %s", name_size, k, v) + format('# %-*s => %s', name_size, k, v) end if opts[:sort] == true diff --git a/lib/aruba/platforms/unix_command_string.rb b/lib/aruba/platforms/unix_command_string.rb index 8f2fdec48..933d07d5b 100644 --- a/lib/aruba/platforms/unix_command_string.rb +++ b/lib/aruba/platforms/unix_command_string.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "delegate" -require "shellwords" +require 'delegate' +require 'shellwords' # Aruba module Aruba diff --git a/lib/aruba/platforms/unix_platform.rb b/lib/aruba/platforms/unix_platform.rb index 5fc5d6fda..6416be799 100644 --- a/lib/aruba/platforms/unix_platform.rb +++ b/lib/aruba/platforms/unix_platform.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true -require "rbconfig" -require "rubygems" -require "pathname" - -require "aruba/aruba_logger" -require "aruba/aruba_path" -require "aruba/command_monitor" - -require "aruba/platforms/simple_table" -require "aruba/platforms/unix_command_string" -require "aruba/platforms/unix_which" -require "aruba/platforms/determine_file_size" -require "aruba/platforms/determine_disk_usage" -require "aruba/platforms/aruba_file_creator" -require "aruba/platforms/aruba_fixed_size_file_creator" -require "aruba/platforms/local_environment" -require "aruba/platforms/announcer" -require "aruba/platforms/filesystem_status" +require 'rbconfig' +require 'rubygems' +require 'pathname' + +require 'aruba/aruba_logger' +require 'aruba/aruba_path' +require 'aruba/command_monitor' + +require 'aruba/platforms/simple_table' +require 'aruba/platforms/unix_command_string' +require 'aruba/platforms/unix_which' +require 'aruba/platforms/determine_file_size' +require 'aruba/platforms/determine_disk_usage' +require 'aruba/platforms/aruba_file_creator' +require 'aruba/platforms/aruba_fixed_size_file_creator' +require 'aruba/platforms/local_environment' +require 'aruba/platforms/announcer' +require 'aruba/platforms/filesystem_status' # Aruba module Aruba @@ -82,7 +82,7 @@ def with_replaced_environment(env = {}, &block) end def default_shell - "bash" + 'bash' end def detect_ruby(cmd) @@ -94,11 +94,11 @@ def detect_ruby(cmd) end def deprecated(msg) - warn(format("%s. Called by %s", msg, caller[1])) + warn(format('%s. Called by %s', msg, caller[1])) end def current_ruby - ::File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"]) + ::File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) end def require_matching_files(pattern, base) @@ -128,7 +128,7 @@ def getwd def chdir(dir_name, &block) dir_name = ::File.expand_path(dir_name.to_s) - with_replaced_environment "OLDPWD" => getwd, "PWD" => dir_name do + with_replaced_environment 'OLDPWD' => getwd, 'PWD' => dir_name do ::Dir.chdir(dir_name, &block) end end @@ -236,7 +236,7 @@ def simple_table(hash, opts = {}) # @param [String] path # The PATH, a string concatenated with ":", e.g. /usr/bin/:/bin on a # UNIX-system - def which(program, path = ENV["PATH"]) + def which(program, path = ENV['PATH']) UnixWhich.new.call(program, path) end diff --git a/lib/aruba/platforms/unix_which.rb b/lib/aruba/platforms/unix_which.rb index 10c298b58..3ae52a5b7 100644 --- a/lib/aruba/platforms/unix_which.rb +++ b/lib/aruba/platforms/unix_which.rb @@ -72,7 +72,7 @@ def initialize # # @param [String] path # ENV['PATH'] - def call(program, path = ENV["PATH"]) + def call(program, path = ENV['PATH']) raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty? program = program.to_s diff --git a/lib/aruba/platforms/windows_environment_variables.rb b/lib/aruba/platforms/windows_environment_variables.rb index ffcfe74f9..e20dea76a 100644 --- a/lib/aruba/platforms/windows_environment_variables.rb +++ b/lib/aruba/platforms/windows_environment_variables.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/platforms/unix_environment_variables" +require 'aruba/platforms/unix_environment_variables' # Aruba module Aruba diff --git a/lib/aruba/platforms/windows_platform.rb b/lib/aruba/platforms/windows_platform.rb index e4cb0d87c..c0483a9dd 100644 --- a/lib/aruba/platforms/windows_platform.rb +++ b/lib/aruba/platforms/windows_platform.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "aruba/platforms/unix_platform" -require "aruba/platforms/windows_command_string" -require "aruba/platforms/windows_environment_variables" -require "aruba/platforms/windows_which" +require 'aruba/platforms/unix_platform' +require 'aruba/platforms/windows_command_string' +require 'aruba/platforms/windows_environment_variables' +require 'aruba/platforms/windows_which' # Aruba module Aruba @@ -34,7 +34,7 @@ def environment_variables end # @see UnixPlatform#which - def which(program, path = ENV["PATH"]) + def which(program, path = ENV['PATH']) WindowsWhich.new.call(program, path) end diff --git a/lib/aruba/platforms/windows_which.rb b/lib/aruba/platforms/windows_which.rb index 6d9fa4545..c004d597f 100644 --- a/lib/aruba/platforms/windows_which.rb +++ b/lib/aruba/platforms/windows_which.rb @@ -51,7 +51,7 @@ def call(program, path) file = File.join(dir, program) # Dir[] doesn't handle backslashes properly, so convert them. Also, if # the program name doesn't have an extension, try them all. - file = file.tr("\\", "/") + file = file.tr('\\', '/') found = Dir[file].first @@ -86,7 +86,7 @@ def initialize # # @param [String] path # ENV['PATH'] - def call(program, path = ENV["PATH"]) + def call(program, path = ENV['PATH']) raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty? program = program.to_s @@ -98,10 +98,10 @@ def call(program, path = ENV["PATH"]) private def windows_executable_extentions - if ENV["PATHEXT"] - format(".{%s}", ENV["PATHEXT"].tr(";", ",").tr(".", "")).downcase + if ENV['PATHEXT'] + format('.{%s}', ENV['PATHEXT'].tr(';', ',').tr('.', '')).downcase else - ".{exe,com,bat}" + '.{exe,com,bat}' end end end diff --git a/lib/aruba/processes/basic_process.rb b/lib/aruba/processes/basic_process.rb index 2a6d1a756..172ff2f58 100644 --- a/lib/aruba/processes/basic_process.rb +++ b/lib/aruba/processes/basic_process.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "aruba/platform" -require "shellwords" +require 'aruba/platform' +require 'shellwords' # Aruba module Aruba diff --git a/lib/aruba/processes/debug_process.rb b/lib/aruba/processes/debug_process.rb index 19c0044b4..18115759e 100644 --- a/lib/aruba/processes/debug_process.rb +++ b/lib/aruba/processes/debug_process.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "aruba/processes/spawn_process" +require 'aruba/processes/spawn_process' # Aruba module Aruba @@ -43,8 +43,8 @@ def stdin(*); end # @return [String] # A predefined string to make users aware they are using the DebugProcess def stdout(*) - "This is the debug launcher on STDOUT." \ - " If this output is unexpected, please check your setup." + 'This is the debug launcher on STDOUT.' \ + ' If this output is unexpected, please check your setup.' end # Return stderr @@ -52,8 +52,8 @@ def stdout(*) # @return [String] # A predefined string to make users aware they are using the DebugProcess def stderr(*) - "This is the debug launcher on STDERR." \ - " If this output is unexpected, please check your setup." + 'This is the debug launcher on STDERR.' \ + ' If this output is unexpected, please check your setup.' end # Write to nothing diff --git a/lib/aruba/processes/in_process.rb b/lib/aruba/processes/in_process.rb index 64972c1c3..e23894c0c 100644 --- a/lib/aruba/processes/in_process.rb +++ b/lib/aruba/processes/in_process.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "shellwords" -require "stringio" -require "aruba/processes/basic_process" -require "aruba/platform" +require 'shellwords' +require 'stringio' +require 'aruba/processes/basic_process' +require 'aruba/platform' # Aruba module Aruba @@ -63,14 +63,14 @@ def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop: # Start command def start - raise "You need to call aruba.config.main_class = YourMainClass" unless main_class + raise 'You need to call aruba.config.main_class = YourMainClass' unless main_class @started = true Dir.chdir @working_directory do before_run - new_env = environment.merge("PWD" => @working_directory) + new_env = environment.merge('PWD' => @working_directory) Aruba.platform.with_replaced_environment new_env do main_class.new(@argv, @stdin, @stdout, @stderr, @kernel).execute! end @@ -113,7 +113,7 @@ def write(input) # Close io def close_io(name) unless [:stdin, :stdout, :stderr].include? name - raise ArgumentError, "Only stdin stdout and stderr are allowed to close" + raise ArgumentError, 'Only stdin stdout and stderr are allowed to close' end get_instance_variable(name.to_sym).close diff --git a/lib/aruba/processes/spawn_process.rb b/lib/aruba/processes/spawn_process.rb index 88f4c207f..0bdc73a64 100644 --- a/lib/aruba/processes/spawn_process.rb +++ b/lib/aruba/processes/spawn_process.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require "tempfile" -require "shellwords" +require 'tempfile' +require 'shellwords' -require "aruba/errors" -require "aruba/processes/basic_process" -require "aruba/platform" +require 'aruba/errors' +require 'aruba/processes/basic_process' +require 'aruba/platform' # Aruba module Aruba @@ -41,11 +41,11 @@ def stop return if @exit_status if Aruba.platform.term_signal_supported? - send_signal "TERM" + send_signal 'TERM' return if poll_for_exit(3) end - send_signal "KILL" + send_signal 'KILL' wait end @@ -147,8 +147,8 @@ def start if started? error_message = "Command \"#{commandline}\" has already been started." \ - " Please `#stop` the command first and `#start` it again." \ - " Alternatively use `#restart`." + ' Please `#stop` the command first and `#start` it again.' \ + ' Alternatively use `#restart`.' raise CommandAlreadyStartedError, error_message end @@ -156,14 +156,14 @@ def start @process = ProcessRunner.new(command_string.to_a) - @stdout_file = Tempfile.new("aruba-stdout-") - @stderr_file = Tempfile.new("aruba-stderr-") + @stdout_file = Tempfile.new('aruba-stdout-') + @stderr_file = Tempfile.new('aruba-stderr-') @stdout_file.sync = true @stderr_file.sync = true - @stdout_file.set_encoding("ASCII-8BIT") - @stderr_file.set_encoding("ASCII-8BIT") + @stdout_file.set_encoding('ASCII-8BIT') + @stderr_file.set_encoding('ASCII-8BIT') @exit_status = nil @@ -348,7 +348,7 @@ def command_path if Aruba.platform.builtin_shell_commands.include?(command) command else - Aruba.platform.which(command, environment["PATH"]) + Aruba.platform.which(command, environment['PATH']) end end @@ -363,7 +363,7 @@ def read_temporary_output_file(file) data = file.read file.close - data.force_encoding("UTF-8") + data.force_encoding('UTF-8') end end end diff --git a/lib/aruba/rspec.rb b/lib/aruba/rspec.rb index 198733b0a..87e9e80da 100644 --- a/lib/aruba/rspec.rb +++ b/lib/aruba/rspec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require "rspec/core" +require 'rspec/core' -require "aruba" -require "aruba/api" -require "aruba/version" +require 'aruba' +require 'aruba/api' +require 'aruba/version' RSpec.configure do |config| config.include Aruba::Api, type: :aruba @@ -16,12 +16,12 @@ # Modify PATH to include project/bin prepend_environment_variable( - "PATH", + 'PATH', aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR ) # Use configured home directory as HOME - set_environment_variable "HOME", aruba.config.home_directory + set_environment_variable 'HOME', aruba.config.home_directory end example.run diff --git a/lib/aruba/runtime.rb b/lib/aruba/runtime.rb index df0c396a1..673cb5e8b 100644 --- a/lib/aruba/runtime.rb +++ b/lib/aruba/runtime.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require "aruba/configuration" -require "aruba/aruba_path" -require "aruba/config_wrapper" -require "aruba/events" -require "aruba/event_bus" +require 'aruba/configuration' +require 'aruba/aruba_path' +require 'aruba/config_wrapper' +require 'aruba/events' +require 'aruba/event_bus' module Aruba # Runtime of aruba @@ -86,7 +86,7 @@ def fixtures_directory directory = candidates.find { |d| Aruba.platform.directory? d } unless directory - canditates_display = candidates.map { |d| format('"%s"', d) }.join(", ") + canditates_display = candidates.map { |d| format('"%s"', d) }.join(', ') raise "No existing fixtures directory found in #{canditates_display}." end diff --git a/lib/aruba/setup.rb b/lib/aruba/setup.rb index 2b3eebbed..a620305e9 100644 --- a/lib/aruba/setup.rb +++ b/lib/aruba/setup.rb @@ -41,10 +41,10 @@ def events :command_started, proc do |event| runtime.announcer.announce(:command) { event.entity.commandline } - runtime.announcer.announce(:timeout, "exit") { event.entity.exit_timeout } - runtime.announcer.announce(:timeout, "io wait") { event.entity.io_wait_timeout } + runtime.announcer.announce(:timeout, 'exit') { event.entity.exit_timeout } + runtime.announcer.announce(:timeout, 'io wait') { event.entity.io_wait_timeout } runtime.announcer - .announce(:wait_time, "startup wait time") { event.entity.startup_wait_time } + .announce(:wait_time, 'startup wait time') { event.entity.startup_wait_time } runtime.announcer.announce(:full_environment) { event.entity.environment } end ) diff --git a/lib/aruba/version.rb b/lib/aruba/version.rb index 5d0dd697f..c9e101ae2 100644 --- a/lib/aruba/version.rb +++ b/lib/aruba/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Aruba - VERSION = "2.2.0" + VERSION = '2.2.0' end diff --git a/spec/aruba/api/bundler_spec.rb b/spec/aruba/api/bundler_spec.rb index 81d4a8dd5..e4fe230a4 100644 --- a/spec/aruba/api/bundler_spec.rb +++ b/spec/aruba/api/bundler_spec.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/api" +require 'spec_helper' +require 'aruba/api' RSpec.describe Aruba::Api::Bundler do - include_context "uses aruba API" + include_context 'uses aruba API' - describe "#unset_bundler_env_vars" do + describe '#unset_bundler_env_vars' do it "sets up Aruba's environment to clear Bundler's variables" do @aruba.unset_bundler_env_vars - expect(@aruba.aruba.environment["BUNDLE_PATH"]).to be_nil - expect(@aruba.aruba.environment["BUNDLE_GEMFILE"]).to be_nil + expect(@aruba.aruba.environment['BUNDLE_PATH']).to be_nil + expect(@aruba.aruba.environment['BUNDLE_GEMFILE']).to be_nil end end end diff --git a/spec/aruba/api/commands_spec.rb b/spec/aruba/api/commands_spec.rb index 07828a6d4..56aee597d 100644 --- a/spec/aruba/api/commands_spec.rb +++ b/spec/aruba/api/commands_spec.rb @@ -1,39 +1,39 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/api" -require "fileutils" +require 'spec_helper' +require 'aruba/api' +require 'fileutils' RSpec.describe Aruba::Api::Commands do - include_context "uses aruba API" + include_context 'uses aruba API' - describe "#run_command" do - context "when succesfully running a command" do - before { @aruba.run_command "cat" } + describe '#run_command' do + context 'when succesfully running a command' do + before { @aruba.run_command 'cat' } after { @aruba.all_commands.each(&:stop) } - it "respond to unfrozen input" do - @aruba.type(+"Hello") + it 'respond to unfrozen input' do + @aruba.type(+'Hello') @aruba.type(+"\u0004") - expect(@aruba.last_command_started).to have_output "Hello" + expect(@aruba.last_command_started).to have_output 'Hello' end - it "respond to frozen input" do - @aruba.type "Hello" + it 'respond to frozen input' do + @aruba.type 'Hello' @aruba.type "\u0004" - expect(@aruba.last_command_started).to have_output "Hello" + expect(@aruba.last_command_started).to have_output 'Hello' end - it "respond to close_input" do - @aruba.type "Hello" + it 'respond to close_input' do + @aruba.type 'Hello' @aruba.close_input - expect(@aruba.last_command_started).to have_output "Hello" + expect(@aruba.last_command_started).to have_output 'Hello' end - it "pipes data" do + it 'pipes data' do @aruba.write_file(@file_name, "Hello\nWorld!") @aruba.pipe_in_file(@file_name) @aruba.close_input @@ -41,7 +41,7 @@ end end - context "when mode is :in_process" do + context 'when mode is :in_process' do before do @aruba.aruba.config.command_launcher = :in_process end @@ -50,13 +50,13 @@ @aruba.aruba.config.command_launcher = :spawn end - it "raises an error" do - expect { @aruba.run_command "cat" }.to raise_error NotImplementedError + it 'raises an error' do + expect { @aruba.run_command 'cat' }.to raise_error NotImplementedError end end - context "when running a relative command" do - let(:cmd) { Gem.win_platform? ? "bin/testcmd.bat" : "bin/testcmd" } + context 'when running a relative command' do + let(:cmd) { Gem.win_platform? ? 'bin/testcmd.bat' : 'bin/testcmd' } before do if Gem.win_platform? @@ -72,7 +72,7 @@ end end - it "finds the command from the test directory" do + it 'finds the command from the test directory' do run_command(cmd) expect(last_command_started).to be_successfully_executed end diff --git a/spec/aruba/api/core_spec.rb b/spec/aruba/api/core_spec.rb index b3a3a6eb9..89fb71fea 100644 --- a/spec/aruba/api/core_spec.rb +++ b/spec/aruba/api/core_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/api" -require "fileutils" +require 'spec_helper' +require 'aruba/api' +require 'fileutils' RSpec.describe Aruba::Api::Core do - include_context "uses aruba API" + include_context 'uses aruba API' - describe "#cd" do + describe '#cd' do before do - @directory_name = "test_dir" + @directory_name = 'test_dir' @directory_path = File.join(@aruba.aruba.current_directory, @directory_name) end - context "with a block given" do - it "runs the passed block in the given directory" do + context 'with a block given' do + it 'runs the passed block in the given directory' do @aruba.create_directory @directory_name full_path = File.expand_path(@directory_path) @aruba.cd @directory_name do @@ -23,25 +23,25 @@ expect(Dir.pwd).not_to eq full_path end - it "sets directory environment in the passed block" do + it 'sets directory environment in the passed block' do @aruba.create_directory @directory_name old_pwd = Dir.pwd full_path = File.expand_path(@directory_path) @aruba.cd @directory_name do - expect(ENV["PWD"]).to eq full_path - expect(ENV["OLDPWD"]).to eq old_pwd + expect(ENV['PWD']).to eq full_path + expect(ENV['OLDPWD']).to eq old_pwd end end - it "sets aruba environment in the passed block" do + it 'sets aruba environment in the passed block' do @aruba.create_directory @directory_name - @aruba.set_environment_variable("FOO", "bar") + @aruba.set_environment_variable('FOO', 'bar') @aruba.cd @directory_name do - expect(ENV["FOO"]).to eq "bar" + expect(ENV['FOO']).to eq 'bar' end end - it "does not touch other environment variables in the passed block" do + it 'does not touch other environment variables in the passed block' do keys = ENV.keys - %w(PWD OLDPWD) old_values = ENV.values_at(*keys) @aruba.create_directory @directory_name @@ -52,14 +52,14 @@ it 'expands "~" to the aruba home directory' do full_path = aruba.config.home_directory - @aruba.cd "~" do + @aruba.cd '~' do expect(Dir.pwd).to eq full_path end expect(Dir.pwd).not_to eq full_path end end - context "with no block given" do + context 'with no block given' do it "sets aruba's current directory to the given directory" do @aruba.create_directory @directory_name full_path = File.expand_path(@directory_path) @@ -69,96 +69,96 @@ it 'expands "~" to the aruba home directory' do full_path = aruba.config.home_directory - @aruba.cd "~" + @aruba.cd '~' expect(File.expand_path(@aruba.aruba.current_directory)).to eq full_path end end end - describe "#expand_path" do - context "when file_name is given" do + describe '#expand_path' do + context 'when file_name is given' do it { expect(@aruba.expand_path(@file_name)).to eq File.expand_path(@file_path) } end - context "when an absolute file_path is given" do + context 'when an absolute file_path is given' do let(:logger) { @aruba.aruba.logger } before do allow(logger).to receive :warn end - it "raises a UserError" do + it 'raises a UserError' do expect { @aruba.expand_path(@file_path) }.to raise_error Aruba::UserError end - it "does not raise an error if told not to" do + it 'does not raise an error if told not to' do @aruba.aruba.config.allow_absolute_paths = true expect { @aruba.expand_path(@file_path) }.not_to raise_error end end context 'when path contains "."' do - it { expect(@aruba.expand_path(".")).to eq File.expand_path(aruba.current_directory) } + it { expect(@aruba.expand_path('.')).to eq File.expand_path(aruba.current_directory) } end context 'when path contains ".."' do it { - expect(@aruba.expand_path("path/..")) + expect(@aruba.expand_path('path/..')) .to eq File.expand_path(File.join(aruba.current_directory)) } end - context "when path is nil" do + context 'when path is nil' do it { expect { @aruba.expand_path(nil) }.to raise_error ArgumentError } end - context "when path is empty" do - it { expect { @aruba.expand_path("") }.to raise_error ArgumentError } + context 'when path is empty' do + it { expect { @aruba.expand_path('') }.to raise_error ArgumentError } end - context "when second argument is given" do - it "behaves similar to File.expand_path" do - expect(@aruba.expand_path(@file_name, "path")) - .to eq File.expand_path(File.join(aruba.current_directory, "path", @file_name)) + context 'when second argument is given' do + it 'behaves similar to File.expand_path' do + expect(@aruba.expand_path(@file_name, 'path')) + .to eq File.expand_path(File.join(aruba.current_directory, 'path', @file_name)) end end context 'when file_name contains fixtures "%" string' do - it "finds files in the fixtures directory" do - expect(@aruba.expand_path("%/cli-app")) - .to eq File.expand_path("cli-app", File.join(aruba.fixtures_directory)) + it 'finds files in the fixtures directory' do + expect(@aruba.expand_path('%/cli-app')) + .to eq File.expand_path('cli-app', File.join(aruba.fixtures_directory)) end end end - describe "#in_current_directory" do + describe '#in_current_directory' do let(:directory_path) { @aruba.aruba.current_directory } let!(:full_path) { File.expand_path(directory_path) } - context "with a block given" do - it "runs the passed block in the given directory" do + context 'with a block given' do + it 'runs the passed block in the given directory' do @aruba.in_current_directory do expect(Dir.pwd).to eq full_path end expect(Dir.pwd).not_to eq full_path end - it "sets directory environment in the passed block" do + it 'sets directory environment in the passed block' do old_pwd = Dir.pwd @aruba.in_current_directory do - expect(ENV["PWD"]).to eq full_path - expect(ENV["OLDPWD"]).to eq old_pwd + expect(ENV['PWD']).to eq full_path + expect(ENV['OLDPWD']).to eq old_pwd end end - it "sets aruba environment in the passed block" do - @aruba.set_environment_variable("FOO", "bar") + it 'sets aruba environment in the passed block' do + @aruba.set_environment_variable('FOO', 'bar') @aruba.in_current_directory do - expect(ENV["FOO"]).to eq "bar" + expect(ENV['FOO']).to eq 'bar' end end - it "does not touch other environment variables in the passed block" do + it 'does not touch other environment variables in the passed block' do keys = ENV.keys - %w(PWD OLDPWD) old_values = ENV.values_at(*keys) @aruba.in_current_directory do @@ -168,88 +168,88 @@ end end - describe "#with_environment" do - it "modifies env for block" do - variable = "THIS_IS_A_ENV_VAR" - ENV[variable] = "1" + describe '#with_environment' do + it 'modifies env for block' do + variable = 'THIS_IS_A_ENV_VAR' + ENV[variable] = '1' - @aruba.with_environment variable => "0" do - expect(ENV[variable]).to eq "0" + @aruba.with_environment variable => '0' do + expect(ENV[variable]).to eq '0' end - expect(ENV[variable]).to eq "1" + expect(ENV[variable]).to eq '1' end - it "modifies env for recursive calls block" do - variable = "THIS_IS_A_ENV_VAR" - ENV[variable] = "1" + it 'modifies env for recursive calls block' do + variable = 'THIS_IS_A_ENV_VAR' + ENV[variable] = '1' - @aruba.with_environment variable => "0" do + @aruba.with_environment variable => '0' do @aruba.with_environment do - expect(ENV[variable]).to eq "0" + expect(ENV[variable]).to eq '0' end end - expect(ENV[variable]).to eq "1" + expect(ENV[variable]).to eq '1' end - it "works together with #set_environment_variable" do - variable = "THIS_IS_A_ENV_VAR" - @aruba.set_environment_variable variable, "1" + it 'works together with #set_environment_variable' do + variable = 'THIS_IS_A_ENV_VAR' + @aruba.set_environment_variable variable, '1' @aruba.with_environment do - expect(ENV[variable]).to eq "1" - @aruba.set_environment_variable variable, "0" + expect(ENV[variable]).to eq '1' + @aruba.set_environment_variable variable, '0' @aruba.with_environment do - expect(ENV[variable]).to eq "0" + expect(ENV[variable]).to eq '0' end - expect(ENV[variable]).to eq "1" + expect(ENV[variable]).to eq '1' end end - it "works with a mix of ENV and #set_environment_variable" do - variable = "THIS_IS_A_ENV_VAR" - @aruba.set_environment_variable variable, "1" - ENV[variable] = "2" - expect(ENV[variable]).to eq "2" + it 'works with a mix of ENV and #set_environment_variable' do + variable = 'THIS_IS_A_ENV_VAR' + @aruba.set_environment_variable variable, '1' + ENV[variable] = '2' + expect(ENV[variable]).to eq '2' @aruba.with_environment do - expect(ENV[variable]).to eq "1" - @aruba.set_environment_variable variable, "0" + expect(ENV[variable]).to eq '1' + @aruba.set_environment_variable variable, '0' @aruba.with_environment do - expect(ENV[variable]).to eq "0" + expect(ENV[variable]).to eq '0' end - expect(ENV[variable]).to eq "1" + expect(ENV[variable]).to eq '1' end - expect(ENV[variable]).to eq "2" + expect(ENV[variable]).to eq '2' end - it "works with a mix of argument and #set_environment_variable" do - variable = "THIS_IS_A_ENV_VAR" + it 'works with a mix of argument and #set_environment_variable' do + variable = 'THIS_IS_A_ENV_VAR' - @aruba.set_environment_variable variable, "1" - @aruba.with_environment variable => "2" do - expect(ENV[variable]).to eq "2" + @aruba.set_environment_variable variable, '1' + @aruba.with_environment variable => '2' do + expect(ENV[variable]).to eq '2' @aruba.with_environment do - expect(ENV[variable]).to eq "2" + expect(ENV[variable]).to eq '2' end end end - it "works together with #delete_environment_variable" do - variable = "THIS_IS_A_ENV_VAR" - ENV[variable] = "2" + it 'works together with #delete_environment_variable' do + variable = 'THIS_IS_A_ENV_VAR' + ENV[variable] = '2' @aruba.delete_environment_variable variable @aruba.with_environment do expect(ENV[variable]).to be_nil end - expect(ENV[variable]).to eq "2" + expect(ENV[variable]).to eq '2' end - it "works with #delete_environment_variable when called several times" do - variable = "THIS_IS_A_ENV_VAR" - ENV[variable] = "2" + it 'works with #delete_environment_variable when called several times' do + variable = 'THIS_IS_A_ENV_VAR' + ENV[variable] = '2' @aruba.delete_environment_variable variable @aruba.with_environment do @@ -259,14 +259,14 @@ @aruba.with_environment do expect(ENV[variable]).to be_nil end - expect(ENV[variable]).to eq "2" + expect(ENV[variable]).to eq '2' end - it "forgets passed argument when called again" do - variable = "THIS_IS_A_ENV_VAR" + it 'forgets passed argument when called again' do + variable = 'THIS_IS_A_ENV_VAR' @aruba.with_environment variable => 2 do - expect(ENV[variable]).to eq "2" + expect(ENV[variable]).to eq '2' end @aruba.with_environment do @@ -274,15 +274,15 @@ end end - it "keeps values not set in argument" do - variable = "THIS_IS_A_ENV_VAR" - ENV[variable] = "2" - expect(ENV[variable]).to eq "2" + it 'keeps values not set in argument' do + variable = 'THIS_IS_A_ENV_VAR' + ENV[variable] = '2' + expect(ENV[variable]).to eq '2' @aruba.with_environment do - expect(ENV[variable]).to eq "2" + expect(ENV[variable]).to eq '2' end - expect(ENV[variable]).to eq "2" + expect(ENV[variable]).to eq '2' end end end diff --git a/spec/aruba/api/filesystem_spec.rb b/spec/aruba/api/filesystem_spec.rb index b00600b6f..0201f5fcf 100644 --- a/spec/aruba/api/filesystem_spec.rb +++ b/spec/aruba/api/filesystem_spec.rb @@ -1,41 +1,41 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/api" +require 'spec_helper' +require 'aruba/api' RSpec.describe Aruba::Api::Filesystem do - include_context "uses aruba API" + include_context 'uses aruba API' let(:name) { @file_name } let(:path) { @file_path } - let(:dir_name) { "test.d" } + let(:dir_name) { 'test.d' } let(:dir_path) { @aruba.expand_path(dir_name) } - describe "#append_lines_to_file" do - it "inserts a newline if existing file does not end in one" do + describe '#append_lines_to_file' do + it 'inserts a newline if existing file does not end in one' do Aruba.platform.write_file(path, "foo\nbar") - append_lines_to_file(name, "baz") + append_lines_to_file(name, 'baz') expect(File.read(path)).to eq "foo\nbar\nbaz" end - it "does not insert a newline if the existing file ends in one" do + it 'does not insert a newline if the existing file ends in one' do Aruba.platform.write_file(path, "foo\nbar\n") - append_lines_to_file(name, "baz") + append_lines_to_file(name, 'baz') expect(File.read(path)).to eq "foo\nbar\nbaz" end end - describe "#all_paths" do - context "when file exists" do + describe '#all_paths' do + context 'when file exists' do before do - Aruba.platform.write_file(path, "") + Aruba.platform.write_file(path, '') end it { expect(all_paths).to include expand_path(name) } end - context "when directory exists" do - let(:name) { "test_dir" } + context 'when directory exists' do + let(:name) { 'test_dir' } let(:path) { File.join(@aruba.aruba.current_directory, name) } before do @@ -45,22 +45,22 @@ it { expect(all_paths).to include expand_path(name) } end - context "when nothing exists" do + context 'when nothing exists' do it { expect(all_paths).to eq [] } end end - describe "#all_files" do - context "when file exists" do + describe '#all_files' do + context 'when file exists' do before do - Aruba.platform.write_file(path, "") + Aruba.platform.write_file(path, '') end it { expect(all_files).to include expand_path(name) } end - context "when directory exists" do - let(:name) { "test_dir" } + context 'when directory exists' do + let(:name) { 'test_dir' } let(:path) { File.join(@aruba.aruba.current_directory, name) } before do @@ -70,22 +70,22 @@ it { expect(all_files).to eq [] } end - context "when nothing exists" do + context 'when nothing exists' do it { expect(all_files).to eq [] } end end - describe "#all_directories" do - context "when file exists" do + describe '#all_directories' do + context 'when file exists' do before do - Aruba.platform.write_file(path, "") + Aruba.platform.write_file(path, '') end it { expect(all_directories).to eq [] } end - context "when directory exists" do - let(:name) { "test_dir" } + context 'when directory exists' do + let(:name) { 'test_dir' } let(:path) { File.join(@aruba.aruba.current_directory, name) } before do @@ -95,32 +95,32 @@ it { expect(all_directories).to include expand_path(name) } end - context "when nothing exists" do + context 'when nothing exists' do it { expect(all_directories).to eq [] } end end - describe "#file_size" do + describe '#file_size' do let(:size) { file_size(name) } - context "when file exists" do + context 'when file exists' do before do - File.open(path, "w") { |f| f.print "a" } + File.open(path, 'w') { |f| f.print 'a' } end it { expect(size).to eq 1 } end - context "when file does not exist" do - let(:name) { "non_existing_file" } + context 'when file does not exist' do + let(:name) { 'non_existing_file' } it { expect { size }.to raise_error RSpec::Expectations::ExpectationNotMetError } end end - describe "#touch" do - context "when touching a file that does not exist" do - it "creates an empty file in an existing directory" do + describe '#touch' do + context 'when touching a file that does not exist' do + it 'creates an empty file in an existing directory' do @aruba.touch(name) aggregate_failures do @@ -129,25 +129,25 @@ end end - it "creates an empty file in a non-existing directory" do - name = "directory/test" + it 'creates an empty file in a non-existing directory' do + name = 'directory/test' path = File.join(@aruba.aruba.current_directory, name) @aruba.touch(name) expect(File.file?(path)).to be true end - it "creates a file relative to home if name includes ~" do + it 'creates a file relative to home if name includes ~' do string = random_string - name = File.join("~", string) + name = File.join('~', string) path = File.join(@aruba.aruba.config.home_directory, string) @aruba.touch(name) expect(File.file?(path)).to be true end - it "sets mtime when passed as an option" do - time = Time.parse("2014-01-01 10:00:00") + it 'sets mtime when passed as an option' do + time = Time.parse('2014-01-01 10:00:00') @aruba.touch(name, mtime: time) aggregate_failures do @@ -156,7 +156,7 @@ end end - it "creates multiple files when multiple names are given" do + it 'creates multiple files when multiple names are given' do names = %w(file1 file2 file3) @aruba.touch(names) @@ -170,7 +170,7 @@ end end - context "when touching an existing directory" do + context 'when touching an existing directory' do let(:name) { %w(directory1) } let(:path) { File.join(@aruba.aruba.current_directory, name) } @@ -178,13 +178,13 @@ Aruba.platform.mkdir path end - it "leaves the directory a directory" do + it 'leaves the directory a directory' do @aruba.touch(name) expect(File.directory?(path)).to be true end - it "sets the mtime if requested" do - time = Time.parse("2014-01-01 10:00:00") + it 'sets the mtime if requested' do + time = Time.parse('2014-01-01 10:00:00') @aruba.touch(name, mtime: time) aggregate_failures do @@ -195,72 +195,72 @@ end end - describe "#absolute?" do - context "when is absolute path" do + describe '#absolute?' do + context 'when is absolute path' do it { expect(@aruba).to be_absolute(path) } end - context "when is relative path" do + context 'when is relative path' do it { expect(@aruba).not_to be_absolute(name) } end end - describe "#relative?" do - context "when given an absolute path" do + describe '#relative?' do + context 'when given an absolute path' do it { expect(@aruba).not_to be_relative(path) } end - context "when given a relative path" do + context 'when given a relative path' do it { expect(@aruba).to be_relative(name) } end end - describe "#exist?" do - context "when given a file" do - it "returns true if the file exists" do - Aruba.platform.write_file(path, "") + describe '#exist?' do + context 'when given a file' do + it 'returns true if the file exists' do + Aruba.platform.write_file(path, '') expect(@aruba.exist?(name)).to be true end - it "returns false if the file does not exist" do + it 'returns false if the file does not exist' do expect(@aruba.exist?(name)).to be false end end - context "when given a directory" do - it "returns true if the directory exists" do + context 'when given a directory' do + it 'returns true if the directory exists' do Aruba.platform.mkdir(dir_path) expect(@aruba.exist?(dir_name)).to be true end - it "returns false if the directory does not exist" do + it 'returns false if the directory does not exist' do expect(@aruba.exist?(dir_name)).to be false end end end - describe "#file?" do - context "when given a file" do - context "when it exists" do + describe '#file?' do + context 'when given a file' do + context 'when it exists' do before do - Aruba.platform.write_file(path, "") + Aruba.platform.write_file(path, '') end it { expect(@aruba).to be_file(name) } end - context "when does not exist" do + context 'when does not exist' do it { expect(@aruba).not_to be_file(name) } end end - context "when given a directory" do - let(:name) { "test.d" } + context 'when given a directory' do + let(:name) { 'test.d' } let(:path) { File.join(@aruba.aruba.current_directory, name) } - context "when it exists" do + context 'when it exists' do before do Aruba.platform.mkdir(path) end @@ -268,29 +268,29 @@ it { expect(@aruba).not_to be_file(name) } end - context "when does not exist" do + context 'when does not exist' do it { expect(@aruba).not_to be_file(name) } end end end - describe "#directory?" do - context "when given a file" do - context "when it exists" do + describe '#directory?' do + context 'when given a file' do + context 'when it exists' do before do - Aruba.platform.write_file(path, "") + Aruba.platform.write_file(path, '') end it { expect(@aruba).not_to be_directory(name) } end - context "when does not exist" do + context 'when does not exist' do it { expect(@aruba).not_to be_directory(name) } end end - context "when given a directory" do - context "when it exists" do + context 'when given a directory' do + context 'when it exists' do before do Aruba.platform.mkdir(dir_path) end @@ -298,79 +298,79 @@ it { expect(@aruba).to be_directory(dir_name) } end - context "when does not exist" do + context 'when does not exist' do it { expect(@aruba).not_to be_directory(dir_name) } end end end - describe "#copy" do - let(:source) { "file.txt" } - let(:destination) { "file1.txt" } + describe '#copy' do + let(:source) { 'file.txt' } + let(:destination) { 'file1.txt' } - context "when source is existing" do - context "when destination is non-existing" do - context "when source is file" do + context 'when source is existing' do + context 'when destination is non-existing' do + context 'when source is file' do before do create_test_files(source) @aruba.copy source, destination end - context "when source is plain file" do + context 'when source is plain file' do it { expect(destination).to be_an_existing_file } end context 'when source is contains "~" in path' do - let(:source) { "~/file.txt" } + 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" } + context 'when source is fixture' do + let(:source) { '%/copy/file.txt' } + let(:destination) { 'file.txt' } it { expect(destination).to be_an_existing_file } end - context "when source is list of files" do + context 'when source is list of files' do let(:source) { %w(file1.txt file2.txt file3.txt) } - let(:destination) { "file.d" } + let(:destination) { 'file.d' } let(:destination_files) { source.map { |s| File.join(destination, s) } } it { expect(destination_files).to all be_an_existing_file } end end - context "when source is directory" do - let(:source) { "src.d" } - let(:destination) { "dst.d" } + context 'when source is directory' do + let(:source) { 'src.d' } + let(:destination) { 'dst.d' } before do Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, source)) @aruba.copy source, destination end - context "when source is single directory" do + context 'when source is single directory' do it { expect(destination).to be_an_existing_directory } end - context "when source is nested directory" do - let(:source) { "src.d/subdir.d" } - let(:destination) { "dst.d/" } + context 'when source is nested directory' do + let(:source) { 'src.d/subdir.d' } + let(:destination) { 'dst.d/' } it { expect(destination).to be_an_existing_directory } end end end - context "when destination is existing" do - context "when source is list of files" do + context 'when destination is existing' do + context 'when source is list of files' do before { create_test_files(source) } - context "when destination is directory" do + context 'when destination is directory' do let(:source) { %w(file1.txt file2.txt file3.txt) } - let(:destination) { "file.d" } + let(:destination) { 'file.d' } let(:destination_files) { source.map { |s| File.join(destination, s) } } before do @@ -381,26 +381,26 @@ it { expect(destination_files).to all be_an_existing_file } end - context "when destination is not a directory" do + context 'when destination is not a directory' do let(:source) { %w(file1.txt file2.txt file3.txt) } - let(:destination) { "file.txt" } - let(:error_message) { "Multiples sources can only be copied to a directory" } + let(:destination) { 'file.txt' } + let(:error_message) { 'Multiples sources can only be copied to a directory' } before { create_test_files(destination) } - it "raises an appropriate error" do + it 'raises an appropriate error' do expect { @aruba.copy source, destination } .to raise_error ArgumentError, error_message end end - context "when a source is the same like destination" do - let(:source) { "file1.txt" } - let(:destination) { "file1.txt" } + context 'when a source is the same like destination' do + let(:source) { 'file1.txt' } + let(:destination) { 'file1.txt' } before { create_test_files(source) } - it "raises an appropriate error" do + it 'raises an appropriate error' do src_path = File.expand_path(File.join(@aruba.aruba.current_directory, source)) dest_path = File.expand_path(File.join(@aruba.aruba.current_directory, destination)) @@ -410,14 +410,14 @@ end end - context "when a fixture is destination" do - let(:source) { "%/copy/file.txt" } - let(:destination) { "%/copy/file.txt" } + context 'when a fixture is destination' do + let(:source) { '%/copy/file.txt' } + let(:destination) { '%/copy/file.txt' } let(:error_message) do "Using a fixture as destination (#{destination}) is not supported" end - it "raises an appropriate error" do + it 'raises an appropriate error' do expect { @aruba.copy source, destination } .to raise_error ArgumentError, error_message end @@ -425,33 +425,33 @@ end end - context "when source is non-existing" do + context 'when source is non-existing' do it { expect { @aruba.copy source, destination }.to raise_error ArgumentError } end end end - describe "#write_file" do - it "writes file" do - @aruba.write_file(name, "") + describe '#write_file' do + it 'writes file' do + @aruba.write_file(name, '') expect(File.exist?(path)).to be true end end - describe "#write_fixed_size_file" do + describe '#write_fixed_size_file' do let(:file_size) { @file_size } - it "writes a fixed sized file" do + it 'writes a fixed sized file' do @aruba.write_fixed_size_file(name, file_size) expect(File.exist?(path)).to be true expect(File.size(path)).to eq file_size end - it "works with ~ in path name" do - file_path = File.join("~", random_string) + it 'works with ~ in path name' do + file_path = File.join('~', random_string) - @aruba.with_environment "HOME" => File.expand_path(aruba.current_directory) do + @aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do @aruba.write_fixed_size_file(file_path, file_size) expect(File.exist?(File.expand_path(file_path))).to be true @@ -460,65 +460,65 @@ end end - describe "#chmod" do + describe '#chmod' do def actual_permissions - format("%o", File::Stat.new(path).mode)[-4, 4] + format('%o', File::Stat.new(path).mode)[-4, 4] end - let(:permissions) { "0644" } + let(:permissions) { '0644' } before do - @aruba.set_environment_variable "HOME", File.expand_path(@aruba.aruba.current_directory) - File.open(path, "w") { |f| f << "" } + @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) + File.open(path, 'w') { |f| f << '' } @aruba.chmod(permissions, name) end - context "when file exists" do - context "and permissions are given as string" do - it { expect(actual_permissions).to eq("0644") } + context 'when file exists' do + context 'and permissions are given as string' do + it { expect(actual_permissions).to eq('0644') } end - context "and permissions are given as octal number" do + context 'and permissions are given as octal number' do let(:permissions) { 0o644 } - it { expect(actual_permissions).to eq("0644") } + it { expect(actual_permissions).to eq('0644') } end - context "and path has ~ in it" do + context 'and path has ~ in it' do let(:basename) { random_string } - let(:name) { File.join("~", basename) } + let(:name) { File.join('~', basename) } let(:path) { File.join(@aruba.aruba.current_directory, basename) } - it { expect(actual_permissions).to eq("0644") } + it { expect(actual_permissions).to eq('0644') } end end end - describe "#with_file_content" do + describe '#with_file_content' do before do - @aruba.write_file(name, "foo bar baz") + @aruba.write_file(name, 'foo bar baz') end it "checks the given file's full content against the expectations in the passed block" do @aruba.with_file_content name do |full_content| - expect(full_content).to eq "foo bar baz" + expect(full_content).to eq 'foo bar baz' end end - it "works with ~ in path name" do - file_path = File.join("~", random_string) + it 'works with ~ in path name' do + file_path = File.join('~', random_string) - @aruba.with_environment "HOME" => File.expand_path(aruba.current_directory) do - @aruba.write_file(file_path, "foo bar baz") + @aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do + @aruba.write_file(file_path, 'foo bar baz') @aruba.with_file_content file_path do |full_content| - expect(full_content).to eq "foo bar baz" + expect(full_content).to eq 'foo bar baz' end end end context "checking the file's content against the expectations in the block" do - it "is successful when the inner expectations match" do + it 'is successful when the inner expectations match' do expect do @aruba.with_file_content name do |full_content| expect(full_content).to match(/foo/) @@ -538,64 +538,64 @@ def actual_permissions end end - describe "#create_directory" do + describe '#create_directory' do before do - @directory_name = "test_dir" + @directory_name = 'test_dir' @directory_path = File.join(@aruba.aruba.current_directory, @directory_name) end - it "creates a directory" do + it 'creates a directory' do @aruba.create_directory @directory_name expect(File).to exist(File.expand_path(@directory_path)) end end - describe "#read" do - let(:name) { "test.txt" } + describe '#read' do + let(:name) { 'test.txt' } let(:path) { File.join(@aruba.aruba.current_directory, name) } - let(:content) { "asdf" } + let(:content) { 'asdf' } before do - @aruba.set_environment_variable "HOME", File.expand_path(@aruba.aruba.current_directory) + @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) end - context "when does not exist" do + context 'when does not exist' do it { expect { @aruba.read(name) }.to raise_error ArgumentError } end - context "when it exists" do - context "when file" do + context 'when it exists' do + context 'when file' do before do - File.open(File.expand_path(path), "w") { |f| f << content } + File.open(File.expand_path(path), 'w') { |f| f << content } end - context "when normal file" do + context 'when normal file' do it { expect(@aruba.read(name)).to eq [content] } end - context "when binary file" do + 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) { "" } + context 'when is empty file' do + let(:content) { '' } it { expect(@aruba.read(name)).to eq [] } end - context "when path contains ~" do + context 'when path contains ~' do let(:string) { random_string } - let(:name) { File.join("~", string) } + let(:name) { File.join('~', string) } let(:path) { File.join(@aruba.aruba.current_directory, string) } it { expect(@aruba.read(name)).to eq [content] } end end - context "when directory" do - let(:name) { "test.d" } + context 'when directory' do + let(:name) { 'test.d' } before do Aruba.platform.mkdir path @@ -606,49 +606,49 @@ def actual_permissions end end - describe "#list" do - let(:name) { "test.d" } + describe '#list' do + let(:name) { 'test.d' } let(:content) { %w(subdir.1.d subdir.2.d) } let(:path) { File.join(@aruba.aruba.current_directory, name) } before do - @aruba.set_environment_variable "HOME", File.expand_path(@aruba.aruba.current_directory) + @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) end - context "when does not exist" do + context 'when does not exist' do it { expect { @aruba.list(name) }.to raise_error ArgumentError } end - context "when it exists" do - context "when file" do - let(:name) { "test.txt" } + context 'when it exists' do + context 'when file' do + let(:name) { 'test.txt' } before do - File.open(File.expand_path(path), "w") { |f| f << content } + File.open(File.expand_path(path), 'w') { |f| f << content } end - context "when normal file" do + context 'when normal file' do it { expect { @aruba.list(name) }.to raise_error ArgumentError } end end - context "when directory" do + context 'when directory' do before do Aruba.platform.mkdir path Array(content).each { |it| Aruba.platform.mkdir File.join(path, it) } end - context "when has subdirectories" do - context "when is simple path" do + context 'when has subdirectories' do + context 'when is simple path' do let(:existing_files) { @aruba.list(name) } let(:expected_files) { content.map { |c| File.join(name, c) }.sort } it { expect(expected_files - existing_files).to be_empty } end - context "when path contains ~" do + context 'when path contains ~' do let(:string) { random_string } - let(:name) { File.join("~", string) } + let(:name) { File.join('~', string) } let(:path) { File.join(@aruba.aruba.current_directory, string) } let(:existing_files) { @aruba.list(name) } @@ -658,7 +658,7 @@ def actual_permissions end end - context "when has no subdirectories" do + context 'when has no subdirectories' do let(:content) { [] } it { expect(@aruba.list(name)).to eq [] } @@ -667,21 +667,21 @@ def actual_permissions end end - describe "#remove" do + describe '#remove' do let(:options) { {} } - context "when given an existing file" do - it "removes a single file" do - name = "test.txt" + context 'when given an existing file' do + it 'removes a single file' do + name = 'test.txt' path = File.join(@aruba.aruba.current_directory, name) - File.write(File.expand_path(path), "foo") + File.write(File.expand_path(path), 'foo') @aruba.remove(name) expect(File.exist?(path)).to be false end - it "removes multiple files" do + it 'removes multiple files' do names = %w(file1 file2 file3) paths = names.map { |it| File.join(@aruba.aruba.current_directory, it) } paths.each { |it| File.write(File.expand_path(it), "foo #{it}") } @@ -694,11 +694,11 @@ def actual_permissions end end - it "interprets ~ as referencing the aruba home directory" do + it 'interprets ~ as referencing the aruba home directory' do string = random_string - name = File.join("~", string) + name = File.join('~', string) path = File.join(@aruba.aruba.config.home_directory, string) - File.write(File.expand_path(path), "foo") + File.write(File.expand_path(path), 'foo') @aruba.remove(name) @@ -706,9 +706,9 @@ def actual_permissions end end - context "when given an existing directory" do - it "removes a single directory" do - name = "test.d" + context 'when given an existing directory' do + it 'removes a single directory' do + name = 'test.d' path = File.join(@aruba.aruba.current_directory, name) Aruba.platform.mkdir path @@ -717,7 +717,7 @@ def actual_permissions expect(File.exist?(path)).to be false end - it "removes multiple directories" do + it 'removes multiple directories' do names = %w(directory1 directory2 directory3) paths = names.map { |it| File.join(@aruba.aruba.current_directory, it) } paths.each { |path| Aruba.platform.mkdir path } @@ -730,9 +730,9 @@ def actual_permissions end end - it "interprets ~ as referencing the aruba home directory" do + it 'interprets ~ as referencing the aruba home directory' do string = random_string - name = File.join("~", string) + name = File.join('~', string) path = File.join(@aruba.aruba.config.home_directory, string) Aruba.platform.mkdir path @@ -742,14 +742,14 @@ def actual_permissions end end - context "when given an item that does not exist" do - it "raises an error" do - name = "missing" + context 'when given an item that does not exist' do + it 'raises an error' do + name = 'missing' expect { @aruba.remove(name) }.to raise_error Errno::ENOENT end - it "raises no error when forced to delete the file" do - name = "missing" + it 'raises no error when forced to delete the file' do + name = 'missing' path = File.join(@aruba.aruba.current_directory, name) aggregate_failures do diff --git a/spec/aruba/api/runtime_spec.rb b/spec/aruba/api/runtime_spec.rb index 70a86e84e..b5cb0457d 100644 --- a/spec/aruba/api/runtime_spec.rb +++ b/spec/aruba/api/runtime_spec.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' -RSpec.describe "aruba" do - describe "#config" do +RSpec.describe 'aruba' do + describe '#config' do subject(:config) { aruba.config } - context "when initialized" do + context 'when initialized' do it { is_expected.to eq Aruba.config } end - context "when changed earlier" do - context "values when init" do + context 'when changed earlier' do + context 'values when init' do let(:value) { 20 } before { aruba.config.io_wait_timeout = value } @@ -19,7 +19,7 @@ it { expect(config.io_wait_timeout).to eq value } end - context "default value" do + context 'default value' do let(:value) { 0.1 } # Aruba.config.io_wait_timeout it { expect(config.io_wait_timeout).to eq value } diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index 4efd47bde..e9018b76b 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -1,64 +1,64 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/api" -require "fileutils" -require "time" +require 'spec_helper' +require 'aruba/api' +require 'fileutils' +require 'time' describe Aruba::Api do - include_context "uses aruba API" + include_context 'uses aruba API' - describe "tags" do - describe "@announce_stdout" do + describe 'tags' do + describe '@announce_stdout' do after { @aruba.all_commands.each(&:stop) } - context "enabled" do + context 'enabled' do before do @aruba.aruba.announcer = instance_double Aruba::Platforms::Announcer allow(@aruba.aruba.announcer).to receive(:announce) end - it "announces to stdout exactly once" do + it 'announces to stdout exactly once' do @aruba.run_command_and_stop('echo "hello world"', fail_on_error: false) aggregate_failures do - expect(@aruba.last_command_started.output).to include("hello world") + expect(@aruba.last_command_started.output).to include('hello world') expect(@aruba.aruba.announcer).to have_received(:announce).with(:stdout).once end end end - context "disabled" do - it "does not announce to stdout" do + context 'disabled' 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 - expect(result).not_to include("hello world") - expect(@aruba.last_command_started.output).to include("hello world") + expect(result).not_to include('hello world') + expect(@aruba.last_command_started.output).to include('hello world') end end end end - describe "#set_environment_variable" do + describe '#set_environment_variable' do after do @aruba.all_commands.each(&:stop) end - it "set environment variable" do - @aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "true" - @aruba.run_command_and_stop "env" + it 'set environment variable' do + @aruba.set_environment_variable 'LONG_LONG_ENV_VARIABLE', 'true' + @aruba.run_command_and_stop 'env' expect(@aruba.last_command_started.output) - .to include("LONG_LONG_ENV_VARIABLE=true") + .to include('LONG_LONG_ENV_VARIABLE=true') end - it "overwrites environment variable" do - @aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "true" - @aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "false" - @aruba.run_command_and_stop "env" + it 'overwrites environment variable' do + @aruba.set_environment_variable 'LONG_LONG_ENV_VARIABLE', 'true' + @aruba.set_environment_variable 'LONG_LONG_ENV_VARIABLE', 'false' + @aruba.run_command_and_stop 'env' expect(@aruba.last_command_started.output) - .to include("LONG_LONG_ENV_VARIABLE=false") + .to include('LONG_LONG_ENV_VARIABLE=false') end end end diff --git a/spec/aruba/aruba_path_spec.rb b/spec/aruba/aruba_path_spec.rb index dc604199a..cc74e4ef9 100644 --- a/spec/aruba/aruba_path_spec.rb +++ b/spec/aruba/aruba_path_spec.rb @@ -1,56 +1,56 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/aruba_path" +require 'spec_helper' +require 'aruba/aruba_path' RSpec.describe Aruba::ArubaPath do - describe "#pop" do - it "pops a previously pushed path element" do - path = described_class.new("path/to/dir") - path.push "subdir" + describe '#pop' do + it 'pops a previously pushed path element' do + path = described_class.new('path/to/dir') + path.push 'subdir' popped = path.pop aggregate_failures do - expect(popped).to eq "subdir" - expect(path.to_s).to eq "path/to/dir" + expect(popped).to eq 'subdir' + expect(path.to_s).to eq 'path/to/dir' end end end - describe "#to_s" do - it "returns the path given in the initializer" do - path = described_class.new("path/to/dir") - expect(path.to_s).to eq "path/to/dir" + describe '#to_s' do + it 'returns the path given in the initializer' do + path = described_class.new('path/to/dir') + expect(path.to_s).to eq 'path/to/dir' end - it "combines pushed relative path elements" do - path = described_class.new("path/to") - path << "dir" - expect(path.to_s).to eq "path/to/dir" + it 'combines pushed relative path elements' do + path = described_class.new('path/to') + path << 'dir' + expect(path.to_s).to eq 'path/to/dir' end - it "replaces earlier elements when an absolute path was pushed" do - path = described_class.new("path/to") - path << "/foo" - expect(path.to_s).to eq "/foo" + it 'replaces earlier elements when an absolute path was pushed' do + path = described_class.new('path/to') + path << '/foo' + expect(path.to_s).to eq '/foo' end - it "replaces earlier elements when a home directory-relative path was pushed" do - path = described_class.new("path/to") - path << "~/foo" - expect(path.to_s).to eq "~/foo" + it 'replaces earlier elements when a home directory-relative path was pushed' do + path = described_class.new('path/to') + path << '~/foo' + expect(path.to_s).to eq '~/foo' end end - describe "#[]" do - let(:path) { described_class.new("path/to/dir") } + describe '#[]' do + let(:path) { described_class.new('path/to/dir') } - context "when single index" do - it { expect(path[0]).to eq "p" } + context 'when single index' do + it { expect(path[0]).to eq 'p' } end - context "when range" do - it { expect(path[0..1]).to eq "pa" } + context 'when range' do + it { expect(path[0..1]).to eq 'pa' } end end end diff --git a/spec/aruba/basic_configuration_spec.rb b/spec/aruba/basic_configuration_spec.rb index 1f9f3a0a8..9d590ef6c 100644 --- a/spec/aruba/basic_configuration_spec.rb +++ b/spec/aruba/basic_configuration_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::BasicConfiguration do - it_behaves_like "a basic configuration" + it_behaves_like 'a basic configuration' end diff --git a/spec/aruba/command_monitor_spec.rb b/spec/aruba/command_monitor_spec.rb index ffd91f0de..4d3d3d1a9 100644 --- a/spec/aruba/command_monitor_spec.rb +++ b/spec/aruba/command_monitor_spec.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::CommandMonitor do let(:monitor) { described_class.new(announcer: announcer) } let(:announcer) { instance_double(Aruba::Platforms::Announcer) } let(:foo_process) do - instance_double(Aruba::Processes::InProcess, commandline: "foo", + instance_double(Aruba::Processes::InProcess, commandline: 'foo', stop: nil, stdout: "foo_stdout\n", stderr: "foo_stderr\n") end let(:bar_process) do - instance_double(Aruba::Processes::InProcess, commandline: "bar", + instance_double(Aruba::Processes::InProcess, commandline: 'bar', stop: nil, stdout: "bar_stdout\n", stderr: "bar_stderr\n") @@ -23,30 +23,30 @@ monitor.register_command(bar_process) end - describe "#find" do - it "find the process with the given name" do - expect(monitor.find("foo")).to eq foo_process + describe '#find' do + it 'find the process with the given name' do + expect(monitor.find('foo')).to eq foo_process end - it "fails if no process with the given name exists" do - expect { monitor.find("boofar") }.to raise_error Aruba::CommandNotFoundError + it 'fails if no process with the given name exists' do + expect { monitor.find('boofar') }.to raise_error Aruba::CommandNotFoundError end end - describe "#all_stdout" do - it "combines stdout from all registered processs" do + describe '#all_stdout' do + it 'combines stdout from all registered processs' do expect(monitor.all_stdout).to eq "foo_stdout\nbar_stdout\n" end end - describe "#all_stderr" do - it "combines stderr from all registered processs" do + describe '#all_stderr' do + it 'combines stderr from all registered processs' do expect(monitor.all_stderr).to eq "foo_stderr\nbar_stderr\n" end end - describe "#all_output" do - it "combines stdout and stderr from all registered processs" do + describe '#all_output' do + it 'combines stdout and stderr from all registered processs' do expect(monitor.all_output) .to eq "foo_stdout\nbar_stdout\nfoo_stderr\nbar_stderr\n" end diff --git a/spec/aruba/command_spec.rb b/spec/aruba/command_spec.rb index cb3c90ee1..b2fc5c91f 100644 --- a/spec/aruba/command_spec.rb +++ b/spec/aruba/command_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::Command do let(:command) do described_class.new( - "true", + 'true', event_bus: event_bus, exit_timeout: exit_timeout, io_wait_timeout: io_wait_timeout, @@ -20,77 +20,77 @@ let(:event_bus) { instance_double(Aruba::EventBus) } let(:exit_timeout) { 0.01 } let(:io_wait_timeout) { 0.01 } - let(:working_directory) { File.expand_path(".") } + let(:working_directory) { File.expand_path('.') } let(:environment) { ENV.to_hash } let(:main_class) { nil } let(:stop_signal) { nil } let(:startup_wait_time) { 0.01 } - describe "#start" do + describe '#start' do before do allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStarted) command.start end - it "leaves the command in the started state" do + it 'leaves the command in the started state' do expect(command).to be_started end end - describe "#stop" do + describe '#stop' do before do allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStarted) allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped) command.start end - it "stops the command" do + it 'stops the command' do command.stop expect(command).to be_stopped end - it "notifies the event bus" do + it 'notifies the event bus' do command.stop expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end - it "notifies the event bus only once per run" do + it 'notifies the event bus only once per run' do command.stop command.stop expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end - it "prevents #terminate from notifying the event bus" do + it 'prevents #terminate from notifying the event bus' do command.stop command.terminate expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end end - describe "#terminate" do + describe '#terminate' do before do allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStarted) allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped) command.start end - it "stops the command" do + it 'stops the command' do command.terminate expect(command).to be_stopped end - it "notifies the event bus" do + it 'notifies the event bus' do command.terminate expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end - it "notifies the event bus only once per run" do + it 'notifies the event bus only once per run' do command.terminate command.terminate expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end - it "prevents #stop from notifying the event bus" do + it 'prevents #stop from notifying the event bus' do command.terminate command.stop expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once diff --git a/spec/aruba/configuration_spec.rb b/spec/aruba/configuration_spec.rb index da91bcd9e..1d8652ea7 100644 --- a/spec/aruba/configuration_spec.rb +++ b/spec/aruba/configuration_spec.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::Configuration do - it_behaves_like "a basic configuration" + it_behaves_like 'a basic configuration' - context "when is modified" do + context 'when is modified' do let(:config) { described_class.new } - it "does not allow bad values" do + it 'does not allow bad values' do expect { config.fixtures_directories = [1, 2] }.to raise_error ParamContractError end end diff --git a/spec/aruba/event_bus_spec.rb b/spec/aruba/event_bus_spec.rb index f5372fb3d..3f1e3daf0 100644 --- a/spec/aruba/event_bus_spec.rb +++ b/spec/aruba/event_bus_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' describe Aruba::EventBus do let(:bus) { described_class.new(registry) } @@ -17,42 +17,42 @@ let(:another_event_instance) { another_event_klass.new } before do - stub_const("Events::TestEvent", Class.new) - stub_const("Events::AnotherTestEvent", Class.new) - stub_const("MyHandler", Class.new { def call(*); end }) - stub_const("MyMalformedHandler", Class.new) + stub_const('Events::TestEvent', Class.new) + stub_const('Events::AnotherTestEvent', Class.new) + stub_const('MyHandler', Class.new { def call(*); end }) + stub_const('MyMalformedHandler', Class.new) end - describe "#notify" do + describe '#notify' do before do bus.register(:test_event) do |event| @received_payload = event end end - context "when subscribed to the event" do - it "calls the block with an instance of the event passed as payload" do + context 'when subscribed to the event' do + it 'calls the block with an instance of the event passed as payload' do bus.notify event_instance expect(@received_payload).to eq(event_instance) end end - context "when not subscribed to the event" do - it "does not call the block" do + context 'when not subscribed to the event' do + it 'does not call the block' do bus.notify another_event_instance expect(@received_payload).to be_nil end end - context "when event is not an event instance" do - it "raises an error" do + context 'when event is not an event instance' do + it 'raises an error' do expect { bus.notify event_klass }.to raise_error ArgumentError end end end - describe "#register" do - context "when registering an event multiple times" do + describe '#register' do + context 'when registering an event multiple times' do let(:received_events) { [] } before do @@ -64,14 +64,14 @@ end end - it "keeps all registrations" do + it 'keeps all registrations' do bus.notify event_instance expect(received_events).to eq [event_instance, event_instance] end end - context "when event id is a symbol" do + context 'when event id is a symbol' do let(:received_payload) { [] } before do @@ -85,7 +85,7 @@ it { expect(received_payload).to include event_instance } end - context "when multiple event ids are given" do + context 'when multiple event ids are given' do let(:received_payload) { [] } before do @@ -94,14 +94,14 @@ end end - it "handles all passed in events" do + it 'handles all passed in events' do bus.notify event_instance bus.notify another_event_instance expect(received_payload).to eq [event_instance, another_event_instance] end end - context "when valid custom handler" do + context 'when valid custom handler' do before do bus.register(:test_event, MyHandler.new) end @@ -109,8 +109,8 @@ it { expect { bus.notify event_instance }.not_to raise_error } end - context "when no handler is given" do - it "raises an ArgumentError" do + context 'when no handler is given' do + it 'raises an ArgumentError' do expect { bus.register(event_klass) }.to raise_error ArgumentError end end diff --git a/spec/aruba/hooks_spec.rb b/spec/aruba/hooks_spec.rb index 8d5e13a61..4941d13d6 100644 --- a/spec/aruba/hooks_spec.rb +++ b/spec/aruba/hooks_spec.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' describe Aruba::Hooks do let(:hooks) { described_class.new } - it "executes a stored hook" do + it 'executes a stored hook' do hook_was_run = false 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 + it 'executes a stored hook that takes multiple arguments' do hook_values = [] hooks.append :hook_label, ->(a, b, c) { hook_values = [a, b, c] } hooks.execute :hook_label, self, 1, 2, 3 diff --git a/spec/aruba/in_config_wrapper_spec.rb b/spec/aruba/in_config_wrapper_spec.rb index ccf6b868e..302b70e59 100644 --- a/spec/aruba/in_config_wrapper_spec.rb +++ b/spec/aruba/in_config_wrapper_spec.rb @@ -1,31 +1,31 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::InConfigWrapper do subject(:wrapper) { described_class.new(config) } let(:config) { {} } - context "when option is defined" do + context 'when option is defined' do before do config[:opt] = true end - context "when valid" do + context 'when valid' do it { expect(wrapper.opt).to be true } end - context "when one tries to pass arguments to option" do + context 'when one tries to pass arguments to option' do it { - expect { wrapper.opt("arg") } - .to raise_error ArgumentError, "Options take no argument" + expect { wrapper.opt('arg') } + .to raise_error ArgumentError, 'Options take no argument' } end end - context "when option is not defined" do - it "raises an error" do + context 'when option is not defined' do + it 'raises an error' do expect { wrapper.opt }.to raise_error NoMethodError end end diff --git a/spec/aruba/jruby_spec.rb b/spec/aruba/jruby_spec.rb index d71c1d6f3..ba0380dd6 100644 --- a/spec/aruba/jruby_spec.rb +++ b/spec/aruba/jruby_spec.rb @@ -1,80 +1,80 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/api" +require 'spec_helper' +require 'aruba/api' -describe "Aruba JRuby Startup Helper" do +describe 'Aruba JRuby Startup Helper' do include Aruba::Api let(:rb_config) { instance_double(Hash) } let(:command) do instance_double(Aruba::Processes::BasicProcess, environment: command_environment) end - let(:command_environment) { { "JRUBY_OPTS" => "--1.9", "JAVA_OPTS" => "-Xdebug" } } + let(:command_environment) { { 'JRUBY_OPTS' => '--1.9', 'JAVA_OPTS' => '-Xdebug' } } before do Aruba.config.reset # Define before :command hook - load "aruba/config/jruby.rb" + load 'aruba/config/jruby.rb' end - context "when running under some MRI Ruby" do + context 'when running under some MRI Ruby' do before do - stub_const("RUBY_PLATFORM", "x86_64-chocolate") + stub_const('RUBY_PLATFORM', 'x86_64-chocolate') end - it "keeps the existing JRUBY_OPTS and JAVA_OPTS environment values" do + it 'keeps the existing JRUBY_OPTS and JAVA_OPTS environment values' do # Run defined before :command hook Aruba.config.run_before_hook :command, self, command aggregate_failures do - expect(command_environment["JRUBY_OPTS"]).to eq "--1.9" - expect(command_environment["JAVA_OPTS"]).to eq "-Xdebug" + expect(command_environment['JRUBY_OPTS']).to eq '--1.9' + expect(command_environment['JAVA_OPTS']).to eq '-Xdebug' end end end - context "when running under JRuby but not on Solaris" do + context 'when running under JRuby but not on Solaris' do before do - unless RUBY_PLATFORM == "java" - stub_const "RUBY_PLATFORM", "java" - stub_const "JRUBY_VERSION", "9.2.0.0" + unless RUBY_PLATFORM == 'java' + stub_const 'RUBY_PLATFORM', 'java' + stub_const 'JRUBY_VERSION', '9.2.0.0' end - stub_const "RbConfig::CONFIG", rb_config + stub_const 'RbConfig::CONFIG', rb_config - allow(rb_config).to receive(:[]).with("host_os").and_return("foo-os") + allow(rb_config).to receive(:[]).with('host_os').and_return('foo-os') end - it "updates the existing JRuby but not Java option values" do + it 'updates the existing JRuby but not Java option values' do # Run defined before :command hook Aruba.config.run_before_hook :command, self, command aggregate_failures do - expect(command_environment["JRUBY_OPTS"]).to eq "--dev -X-C --1.9" - expect(command_environment["JAVA_OPTS"]).to eq "-Xdebug" + expect(command_environment['JRUBY_OPTS']).to eq '--dev -X-C --1.9' + expect(command_environment['JAVA_OPTS']).to eq '-Xdebug' end end end - context "when running under JRuby on Solaris" do + context 'when running under JRuby on Solaris' do before do - unless RUBY_PLATFORM == "java" - stub_const "RUBY_PLATFORM", "java" - stub_const "JRUBY_VERSION", "9.2.0.0" + unless RUBY_PLATFORM == 'java' + stub_const 'RUBY_PLATFORM', 'java' + stub_const 'JRUBY_VERSION', '9.2.0.0' end - stub_const "RbConfig::CONFIG", rb_config + stub_const 'RbConfig::CONFIG', rb_config - allow(rb_config).to receive(:[]).with("host_os").and_return("solaris") + allow(rb_config).to receive(:[]).with('host_os').and_return('solaris') end - it "keeps the existing JRuby and Java option values" do + it 'keeps the existing JRuby and Java option values' do # Run defined before :command hook Aruba.config.run_before_hook :command, self, command aggregate_failures do - expect(command_environment["JRUBY_OPTS"]).to eq "--dev -X-C --1.9" - expect(command_environment["JAVA_OPTS"]).to eq "-d32 -Xdebug" + expect(command_environment['JRUBY_OPTS']).to eq '--dev -X-C --1.9' + expect(command_environment['JAVA_OPTS']).to eq '-d32 -Xdebug' end end end diff --git a/spec/aruba/matchers/command/have_output_size_spec.rb b/spec/aruba/matchers/command/have_output_size_spec.rb index 0ee6fa3d9..4a48ef385 100644 --- a/spec/aruba/matchers/command/have_output_size_spec.rb +++ b/spec/aruba/matchers/command/have_output_size_spec.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' -RSpec.describe "Output Matchers" do - describe "#to_have_output_size" do - context "when actual is a string" do - let(:obj) { "string" } +RSpec.describe 'Output Matchers' do + describe '#to_have_output_size' do + context 'when actual is a string' do + let(:obj) { 'string' } before do allow(Aruba.platform).to receive(:deprecated) end - it "matches when the string is the given size" do + it 'matches when the string is the given size' do expect(obj).to have_output_size 6 end - it "does not match when the string does not have the given size" do + it 'does not match when the string does not have the given size' do expect(obj).not_to have_output_size 5 end - it "emits a deprecation warning" do + it 'emits a deprecation warning' do aggregate_failures do expect(obj).to have_output_size 6 expect(Aruba.platform).to have_received(:deprecated) @@ -27,17 +27,17 @@ end end - context "when actual is a command" do + context 'when actual is a command' do let(:cmd) { "echo #{output}" } - let(:output) { "hello world" } + let(:output) { 'hello world' } before { run_command(cmd) } - it "matches directly on the command itself" do + it 'matches directly on the command itself' do expect(last_command_started).to have_output_size "#{output}\n".length end - it "does not match if output size is different" do + it 'does not match if output size is different' do expect(last_command_started).not_to have_output_size "#{output}\n".length + 1 end end diff --git a/spec/aruba/matchers/command_spec.rb b/spec/aruba/matchers/command_spec.rb index 51275177a..49a27407f 100644 --- a/spec/aruba/matchers/command_spec.rb +++ b/spec/aruba/matchers/command_spec.rb @@ -1,54 +1,54 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' -RSpec.describe "Command Matchers" do - include_context "uses aruba API" +RSpec.describe 'Command Matchers' do + include_context 'uses aruba API' - describe "#to_have_exit_status" do - let(:cmd) { "true" } + describe '#to_have_exit_status' do + let(:cmd) { 'true' } before { run_command(cmd) } - context "when has exit 0" do + context 'when has exit 0' do it { expect(last_command_started).to have_exit_status 0 } end - context "when does not have exit 0" do - let(:cmd) { "false" } + context 'when does not have exit 0' do + let(:cmd) { 'false' } it { expect(last_command_started).not_to have_exit_status 0 } end end - describe "#to_be_successfully_executed_" do - let(:cmd) { "true" } + describe '#to_be_successfully_executed_' do + let(:cmd) { 'true' } before { run_command(cmd) } - context "when has exit 0" do + context 'when has exit 0' do it { expect(last_command_started).to be_successfully_executed } end - context "when does not have exit 0" do - let(:cmd) { "false" } + context 'when does not have exit 0' do + let(:cmd) { 'false' } it { expect(last_command_started).not_to be_successfully_executed } end end - describe "#to_have_output" do + describe '#to_have_output' do let(:cmd) { "echo #{output}" } - let(:output) { "hello world" } + let(:output) { 'hello world' } - context "when have output hello world on stdout" do + context 'when have output hello world on stdout' do 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 commands must have the output" do + context 'when multiple commands output hello world on stdout' do + context 'and all commands must have the output' do before do run_command(cmd) run_command(cmd) @@ -57,17 +57,17 @@ it { expect(all_commands).to all have_output output } end - context "and any command can have the output" do + context 'and any command can have the output' do before do run_command(cmd) - run_command("echo hello universe") + run_command('echo hello universe') end it { expect(all_commands).to include have_output(output) } end end - context "when have output hello world on stderr" do + context 'when have output hello world on stderr' do let(:cmd) { "sh -c \"echo #{output} >&2\"" } before { run_command(cmd) } @@ -75,24 +75,24 @@ it { expect(last_command_started).to have_output output } end - context "when not has output" do + context 'when not has output' do before { run_command(cmd) } - it { expect(last_command_started).not_to have_output "hello universe" } + it { expect(last_command_started).not_to have_output 'hello universe' } end end - describe "#to_have_output_on_stdout" do + describe '#to_have_output_on_stdout' do let(:cmd) { "echo #{output}" } - let(:output) { "hello world" } + let(:output) { 'hello world' } - context "when have output hello world on stdout" do + context 'when have output hello world on stdout' do 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 + context 'when have output hello world on stderr' do let(:cmd) { "sh -c \"echo #{output} >&2\"" } before { run_command(cmd) } @@ -100,24 +100,24 @@ it { expect(last_command_started).not_to have_output_on_stdout output } end - context "when not has output" do + context 'when not has output' do before { run_command(cmd) } - it { expect(last_command_started).not_to have_output_on_stdout "hello universe" } + it { expect(last_command_started).not_to have_output_on_stdout 'hello universe' } end end - describe "#to_have_output_on_stderr" do + describe '#to_have_output_on_stderr' do let(:cmd) { "echo #{output}" } - let(:output) { "hello world" } + let(:output) { 'hello world' } - context "when have output hello world on stdout" do + context 'when have output hello world on stdout' do 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 + context 'when have output hello world on stderr' do let(:cmd) { "sh -c \"echo #{output} >&2\"" } before { run_command(cmd) } @@ -125,10 +125,10 @@ it { expect(last_command_started).to have_output_on_stderr output } end - context "when not has output" do + context 'when not has output' do before { run_command(cmd) } - it { expect(last_command_started).not_to have_output_on_stderr "hello universe" } + it { expect(last_command_started).not_to have_output_on_stderr 'hello universe' } end end end diff --git a/spec/aruba/matchers/directory_spec.rb b/spec/aruba/matchers/directory_spec.rb index b61d16bff..a7d2e362a 100644 --- a/spec/aruba/matchers/directory_spec.rb +++ b/spec/aruba/matchers/directory_spec.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/matchers/directory" -require "fileutils" +require 'spec_helper' +require 'aruba/matchers/directory' +require 'fileutils' -RSpec.describe "Directory Matchers" do - include_context "uses aruba API" +RSpec.describe 'Directory Matchers' do + include_context 'uses aruba API' - describe "to_be_an_existing_directory" do - let(:name) { "test.d" } + describe 'to_be_an_existing_directory' do + let(:name) { 'test.d' } let(:path) { @aruba.expand_path(name) } - context "when directory exists" do + context 'when directory exists' do before do FileUtils.mkdir_p path end @@ -19,37 +19,37 @@ it { expect(name).to be_an_existing_directory } end - context "when directory does not exist" do + context 'when directory does not exist' do it { expect(name).not_to be_an_existing_directory } end end - describe "to_have_sub_directory" do - let(:name) { "test.d" } + describe 'to_have_sub_directory' do + let(:name) { 'test.d' } let(:path) { @aruba.expand_path(name) } let(:content) { %w(subdir.1.d subdir.2.d) } - context "when directory exists" do + context 'when directory exists' do before do FileUtils.mkdir_p path Array(content).each { |p| Dir.mkdir File.join(path, p) } end - context "when single directory" do - it { expect(name).to have_sub_directory("subdir.1.d") } + context 'when single directory' do + it { expect(name).to have_sub_directory('subdir.1.d') } end - context "when multiple directories" do - it { expect(name).to have_sub_directory(["subdir.1.d", "subdir.2.d"]) } + context 'when multiple directories' do + it { expect(name).to have_sub_directory(['subdir.1.d', 'subdir.2.d']) } end - context "when non existing directory" do - it { expect(name).not_to have_sub_directory("subdir.3.d") } + context 'when non existing directory' do + it { expect(name).not_to have_sub_directory('subdir.3.d') } end end - context "when directory does not exist" do - it { expect(name).not_to have_sub_directory("subdir") } + context 'when directory does not exist' do + it { expect(name).not_to have_sub_directory('subdir') } end end end diff --git a/spec/aruba/matchers/file_spec.rb b/spec/aruba/matchers/file_spec.rb index d1e9a4221..154a15ed8 100644 --- a/spec/aruba/matchers/file_spec.rb +++ b/spec/aruba/matchers/file_spec.rb @@ -1,135 +1,135 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/matchers/file" +require 'spec_helper' +require 'aruba/matchers/file' -RSpec.describe "File Matchers" do - include_context "uses aruba API" +RSpec.describe 'File Matchers' do + include_context 'uses aruba API' - describe "#be_an_existing_file" do + describe '#be_an_existing_file' do let(:name) { @file_name } - context "when file exists" do + context 'when file exists' do before { create_test_files(name) } it { expect(name).to be_an_existing_file } end - context "when file does not exist" do + context 'when file does not exist' do it { expect(name).not_to be_an_existing_file } end - context "when contains ~" do - let(:name) { File.join("~", random_string) } + context 'when contains ~' do + let(:name) { File.join('~', random_string) } before do - @aruba.with_environment "HOME" => expand_path(".") do + @aruba.with_environment 'HOME' => expand_path('.') do create_test_files(name) end end it do - @aruba.with_environment "HOME" => expand_path(".") do + @aruba.with_environment 'HOME' => expand_path('.') do expect(name).to be_an_existing_file end end end end - describe "#have_file_content" do - context "when file exists" do + describe '#have_file_content' do + context 'when file exists' do before do - Aruba.platform.write_file(@file_path, "aba") + Aruba.platform.write_file(@file_path, 'aba') end - context "and file content is exactly equal string" do - it { expect(@file_name).to have_file_content("aba") } + context 'and file content is exactly equal string' do + it { expect(@file_name).to have_file_content('aba') } end - context "and file content contains string" do + context 'and file content contains string' do it { expect(@file_name).to have_file_content(/b/) } end - context "and file content is not exactly equal string" do - it { expect(@file_name).not_to have_file_content("c") } + context 'and file content is not exactly equal string' do + it { expect(@file_name).not_to have_file_content('c') } end - context "and file content not contains string" do + context 'and file content not contains string' do it { expect(@file_name).not_to have_file_content(/c/) } end context 'when other matchers is given which matches a string start with "a"' do - it { expect(@file_name).to have_file_content(a_string_starting_with("a")) } + it { expect(@file_name).to have_file_content(a_string_starting_with('a')) } end end - context "when file does not exist" do - it { expect(@file_name).not_to have_file_content("a") } + context 'when file does not exist' do + it { expect(@file_name).not_to have_file_content('a') } end - describe "description" do - context "when string" do - it { expect(have_file_content("a").description).to eq('have file content: "a"') } + describe 'description' do + context 'when string' do + it { expect(have_file_content('a').description).to eq('have file content: "a"') } end - context "when regexp" do - it { expect(have_file_content(/a/).description).to eq("have file content: /a/") } + context 'when regexp' do + it { expect(have_file_content(/a/).description).to eq('have file content: /a/') } end - it "is correct when using a matcher" do - expect(have_file_content(a_string_starting_with("a")).description) + it 'is correct when using a matcher' do + expect(have_file_content(a_string_starting_with('a')).description) .to eq('have file content: a string starting with "a"') end end - describe "failure messages" do + describe 'failure messages' do before do - Aruba.platform.write_file(@file_path, "aba") + Aruba.platform.write_file(@file_path, 'aba') end def fail_with(message) raise_error(RSpec::Expectations::ExpectationNotMetError, message) end - example "for a string" do + example 'for a string' do expect do - expect(@file_name).to have_file_content("z") + expect(@file_name).to have_file_content('z') end.to fail_with('expected "aba" to have file content: "z"') end - example "for a regular expression" do + example 'for a regular expression' do expect do expect(@file_name).to have_file_content(/z/) end.to fail_with('expected "aba" to have file content: /z/') end - example "for a matcher" do + example 'for a matcher' do expect do - expect(@file_name).to have_file_content(a_string_starting_with("z")) + expect(@file_name).to have_file_content(a_string_starting_with('z')) end.to fail_with 'expected "aba" to have file content: a string starting with "z"' end end end - describe "#have_same_file_content_as" do + describe '#have_same_file_content_as' do let(:file_name) { @file_name } let(:file_path) { @file_path } - let(:reference_file) { "fixture" } + let(:reference_file) { 'fixture' } before do - @aruba.write_file(@file_name, "foo bar baz") + @aruba.write_file(@file_name, 'foo bar baz') @aruba.write_file(reference_file, reference_file_content) end - context "when files are the same" do - let(:reference_file_content) { "foo bar baz" } + context 'when files are the same' do + let(:reference_file_content) { 'foo bar baz' } - context "and this is expected" do + context 'and this is expected' do it { expect(file_name).to have_same_file_content_as reference_file } end - context "and this is not expected" do + context 'and this is not expected' do it do expect { expect(file_name).not_to have_same_file_content_as reference_file } .to raise_error RSpec::Expectations::ExpectationNotMetError @@ -137,14 +137,14 @@ def fail_with(message) end end - context "when files are not the same" do - let(:reference_file_content) { "bar" } + context 'when files are not the same' do + let(:reference_file_content) { 'bar' } - context "and this is expected" do + context 'and this is expected' do it { expect(file_name).not_to have_same_file_content_as reference_file } end - context "and this is not expected" do + context 'and this is not expected' do it do expect { expect(file_name).to have_same_file_content_as reference_file } .to raise_error RSpec::Expectations::ExpectationNotMetError @@ -154,26 +154,26 @@ def fail_with(message) end # FIXME: This basically checks a_file_with_same_content_as as an alias - describe "include a_file_with_same_content_as" do - let(:reference_file) { "fixture" } - let(:reference_file_content) { "foo bar baz" } - let(:file_with_same_content) { "file_a.txt" } - let(:file_with_different_content) { "file_b.txt" } + describe 'include a_file_with_same_content_as' do + let(:reference_file) { 'fixture' } + let(:reference_file_content) { 'foo bar baz' } + let(:file_with_same_content) { 'file_a.txt' } + let(:file_with_different_content) { 'file_b.txt' } 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...") + @aruba.write_file(file_with_different_content, 'Some different content here...') end - context "when the array of files includes a file with the same content" do + context 'when the array of files includes a file with the same content' do let(:files) { [file_with_different_content, file_with_same_content] } - context "and this is expected" do + context 'and this is expected' do it { expect(files).to include a_file_with_same_content_as reference_file } end - context "and this is not expected" do + 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 @@ -181,14 +181,14 @@ def fail_with(message) end end - context "when the array of files does not include a file with the same content" do + context 'when the array of files does not include a file with the same content' do let(:files) { [file_with_different_content] } - context "and this is expected" do + context 'and this is expected' do it { expect(files).not_to include a_file_with_same_content_as reference_file } end - context "and this is not expected" do + 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 @@ -197,122 +197,122 @@ def fail_with(message) end end - describe "#have_file_size" do - context "when file exists" do + describe '#have_file_size' do + context 'when file exists' do before do - Aruba.platform.write_file(@file_path, "") + Aruba.platform.write_file(@file_path, '') end - context "and file size is equal" do + context 'and file size is equal' do it { expect(@file_name).to have_file_size(0) } end - context "and file size is not equal" do + context 'and file size is not equal' do it { expect(@file_name).not_to have_file_size(1) } end end - context "when file does not exist" do + context 'when file does not exist' do it { expect(@file_name).not_to have_file_size(0) } end end - describe "#be_an_existing_executable" do - context "when file exists and is executable" do - let(:file) { Gem.win_platform? ? "foo.bat" : "foo" } + describe '#be_an_existing_executable' do + context 'when file exists and is executable' do + let(:file) { Gem.win_platform? ? 'foo.bat' : 'foo' } before do - @aruba.write_file(file, "") + @aruba.write_file(file, '') @aruba.chmod(0x755, file) unless Gem.win_platform? end - it "matches" do + it 'matches' do expect(file).to be_an_existing_executable end end - context "when file exists and is not executable" do - let(:file) { Gem.win_platform? ? "foo.txt" : "foo" } + context 'when file exists and is not executable' do + let(:file) { Gem.win_platform? ? 'foo.txt' : 'foo' } before do - @aruba.write_file(file, "") + @aruba.write_file(file, '') end - it "does not match" do + it 'does not match' do expect(file).not_to be_an_existing_executable end end - context "when file does not exist" do - let(:file) { Gem.win_platform? ? "foo.bat" : "foo" } + context 'when file does not exist' do + let(:file) { Gem.win_platform? ? 'foo.bat' : 'foo' } - it "does not match" do + it 'does not match' do expect(file).not_to be_an_existing_executable end end end - describe "#be_a_command_found_in_path" do - context "when file exists in path and is executable" do - let(:file) { Gem.win_platform? ? "foo.bat" : "foo" } + describe '#be_a_command_found_in_path' do + context 'when file exists in path and is executable' do + let(:file) { Gem.win_platform? ? 'foo.bat' : 'foo' } before do - prepend_environment_variable("PATH", expand_path(".") + File::PATH_SEPARATOR) - @aruba.write_file(file, "") + prepend_environment_variable('PATH', expand_path('.') + File::PATH_SEPARATOR) + @aruba.write_file(file, '') @aruba.chmod(0x755, file) unless Gem.win_platform? end - it "matches" do + it 'matches' do expect(file).to be_a_command_found_in_path end end - context "when file exists and is executable but is not in path" do - let(:file) { Gem.win_platform? ? "foo.bat" : "foo" } + context 'when file exists and is executable but is not in path' do + let(:file) { Gem.win_platform? ? 'foo.bat' : 'foo' } before do - @aruba.write_file(file, "") + @aruba.write_file(file, '') @aruba.chmod(0x755, file) unless Gem.win_platform? end - it "does not match" do + it 'does not match' do expect(file).not_to be_a_command_found_in_path end end - context "when file exists in path and is not executable" do - let(:file) { Gem.win_platform? ? "foo.txt" : "foo" } + context 'when file exists in path and is not executable' do + let(:file) { Gem.win_platform? ? 'foo.txt' : 'foo' } before do - prepend_environment_variable("PATH", expand_path(".") + File::PATH_SEPARATOR) - @aruba.write_file(file, "") + prepend_environment_variable('PATH', expand_path('.') + File::PATH_SEPARATOR) + @aruba.write_file(file, '') end - it "does not match" do + it 'does not match' do expect(file).not_to be_a_command_found_in_path end end - context "when file does not exist" do - let(:file) { Gem.win_platform? ? "foo.bat" : "foo" } + context 'when file does not exist' do + let(:file) { Gem.win_platform? ? 'foo.bat' : 'foo' } before do - prepend_environment_variable("PATH", expand_path(".") + File::PATH_SEPARATOR) + prepend_environment_variable('PATH', expand_path('.') + File::PATH_SEPARATOR) end - it "does not match" do + it 'does not match' do expect(file).not_to be_a_command_found_in_path end end - context "when the positive matcher fails" do - let(:file) { Gem.win_platform? ? "foo.bat" : "foo" } + context 'when the positive matcher fails' do + let(:file) { Gem.win_platform? ? 'foo.bat' : 'foo' } before do - set_environment_variable "PATH", expand_path(".") + set_environment_variable 'PATH', expand_path('.') end - it "provides the correct path value in the message" do + it 'provides the correct path value in the message' do expect { expect(file).to be_a_command_found_in_path } .to raise_error RSpec::Expectations::ExpectationNotMetError, "expected that command \"#{file}\" can be found" \ @@ -320,16 +320,16 @@ def fail_with(message) end end - context "when the negative matcher fails" do - let(:file) { Gem.win_platform? ? "foo.bat" : "foo" } + context 'when the negative matcher fails' do + let(:file) { Gem.win_platform? ? 'foo.bat' : 'foo' } before do - set_environment_variable("PATH", expand_path(".")) - @aruba.write_file(file, "") + set_environment_variable('PATH', expand_path('.')) + @aruba.write_file(file, '') @aruba.chmod(0x755, file) unless Gem.win_platform? end - it "provides the correct path value in the message" do + it 'provides the correct path value in the message' do expect { expect(file).not_to be_a_command_found_in_path } .to raise_error RSpec::Expectations::ExpectationNotMetError, "expected that command \"#{file}\" cannot be found" \ diff --git a/spec/aruba/matchers/path_spec.rb b/spec/aruba/matchers/path_spec.rb index 5898faa2b..32d276e8a 100644 --- a/spec/aruba/matchers/path_spec.rb +++ b/spec/aruba/matchers/path_spec.rb @@ -1,46 +1,46 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' -require "fileutils" -require "aruba/matchers/path" +require 'fileutils' +require 'aruba/matchers/path' -RSpec.describe "Path Matchers" do - include_context "uses aruba API" +RSpec.describe 'Path Matchers' do + include_context 'uses aruba API' - describe "to_be_an_absolute_path" do + describe 'to_be_an_absolute_path' do let(:name) { @file_name } let(:path) { @aruba.expand_path(name) } - context "when is absolute path" do + context 'when is absolute path' do it { expect(path).to be_an_absolute_path } end - context "when is relative path" do + context 'when is relative path' do it { expect(name).not_to be_an_absolute_path } end end - describe "to_be_an_existing_path" do - context "when file" do - context "exists" do + describe 'to_be_an_existing_path' do + context 'when file' do + context 'exists' do before do - Aruba.platform.write_file(@file_path, "") + Aruba.platform.write_file(@file_path, '') end it { expect(@file_name).to be_an_existing_path } end - context "does not exist" do + context 'does not exist' do it { expect(@file_name).not_to be_an_existing_path } end end - context "when directory" do - let(:name) { "test.d" } + context 'when directory' do + let(:name) { 'test.d' } let(:path) { @aruba.expand_path(name) } - context "exists" do + context 'exists' do before do FileUtils.mkdir_p path end @@ -48,45 +48,45 @@ it { expect(name).to be_an_existing_path } end - context "does not exist" do + context 'does not exist' do it { expect(name).not_to be_an_existing_path } end end end - describe "to have_permissions" do + describe 'to have_permissions' do let(:file_name) { @file_name } let(:file_path) { @file_path } - let(:permissions) { "0644" } + let(:permissions) { '0644' } before do - @aruba.set_environment_variable "HOME", File.expand_path(@aruba.aruba.current_directory) - File.open(file_path, "w") { |f| f << "" } + @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory) + File.open(file_path, 'w') { |f| f << '' } @aruba.chmod(permissions, file_name) end - context "when file exists" do - context "and should have the same permissions" do - context "and permissions are given as string" do + context 'when file exists' do + context 'and should have the same permissions' do + context 'and permissions are given as string' do it { expect(file_name).to have_permissions permissions } end - context "and permissions are given as octal number" do + context 'and permissions are given as octal number' do let(:permissions) { 0o644 } it { expect(file_name).to have_permissions permissions } end - context "and path includes ~" do + context 'and path includes ~' do let(:string) { random_string } - let(:file_name) { File.join("~", string) } + let(:file_name) { File.join('~', string) } let(:file_path) { File.join(@aruba.aruba.current_directory, string) } it { expect(file_name).to have_permissions permissions } end - context "but the permissions are different" do + context 'but the permissions are different' do let(:expected_permissions) { 0o666 } it do @@ -96,14 +96,14 @@ end end - context "and should not have the same permissions" do - context "and permissions are different" do + context 'and should not have the same permissions' do + context 'and permissions are different' do let(:different_permissions) { 0o666 } it { expect(file_name).not_to have_permissions different_permissions } end - context "but permissions are the same" do + context 'but permissions are the same' do let(:different_permissions) { 0o644 } it do diff --git a/spec/aruba/platforms/announcer_spec.rb b/spec/aruba/platforms/announcer_spec.rb index 84db39814..5513596c9 100644 --- a/spec/aruba/platforms/announcer_spec.rb +++ b/spec/aruba/platforms/announcer_spec.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/platforms/announcer" +require 'spec_helper' +require 'aruba/platforms/announcer' RSpec.describe Aruba::Platforms::Announcer do let(:announcer) { described_class.new } - describe "#mode=" do - it "sets the mode to :puts" do + describe '#mode=' do + it 'sets the mode to :puts' do announcer.mode = :puts expect(announcer.mode).to eq :puts end - it "sets the mode to :kernel_puts" do + it 'sets the mode to :kernel_puts' do announcer.mode = :kernel_puts expect(announcer.mode).to eq :kernel_puts end diff --git a/spec/aruba/platforms/simple_table_spec.rb b/spec/aruba/platforms/simple_table_spec.rb index e9ca67c7e..d7c5ce5b6 100644 --- a/spec/aruba/platforms/simple_table_spec.rb +++ b/spec/aruba/platforms/simple_table_spec.rb @@ -1,34 +1,34 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/platform" +require 'spec_helper' +require 'aruba/platform' -RSpec.describe ".simple_table" do - context "when valid hash" do +RSpec.describe '.simple_table' do + context 'when valid hash' do let(:hash) do { - key1: "value", - key2: "value" + key1: 'value', + key2: 'value' } end - let(:rows) { ["# key1 => value", "# key2 => value"] } + let(:rows) { ['# key1 => value', '# key2 => value'] } it { expect(Aruba.platform.simple_table(hash).to_s).to eq rows.join("\n") } end - context "when valid hash with unequal key lengths" do + context 'when valid hash with unequal key lengths' do let(:hash) do { - key1: "value", - long_key2: "value" + key1: 'value', + long_key2: 'value' } end - let(:rows) { ["# key1 => value", "# long_key2 => value"] } + let(:rows) { ['# key1 => value', '# long_key2 => value'] } it { expect(Aruba.platform.simple_table(hash).to_s).to eq rows.join("\n") } end - context "when empty hash" do + context 'when empty hash' do let(:hash) { {} } let(:rows) { [] } diff --git a/spec/aruba/platforms/unix_command_string_spec.rb b/spec/aruba/platforms/unix_command_string_spec.rb index ee5bdb177..e57e96ff9 100644 --- a/spec/aruba/platforms/unix_command_string_spec.rb +++ b/spec/aruba/platforms/unix_command_string_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::Platforms::UnixCommandString do let(:command_string) { described_class.new(base_command, *arguments) } let(:arguments) { [] } - describe "#to_a" do - context "with a command with a path" do - let(:base_command) { "/foo/bar" } + 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" } + 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"] } + 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 diff --git a/spec/aruba/platforms/unix_platform_spec.rb b/spec/aruba/platforms/unix_platform_spec.rb index 53e74c2df..42bfe9bd9 100644 --- a/spec/aruba/platforms/unix_platform_spec.rb +++ b/spec/aruba/platforms/unix_platform_spec.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/platforms/unix_platform" +require 'spec_helper' +require 'aruba/platforms/unix_platform' RSpec.describe Aruba::Platforms::UnixPlatform do - include_context "uses aruba API" + include_context 'uses aruba API' - describe ".match?" do - it "works even when ruby is launched with --disable-gems and --disable-rubyopt" do - aruba_lib = File.expand_path("../../../lib", __dir__) + describe '.match?' do + it 'works even when ruby is launched with --disable-gems and --disable-rubyopt' do + aruba_lib = File.expand_path('../../../lib', __dir__) run_command_and_stop( "ruby --disable-rubyopt --disable-gems -I#{aruba_lib}" \ " -e 'require \"aruba/platforms/unix_platform\";" \ diff --git a/spec/aruba/platforms/windows_command_string_spec.rb b/spec/aruba/platforms/windows_command_string_spec.rb index 582d6beea..d91ccce57 100644 --- a/spec/aruba/platforms/windows_command_string_spec.rb +++ b/spec/aruba/platforms/windows_command_string_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::Platforms::WindowsCommandString do let(:command_string) { described_class.new(base_command, *arguments) } let(:arguments) { [] } - describe "#to_a" do - context "with a command with a path" do - let(:base_command) { "C:\\Foo\\Bar" } + 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 [base_command] } end - context "with a command with a path containing spaces" do - let(:base_command) { "C:\\Foo Bar\\Baz" } + 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 [base_command] } end - context "with a command and arguments" do - let(:base_command) { "C:\\Foo\\Bar" } - let(:arguments) { ["-w", "baz quux"] } + context 'with a command and arguments' do + let(:base_command) { 'C:\\Foo\\Bar' } + let(:arguments) { ['-w', 'baz quux'] } it { expect(command_string.to_a) diff --git a/spec/aruba/platforms/windows_environment_variables_spec.rb b/spec/aruba/platforms/windows_environment_variables_spec.rb index 7baa2b3d8..38d60312b 100644 --- a/spec/aruba/platforms/windows_environment_variables_spec.rb +++ b/spec/aruba/platforms/windows_environment_variables_spec.rb @@ -1,200 +1,200 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/platforms/windows_environment_variables" +require 'spec_helper' +require 'aruba/platforms/windows_environment_variables' RSpec.describe Aruba::Platforms::WindowsEnvironmentVariables do subject(:environment) { described_class.new(old_environment) } - describe "#[]" do - context "when environment contains uppercase variable" do - let(:old_environment) { { "MY_VARIABLE" => "1" } } + describe '#[]' do + context 'when environment contains uppercase variable' do + let(:old_environment) { { 'MY_VARIABLE' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } it { expect(environment[variable]).to be_nil } end end - context "when environment contains lowercase variable" do - let(:old_environment) { { "my_variable" => "1" } } + context 'when environment contains lowercase variable' do + let(:old_environment) { { 'my_variable' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } it { expect(environment[variable]).to be_nil } end end - context "when environment contains mixed case variable" do - let(:old_environment) { { "MY_variable" => "1" } } + context 'when environment contains mixed case variable' do + let(:old_environment) { { 'MY_variable' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "1" } + it { expect(environment[variable]).to eq '1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } it { expect(environment[variable]).to be_nil } end end end - describe "#fetch" do - context "when environment contains uppercase variable" do - let(:old_environment) { { "MY_VARIABLE" => "1" } } + describe '#fetch' do + context 'when environment contains uppercase variable' do + let(:old_environment) { { 'MY_VARIABLE' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - context "and no default is given" do + context 'and no default is given' do it { expect { environment.fetch(variable) }.to raise_error KeyError } end - context "and default is given" do - let(:default_value) { "default_value" } + context 'and default is given' do + let(:default_value) { 'default_value' } it { expect(environment.fetch(variable, default_value)).to eq default_value } end end end - context "when environment contains lowercase variable" do - let(:old_environment) { { "my_variable" => "1" } } + context 'when environment contains lowercase variable' do + let(:old_environment) { { 'my_variable' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - context "and no default is given" do + context 'and no default is given' do it { expect { environment.fetch(variable) }.to raise_error KeyError } end - context "and default is given" do - let(:default_value) { "default_value" } + context 'and default is given' do + let(:default_value) { 'default_value' } it { expect(environment.fetch(variable, default_value)).to eq default_value } end end end - context "when environment contains mixed case variable" do - let(:old_environment) { { "MY_variable" => "1" } } + context 'when environment contains mixed case variable' do + let(:old_environment) { { 'MY_variable' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment.fetch(variable)).to eq "1" } + it { expect(environment.fetch(variable)).to eq '1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - context "and no default is given" do + context 'and no default is given' do it { expect { environment.fetch(variable) }.to raise_error KeyError } end - context "and default is given" do - let(:default_value) { "default_value" } + context 'and default is given' do + let(:default_value) { 'default_value' } it { expect(environment.fetch(variable, default_value)).to eq default_value } end @@ -202,291 +202,291 @@ end end - describe "#key?" do - context "when environment contains uppercase variable" do - let(:old_environment) { { "MY_VARIABLE" => "1" } } + describe '#key?' do + context 'when environment contains uppercase variable' do + let(:old_environment) { { 'MY_VARIABLE' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } it { expect(environment).to be_key variable } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } it { expect(environment).to be_key variable } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } it { expect(environment).to be_key variable } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } it { expect(environment).not_to be_key variable } end end - context "when environment contains lowercase variable" do - let(:old_environment) { { "my_variable" => "1" } } + context 'when environment contains lowercase variable' do + let(:old_environment) { { 'my_variable' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } it { expect(environment).to be_key variable } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } it { expect(environment).to be_key variable } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } it { expect(environment).to be_key variable } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } it { expect(environment).not_to be_key variable } end end - context "when environment contains mixed case variable" do - let(:old_environment) { { "MY_variable" => "1" } } + context 'when environment contains mixed case variable' do + let(:old_environment) { { 'MY_variable' => '1' } } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } it { expect(environment).to be_key variable } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } it { expect(environment).to be_key variable } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } it { expect(environment).to be_key variable } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } it { expect(environment).not_to be_key variable } end end end - describe "#append" do - let(:value) { "NEW_VALUE" } + describe '#append' do + let(:value) { 'NEW_VALUE' } - context "when environment contains uppercase variable" do - let(:old_environment) { { "MY_VARIABLE" => "1" } } + context 'when environment contains uppercase variable' do + let(:old_environment) { { 'MY_VARIABLE' => '1' } } before { environment.append(variable, value) } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - it { expect(environment[variable]).to eq "NEW_VALUE" } + it { expect(environment[variable]).to eq 'NEW_VALUE' } end end - context "when environment contains lowercase variable" do - let(:old_environment) { { "my_variable" => "1" } } + context 'when environment contains lowercase variable' do + let(:old_environment) { { 'my_variable' => '1' } } before { environment.append(variable, value) } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - it { expect(environment[variable]).to eq "NEW_VALUE" } + it { expect(environment[variable]).to eq 'NEW_VALUE' } end end - context "when environment contains mixed case variable" do - let(:old_environment) { { "MY_variable" => "1" } } + context 'when environment contains mixed case variable' do + let(:old_environment) { { 'MY_variable' => '1' } } before { environment.append(variable, value) } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "1NEW_VALUE" } + it { expect(environment[variable]).to eq '1NEW_VALUE' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - it { expect(environment[variable]).to eq "NEW_VALUE" } + it { expect(environment[variable]).to eq 'NEW_VALUE' } end end end - describe "#prepend" do - let(:value) { "NEW_VALUE" } + describe '#prepend' do + let(:value) { 'NEW_VALUE' } - context "when environment contains uppercase variable" do - let(:old_environment) { { "MY_VARIABLE" => "1" } } + context 'when environment contains uppercase variable' do + let(:old_environment) { { 'MY_VARIABLE' => '1' } } before { environment.prepend(variable, value) } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - it { expect(environment[variable]).to eq "NEW_VALUE" } + it { expect(environment[variable]).to eq 'NEW_VALUE' } end end - context "when environment contains lowercase variable" do - let(:old_environment) { { "my_variable" => "1" } } + context 'when environment contains lowercase variable' do + let(:old_environment) { { 'my_variable' => '1' } } before { environment.prepend(variable, value) } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - it { expect(environment[variable]).to eq "NEW_VALUE" } + it { expect(environment[variable]).to eq 'NEW_VALUE' } end end - context "when environment contains mixed case variable" do - let(:old_environment) { { "MY_variable" => "1" } } + context 'when environment contains mixed case variable' do + let(:old_environment) { { 'MY_variable' => '1' } } before { environment.prepend(variable, value) } - context "when uppercase key is given" do - let(:variable) { "MY_VARIABLE" } + context 'when uppercase key is given' do + let(:variable) { 'MY_VARIABLE' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when lowercase key is given" do - let(:variable) { "my_variable" } + context 'when lowercase key is given' do + let(:variable) { 'my_variable' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when mixed case key is given" do - let(:variable) { "MY_variable" } + context 'when mixed case key is given' do + let(:variable) { 'MY_variable' } - it { expect(environment[variable]).to eq "NEW_VALUE1" } + it { expect(environment[variable]).to eq 'NEW_VALUE1' } end - context "when unknown variable is given" do - let(:variable) { "unknown" } + context 'when unknown variable is given' do + let(:variable) { 'unknown' } - it { expect(environment[variable]).to eq "NEW_VALUE" } + it { expect(environment[variable]).to eq 'NEW_VALUE' } end end end - describe "#delete" do - let(:variable) { "my_variable" } - let(:old_environment) { { "MY_VARIABLE" => "1" } } + describe '#delete' do + let(:variable) { 'my_variable' } + let(:old_environment) { { 'MY_VARIABLE' => '1' } } - it "deletes a value from the environment" do + it 'deletes a value from the environment' do environment.delete(variable) expect(environment[variable]).to be_nil end - it "returns deleted value" do - expect(environment.delete(variable)).to eq("1") + it 'returns deleted value' do + expect(environment.delete(variable)).to eq('1') end end end diff --git a/spec/aruba/platforms/windows_platform_spec.rb b/spec/aruba/platforms/windows_platform_spec.rb index 699eac35b..d4a801ee4 100644 --- a/spec/aruba/platforms/windows_platform_spec.rb +++ b/spec/aruba/platforms/windows_platform_spec.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require "spec_helper" -require "aruba/platforms/windows_platform" +require 'spec_helper' +require 'aruba/platforms/windows_platform' RSpec.describe Aruba::Platforms::WindowsPlatform do - include_context "uses aruba API" + include_context 'uses aruba API' - describe ".match?" do - it "works even when ruby is launched with --disable-gems and --disable-rubyopt" do - aruba_lib = File.expand_path("../../../lib", __dir__) + describe '.match?' do + it 'works even when ruby is launched with --disable-gems and --disable-rubyopt' do + aruba_lib = File.expand_path('../../../lib', __dir__) run_command_and_stop( "ruby --disable-rubyopt --disable-gems -I#{aruba_lib}" \ " -e 'require \"aruba/platforms/windows_platform\";" \ diff --git a/spec/aruba/processes/basic_process_spec.rb b/spec/aruba/processes/basic_process_spec.rb index dcc6637b6..620409aba 100644 --- a/spec/aruba/processes/basic_process_spec.rb +++ b/spec/aruba/processes/basic_process_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::Processes::BasicProcess do let(:process) do @@ -21,42 +21,42 @@ def stderr(*_args) end.new(stdout, stderr, cmd, exit_timeout, io_wait_timeout, working_directory) end - let(:cmd) { "foobar" } + 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" } + let(:stdout) { 'foo output' } + let(:stderr) { 'foo error output' } - describe "#inspect" do - it "shows useful info" do + describe '#inspect' do + it 'shows useful info' do expected = /commandline="foobar": stdout="foo output" stderr="foo error output"/ expect(process.inspect).to match(expected) end - context "with no stdout" do + context 'with no stdout' do let(:stdout) { nil } - it "shows useful info" do + it 'shows useful info' do expected = /commandline="foobar": stdout=nil stderr="foo error output"/ expect(process.inspect).to match(expected) end end - context "with no stderr" do + context 'with no stderr' do let(:stderr) { nil } - it "shows useful info" do + it 'shows useful info' do expected = /commandline="foobar": stdout="foo output" stderr=nil/ expect(process.inspect).to match(expected) end end - context "with neither stderr nor stdout" do + context 'with neither stderr nor stdout' do let(:stderr) { nil } let(:stdout) { nil } - it "shows useful info" do + it 'shows useful info' do expected = /commandline="foobar": stdout=nil stderr=nil/ expect(process.inspect).to match(expected) end diff --git a/spec/aruba/processes/in_process_spec.rb b/spec/aruba/processes/in_process_spec.rb index dd87e9144..43dd83e97 100644 --- a/spec/aruba/processes/in_process_spec.rb +++ b/spec/aruba/processes/in_process_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::Processes::InProcess do let(:base_runner) do @@ -18,7 +18,7 @@ def execute!; end let(:stdout_runner) do Class.new(base_runner) do def execute! - @stdout.puts "yo" + @stdout.puts 'yo' end end end @@ -26,7 +26,7 @@ def execute! let(:stderr_runner) do Class.new(base_runner) do def execute! - @stderr.puts "yo" + @stderr.puts 'yo' end end end @@ -34,7 +34,7 @@ def execute! let(:failed_runner) do Class.new(base_runner) do def execute! - raise "Oops" + raise 'Oops' end end end @@ -44,14 +44,14 @@ def execute! environment, main_class) end - let(:command) { "foo" } + let(:command) { 'foo' } let(:exit_timeout) { 1 } let(:io_wait) { 1 } let(:working_directory) { Dir.getwd } let(:environment) { ENV.to_hash.dup } let(:main_class) { base_runner } - describe "#stdout" do + describe '#stdout' do let(:main_class) { stdout_runner } before do @@ -59,16 +59,16 @@ def execute! process.stop end - context "when invoked once" do + context 'when invoked once' do it { expect(process.stdout).to eq "yo\n" } end - context "when invoked twice" do + context 'when invoked twice' do it { 2.times { expect(process.stdout).to eq "yo\n" } } end end - describe "#stderr" do + describe '#stderr' do let(:main_class) { stderr_runner } before do @@ -76,46 +76,46 @@ def execute! process.stop end - context "when invoked once" do + context 'when invoked once' do it { expect(process.stderr).to eq "yo\n" } end - context "when invoked twice" do + context 'when invoked twice' do it { 2.times { expect(process.stderr).to eq "yo\n" } } end end - describe "#stop" do + describe '#stop' do before { process.start } - context "when stopped successfully" do + context 'when stopped successfully' do it { expect { process.stop }.not_to raise_error } - it "makes the process stopped" do + it 'makes the process stopped' do process.stop expect(process).to be_stopped end end end - describe "#start" do - context "when process run succeeds" do + describe '#start' do + context 'when process run succeeds' do it { expect { process.start }.not_to raise_error } - it "makes the process started" do + it 'makes the process started' do process.start expect(process).to be_started end end - context "when process run fails" do + context 'when process run fails' do let(:main_class) { failed_runner } - it { expect { process.start }.to raise_error RuntimeError, "Oops" } + it { expect { process.start }.to raise_error RuntimeError, 'Oops' } end end - describe "#exit_status" do + describe '#exit_status' do def run_process(&block) process = described_class.new( command, exit_timeout, io_wait, working_directory, @@ -126,21 +126,21 @@ def run_process(&block) process end - it "exits success" do + it 'exits success' do expect(run_process { nil }.exit_status).to eq 0 end - it "exits with given status" do + it 'exits with given status' do expect(run_process { @kernel.exit 12 }.exit_status).to eq 12 end - it "exits with boolean" do + it 'exits with boolean' do expect(run_process { @kernel.exit false }.exit_status).to eq 1 end - it "refuses to exit with anything else" do - expect { run_process { @kernel.exit "false" } } - .to raise_error(TypeError, "no implicit conversion of String into Integer") + it 'refuses to exit with anything else' do + expect { run_process { @kernel.exit 'false' } } + .to raise_error(TypeError, 'no implicit conversion of String into Integer') end end end diff --git a/spec/aruba/processes/spawn_process_spec.rb b/spec/aruba/processes/spawn_process_spec.rb index 1bcdcb978..376e18852 100644 --- a/spec/aruba/processes/spawn_process_spec.rb +++ b/spec/aruba/processes/spawn_process_spec.rb @@ -1,38 +1,38 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::Processes::SpawnProcess do subject(:process) do described_class.new(command_line, exit_timeout, io_wait, working_directory) end - include_context "uses aruba API" + include_context 'uses aruba API' let(:command_line) { 'echo "yo"' } let(:exit_timeout) { 30 } let(:io_wait) { 1 } - let(:working_directory) { @aruba.expand_path(".") } + let(:working_directory) { @aruba.expand_path('.') } - describe "#stdout" do - context "with a command that is stopped" do + describe '#stdout' do + context 'with a command that is stopped' do before do process.start process.stop end - context "when invoked once" do - it { expect(process.stdout.chomp).to eq "yo" } + context 'when invoked once' do + it { expect(process.stdout.chomp).to eq 'yo' } end - context "when invoked twice" do - it { 2.times { expect(process.stdout.chomp).to eq "yo" } } + context 'when invoked twice' do + it { 2.times { expect(process.stdout.chomp).to eq 'yo' } } end end - context "with a command that is still running" do - let(:cmd) { "bin/test-cli" } - let(:command_line) { "bash bin/test-cli" } + context 'with a command that is still running' do + let(:cmd) { 'bin/test-cli' } + let(:command_line) { 'bash bin/test-cli' } let(:exit_timeout) { 0.1 } before do @@ -45,16 +45,16 @@ BASH end - it "returns the output so far" do + it 'returns the output so far' do process.start - expect(process.stdout.chomp).to eq "yo" + expect(process.stdout.chomp).to eq 'yo' process.stop end end end - describe "#stderr" do - context "with a command that is stopped" do + describe '#stderr' do + context 'with a command that is stopped' do let(:command_line) { "sh -c \"echo 'yo' >&2\"" } before do @@ -62,19 +62,19 @@ process.stop end - it "returns the output of the process on stderr" do + it 'returns the output of the process on stderr' do expect(process).not_to be_timed_out - expect(process.stderr.chomp).to eq "yo" + expect(process.stderr.chomp).to eq 'yo' end - it "returns the same result when invoked a second time" do - 2.times { expect(process.stderr.chomp).to eq "yo" } + it 'returns the same result when invoked a second time' do + 2.times { expect(process.stderr.chomp).to eq 'yo' } end end - context "with a command that is still running" do - let(:cmd) { "bin/test-cli" } - let(:command_line) { "bash bin/test-cli" } + context 'with a command that is still running' do + let(:cmd) { 'bin/test-cli' } + let(:command_line) { 'bash bin/test-cli' } let(:exit_timeout) { 0.1 } before do @@ -87,31 +87,31 @@ BASH end - it "returns the error output so far" do + it 'returns the error output so far' do process.start - expect(process.stderr.chomp).to eq "yo" + expect(process.stderr.chomp).to eq 'yo' process.stop end end end - describe "#stop" do - context "when stopped successfully" do + describe '#stop' do + context 'when stopped successfully' do before do process.start end it { expect { process.stop }.not_to raise_error } - it "makes the process stopped" do + it 'makes the process stopped' do process.stop expect(process).to be_stopped end end - context "with a command that is taking a long time to run" do - let(:cmd) { "bin/test-cli" } - let(:command_line) { "bash bin/test-cli" } + context 'with a command that is taking a long time to run' do + let(:cmd) { 'bin/test-cli' } + let(:command_line) { 'bash bin/test-cli' } let(:exit_timeout) { 0.1 } before do @@ -124,31 +124,31 @@ BASH end - it "terminates the command" do + it 'terminates the command' do process.start process.stop - expect(process).not_to have_output "Success" + expect(process).not_to have_output 'Success' end - it "makes the command timed out" do + it 'makes the command timed out' do process.start process.stop expect(process).to be_timed_out end end - context "with an explicit termination signal specified" do - let(:cmd) { "bin/test-cli" } - let(:command_line) { "bash bin/test-cli" } + context 'with an explicit termination signal specified' do + let(:cmd) { 'bin/test-cli' } + let(:command_line) { 'bash bin/test-cli' } let(:exit_timeout) { 0.2 } let(:process) do described_class.new(command_line, exit_timeout, io_wait, working_directory, Aruba.platform.environment_variables.hash_from_env, - nil, "HUP") + nil, 'HUP') end before do - skip "Signals other than KILL are not supported on Windows" if Gem.win_platform? + skip 'Signals other than KILL are not supported on Windows' if Gem.win_platform? @aruba.write_file cmd, <<~BASH #!/usr/bin/env bash @@ -169,17 +169,17 @@ BASH end - it "terminates the command with the given signal" do + it 'terminates the command with the given signal' do process.start process.stop expect(process.exit_status).to eq 155 end end - context "with zero exit timeout" do + context 'with zero exit timeout' do let(:exit_timeout) { 0 } - it "does not make the command timed out if it already stopped" do + it 'does not make the command timed out if it already stopped' do process.start sleep 0.1 process.stop @@ -188,33 +188,33 @@ end end - describe "#start" do - context "when process run succeeds" do + describe '#start' do + context 'when process run succeeds' do it { expect { process.start }.not_to raise_error } - it "makes the process started" do + it 'makes the process started' do process.start expect(process).to be_started end - it "raises an error when attempting to start twice" do + it 'raises an error when attempting to start twice' do process.start expect { process.start }.to raise_error Aruba::CommandAlreadyStartedError end end - context "when process run fails" do - let(:command_line) { "does_not_exists" } + context 'when process run fails' do + let(:command_line) { 'does_not_exists' } it { expect { process.start }.to raise_error Aruba::LaunchError } end - context "when on unix" do + context 'when on unix' do let(:child) { instance_double(Aruba::Processes::ProcessRunner).as_null_object } - let(:command_line) { "foo" } - let(:command) { "foo" } - let(:command_path) { "/bar/foo" } + let(:command_line) { 'foo' } + let(:command) { 'foo' } + let(:command_path) { '/bar/foo' } before do allow(Aruba.platform).to receive(:command_string) @@ -226,8 +226,8 @@ allow(child).to receive(:environment).and_return({}) end - context "when spawning raises some SystemCallError" do - let(:error) { Errno::ENOENT.new "Foobar!" } + context 'when spawning raises some SystemCallError' do + let(:error) { Errno::ENOENT.new 'Foobar!' } before do allow(child).to receive(:start).and_raise error @@ -240,30 +240,30 @@ end end - context "with a command with a space in the path" do - let(:command_path) { "/path with space/foo" } + context 'with a command with a space in the path' do + let(:command_path) { '/path with space/foo' } - it "passes the command path as a single string to ProcessRunner.new" do + it 'passes the command path as a single string to ProcessRunner.new' do process.start expect(Aruba::Processes::ProcessRunner).to have_received(:new).with([command_path]) end end - context "with a command with arguments" do + context 'with a command with arguments' do let(:command_line) { 'foo -x "bar baz"' } - it "passes the command and arguments as separate items to ProcessRunner.new" do + it 'passes the command and arguments as separate items to ProcessRunner.new' do process.start expect(Aruba::Processes::ProcessRunner).to have_received(:new) - .with([command_path, "-x", "bar baz"]) + .with([command_path, '-x', 'bar baz']) end end end - context "when on windows" do + context 'when on windows' do let(:child) { instance_double(Aruba::Processes::ProcessRunner).as_null_object } - let(:command_line) { "foo" } - let(:command) { "foo" } + let(:command_line) { 'foo' } + let(:command) { 'foo' } let(:cmd_path) { 'C:\Bar\cmd.exe' } let(:command_path) { 'D:\Foo\foo' } @@ -277,8 +277,8 @@ allow(child).to receive(:environment).and_return({}) end - context "when spawning raises some SystemCallError" do - let(:error) { Errno::ENOENT.new "Foobar!" } + context 'when spawning raises some SystemCallError' do + let(:error) { Errno::ENOENT.new 'Foobar!' } before do allow(child).to receive(:start).and_raise error @@ -291,42 +291,42 @@ end end - context "with a command without a space in the path" do - it "passes the command as-is" do + context 'with a command without a space in the path' do + it 'passes the command as-is' do process.start expect(Aruba::Processes::ProcessRunner).to have_received(:new) .with([command_path]) end end - context "with a command with a space in the path" do + context 'with a command with a space in the path' do let(:command_path) { 'D:\Bar Baz\foo' } - it "passes the command as-is" do + it 'passes the command as-is' do process.start expect(Aruba::Processes::ProcessRunner).to have_received(:new) .with([command_path]) end end - context "with a command with arguments" do + context 'with a command with arguments' do let(:command_line) { "foo -x 'bar \"baz\"'" } - it "passes the command and arguments individually" do + it 'passes the command and arguments individually' do process.start expect(Aruba::Processes::ProcessRunner).to have_received(:new) - .with([command_path, "-x", "bar \"baz\""]) + .with([command_path, '-x', 'bar "baz"']) end end end end - describe "#send_signal" do - let(:signal) { Gem.win_platform? ? 9 : "KILL" } + describe '#send_signal' do + let(:signal) { Gem.win_platform? ? 9 : 'KILL' } - context "with a command that is running" do - let(:cmd) { "bin/test-cli" } - let(:command_line) { "bash bin/test-cli" } + context 'with a command that is running' do + let(:cmd) { 'bin/test-cli' } + let(:command_line) { 'bash bin/test-cli' } before do @aruba.write_file cmd, <<~BASH @@ -338,16 +338,16 @@ BASH end - it "sends the given signal to the command" do + it 'sends the given signal to the command' do process.start process.send_signal signal process.stop - expect(process).not_to have_output "Success" + expect(process).not_to have_output 'Success' end end - context "with a command that has stopped" do - it "raises an error" do + context 'with a command that has stopped' do + it 'raises an error' do process.start process.stop @@ -357,19 +357,19 @@ end end - describe "#command" do + describe '#command' do let(:command_line) { "ruby -e 'warn \"yo\"'" } - it "returns the first item of the command line" do - expect(process.command).to eq "ruby" + it 'returns the first item of the command line' do + expect(process.command).to eq 'ruby' end end - describe "#arguments" do + describe '#arguments' do let(:command_line) { "ruby -e 'warn \"yo\"'" } - it "handles arguments delimited with quotes" do - expect(process.arguments).to eq ["-e", 'warn "yo"'] + it 'handles arguments delimited with quotes' do + expect(process.arguments).to eq ['-e', 'warn "yo"'] end end end diff --git a/spec/aruba/rspec_spec.rb b/spec/aruba/rspec_spec.rb index 078a53335..e6eb4794d 100644 --- a/spec/aruba/rspec_spec.rb +++ b/spec/aruba/rspec_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' -RSpec.describe "RSpec Integration", type: :aruba do - describe "Configuration" do +RSpec.describe 'RSpec Integration', type: :aruba do + describe 'Configuration' do subject(:config) { aruba.config } - context "when io_wait_timeout is 0.5", io_wait_timeout: 0.5 do + context 'when io_wait_timeout is 0.5', io_wait_timeout: 0.5 do it { expect(config.io_wait_timeout).to eq 0.5 } end - context "when io_wait_timeout is 0.1" do + context 'when io_wait_timeout is 0.1' do it { expect(config.io_wait_timeout).to eq 0.1 } end end - describe "Setting up the environment" do - it "sets HOME to the configured value" do + describe 'Setting up the environment' do + it 'sets HOME to the configured value' do expect(Dir.home).to eq aruba.config.home_directory end - it "includes configured command search paths in PATH" do - expect(ENV["PATH"]) + it 'includes configured command search paths in PATH' do + expect(ENV['PATH']) .to include aruba.config.command_search_paths.join(File::PATH_SEPARATOR) end end diff --git a/spec/aruba/runtime_spec.rb b/spec/aruba/runtime_spec.rb index f3c46497c..1dd01dd72 100644 --- a/spec/aruba/runtime_spec.rb +++ b/spec/aruba/runtime_spec.rb @@ -1,33 +1,33 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Aruba::Runtime do - include_context "uses aruba API" + include_context 'uses aruba API' - describe "#fixtures_directory" do + describe '#fixtures_directory' do let(:runtime) do @aruba.aruba end - context "when no fixtures directories exist" do + context 'when no fixtures directories exist' do before do - runtime.config.fixtures_directories = ["not-there", "not/here", "does/not/exist"] + runtime.config.fixtures_directories = ['not-there', 'not/here', 'does/not/exist'] end - it "raises exception" do + it 'raises exception' do expect { runtime.fixtures_directory } .to raise_error RuntimeError, /No existing fixtures directory found/ end end - context "when one of the configures fixture directories exists" do + context 'when one of the configures fixture directories exists' do before do - runtime.config.fixtures_directories = ["not-there", "fixtures", "does/not/exist"] + runtime.config.fixtures_directories = ['not-there', 'fixtures', 'does/not/exist'] end - it "returns that directory" do - expect(runtime.fixtures_directory.to_s).to eq File.expand_path("fixtures", + it 'returns that directory' do + expect(runtime.fixtures_directory.to_s).to eq File.expand_path('fixtures', runtime.root_directory) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7156b79fe..c6afe69e3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -$LOAD_PATH << File.expand_path("../lib", __dir__) +$LOAD_PATH << File.expand_path('../lib', __dir__) -unless RUBY_PLATFORM.include?("java") - require "simplecov" - SimpleCov.command_name "RSpec" +unless RUBY_PLATFORM.include?('java') + require 'simplecov' + SimpleCov.command_name 'RSpec' # Run simplecov by default - SimpleCov.start unless ENV.key? "ARUBA_NO_COVERAGE" + SimpleCov.start unless ENV.key? 'ARUBA_NO_COVERAGE' end # Loading support files -Dir.glob(File.expand_path("support/*.rb", __dir__)).each { |f| require_relative f } -Dir.glob(File.expand_path("support/**/*.rb", __dir__)).each { |f| require_relative f } +Dir.glob(File.expand_path('support/*.rb', __dir__)).each { |f| require_relative f } +Dir.glob(File.expand_path('support/**/*.rb', __dir__)).each { |f| require_relative f } diff --git a/spec/support/configs/aruba.rb b/spec/support/configs/aruba.rb index b1c207f72..3ae9f6d92 100644 --- a/spec/support/configs/aruba.rb +++ b/spec/support/configs/aruba.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "aruba/rspec" -require "aruba/config/jruby" +require 'aruba/rspec' +require 'aruba/config/jruby' Aruba.configure do |config| config.activate_announcer_on_command_failure = [:stderr, :stdout, :command] diff --git a/spec/support/configs/pry.rb b/spec/support/configs/pry.rb index f460211a8..5db48e129 100644 --- a/spec/support/configs/pry.rb +++ b/spec/support/configs/pry.rb @@ -2,4 +2,4 @@ # Otherwise pry doesn't find it's RC file # if ENV['HOME'] is mocked -ENV["PRYRC"] = File.expand_path("~/.pryrc") +ENV['PRYRC'] = File.expand_path('~/.pryrc') diff --git a/spec/support/configs/rspec.rb b/spec/support/configs/rspec.rb index eb4188c66..241e2e519 100644 --- a/spec/support/configs/rspec.rb +++ b/spec/support/configs/rspec.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require "rspec/core" -require "aruba/api" +require 'rspec/core' +require 'aruba/api' RSpec.configure do |config| config.filter_run focus: true config.run_all_when_everything_filtered = true - config.example_status_persistence_file_path = "tmp/rspec-examples.txt" + config.example_status_persistence_file_path = 'tmp/rspec-examples.txt' config.profile_examples = 10 config.expect_with :rspec do |c| diff --git a/spec/support/shared_contexts/aruba.rb b/spec/support/shared_contexts/aruba.rb index b321c322f..649f059dd 100644 --- a/spec/support/shared_contexts/aruba.rb +++ b/spec/support/shared_contexts/aruba.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true -require "fileutils" -require "securerandom" +require 'fileutils' +require 'securerandom' -RSpec.shared_context "uses aruba API" do +RSpec.shared_context 'uses aruba API' do def random_string(options = {}) options[:prefix].to_s + SecureRandom.hex + options[:suffix].to_s end - def create_test_files(files, data = "a") + def create_test_files(files, data = 'a') Array(files).each do |s| - next if s.to_s[0] == "%" + next if s.to_s[0] == '%' local_path = @aruba.expand_path(s) FileUtils.mkdir_p File.dirname(local_path) - File.open(local_path, "w") { |f| f << data } + File.open(local_path, 'w') { |f| f << data } end end @@ -30,13 +30,13 @@ def set_tag(tag_name, value) @aruba = klass.new - @file_name = "test.txt" + @file_name = 'test.txt' @file_size = 256 @file_path = @aruba.expand_path(@file_name) @aruba.setup_aruba - if @aruba.aruba.current_directory[0] == "/" - raise "We must work with relative paths, everything else is dangerous" + if @aruba.aruba.current_directory[0] == '/' + raise 'We must work with relative paths, everything else is dangerous' end end end diff --git a/spec/support/shared_examples/configuration.rb b/spec/support/shared_examples/configuration.rb index dab801f50..52d923fb4 100644 --- a/spec/support/shared_examples/configuration.rb +++ b/spec/support/shared_examples/configuration.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.shared_examples "a basic configuration" do +RSpec.shared_examples 'a basic configuration' do subject(:config) do Class.new(described_class) do option_accessor :use_test, type: Contracts::Bool, @@ -10,7 +10,7 @@ it { expect(config).not_to be_nil } - describe ".option_reader" do + describe '.option_reader' do subject(:config) { config_klass.new } let(:config_klass) { Class.new(described_class) } @@ -20,15 +20,15 @@ default: 1 end - context "when value is read" do + context 'when value is read' do it { expect(config.new_opt).to eq 1 } end - context "when one tries to write a value" do + context 'when one tries to write a value' do it { expect { config.new_opt = 1 }.to raise_error NoMethodError } end - context "when block is defined" do + context 'when block is defined' do before do config_klass.option_reader( :new_opt2, @@ -36,23 +36,23 @@ ) { |c| c.new_opt.value + 1 } end - it "uses the block to set the value" do + it 'uses the block to set the value' do expect(config.new_opt2).to eq 2 end end - context "when block and default value is defined" do - it "complains that only one or the other can be specified" do + context 'when block and default value is defined' do + it 'complains that only one or the other can be specified' do expect do config_klass .option_accessor(:new_opt2, type: Contracts::Num, default: 2) { |c| c.new_opt.value + 1 } - end.to raise_error ArgumentError, "Either use block or default value" + end.to raise_error ArgumentError, 'Either use block or default value' end end end - describe ".option_accessor" do + describe '.option_accessor' do subject(:config) { config_klass.new } let(:config_klass) { Class.new(described_class) } @@ -62,17 +62,17 @@ default: 1 end - context "when default is used" do + context 'when default is used' do it { expect(config.new_opt).to eq 1 } end - context "when is modified" do + context 'when is modified' do before { config.new_opt = 2 } it { expect(config.new_opt).to eq 2 } end - context "when block is defined" do + context 'when block is defined' do before do config_klass.option_accessor( :new_opt2, type: Contracts::Num @@ -81,44 +81,44 @@ end end - it "uses the block to set the default value" do + it 'uses the block to set the default value' do expect(config.new_opt2).to eq 2 end end - context "when block and default value is defined" do - it "complains that only one or the other can be specified" do + context 'when block and default value is defined' do + it 'complains that only one or the other can be specified' do expect do config_klass.option_accessor(:new_opt2, type: Contracts::Num, default: 2) { |c| c.new_opt1 + 1 } - end.to raise_error ArgumentError, "Either use block or default value" + end.to raise_error ArgumentError, 'Either use block or default value' end end end - describe "option?" do + describe 'option?' do let(:name) { :use_test } - it "returns true when passed a valid option name" do + it 'returns true when passed a valid option name' do expect(config.option?(:use_test)).to be_truthy end - it "returns false when passed an invalid option name" do + it 'returns false when passed an invalid option name' do expect(config.option?(:blub)).to be_falsy end end - describe "set_if_option" do + describe 'set_if_option' do let(:name) { :use_test } let(:value) { true } - it "sets the option to the given value if a valid option name is passed" do + it 'sets the option to the given value if a valid option name is passed' do expect { config.set_if_option(:use_test, true) } .to change(config, :use_test).from(false).to(true) end - it "raises no error if an invalid option name is passed" do + it 'raises no error if an invalid option name is passed' do expect { config.set_if_option(:blub, true) }.not_to raise_error end end From 1c7d5f8499af039f226c9054e41bbeb56150ce6d Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sat, 31 Aug 2024 19:55:33 +0200 Subject: [PATCH 2/6] Switch to default RuboCop PercentLiteralDelimiters style This brings Aruba more in line with other Cucumber Ruby code. --- .rubocop.yml | 5 ----- Rakefile | 6 +++--- lib/aruba/cli.rb | 2 +- lib/aruba/configuration.rb | 2 +- lib/aruba/platforms/windows_platform.rb | 2 +- spec/aruba/api/core_spec.rb | 4 ++-- spec/aruba/api/filesystem_spec.rb | 16 ++++++++-------- spec/aruba/matchers/directory_spec.rb | 2 +- 8 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a4844c8d4..e66339c19 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -59,11 +59,6 @@ RSpec/PredicateMatcher: Style/FetchEnvVar: Enabled: false -# Use older RuboCop default -Style/PercentLiteralDelimiters: - PreferredDelimiters: - '%w': () - # SupportedStyles: percent, brackets Style/SymbolArray: EnforcedStyle: brackets diff --git a/Rakefile b/Rakefile index 70ca1c927..a5a79f76f 100644 --- a/Rakefile +++ b/Rakefile @@ -12,13 +12,13 @@ require 'rspec/core/rake_task' require 'rubocop/rake_task' Cucumber::Rake::Task.new do |t| - t.cucumber_opts = %w(--format progress) + t.cucumber_opts = %w[--format progress] end Cucumber::Rake::Task.new('cucumber:wip', 'Run Cucumber features' \ ' which are "WORK IN PROGRESS" and' \ ' are allowed to fail') do |t| - t.cucumber_opts = %w(--tags @wip:3 --wip) + t.cucumber_opts = %w[--tags @wip:3 --wip] end RSpec::Core::RakeTask.new @@ -41,6 +41,6 @@ end task build: 'manifest:check' desc 'Run checks' -task lint: %w(rubocop manifest:check) +task lint: %w[rubocop manifest:check] task default: :test diff --git a/lib/aruba/cli.rb b/lib/aruba/cli.rb index 0f381cf77..c7a4939d6 100644 --- a/lib/aruba/cli.rb +++ b/lib/aruba/cli.rb @@ -22,7 +22,7 @@ def console desc 'init', 'Initialize aruba' option :test_framework, default: 'cucumber', - enum: %w(cucumber rspec minitest), + enum: %w[cucumber rspec minitest], desc: 'Choose which test framework to use' def init Aruba::Initializer.new.call(options[:test_framework]) diff --git a/lib/aruba/configuration.rb b/lib/aruba/configuration.rb index 027d162e7..15ac774b2 100644 --- a/lib/aruba/configuration.rb +++ b/lib/aruba/configuration.rb @@ -33,7 +33,7 @@ class Configuration < BasicConfiguration option_accessor :startup_wait_time, type: Num, default: 0 option_accessor :fixtures_directories, type: ArrayOf[String], - default: %w(features/fixtures spec/fixtures test/fixtures fixtures) + default: %w[features/fixtures spec/fixtures test/fixtures fixtures] option_accessor :command_runtime_environment, type: Hash, default: {} option_accessor :command_search_paths, diff --git a/lib/aruba/platforms/windows_platform.rb b/lib/aruba/platforms/windows_platform.rb index c0483a9dd..8ec08df39 100644 --- a/lib/aruba/platforms/windows_platform.rb +++ b/lib/aruba/platforms/windows_platform.rb @@ -39,7 +39,7 @@ def which(program, path = ENV['PATH']) end def builtin_shell_commands - %w(cd dir echo exit set type) + %w[cd dir echo exit set type] end def term_signal_supported? diff --git a/spec/aruba/api/core_spec.rb b/spec/aruba/api/core_spec.rb index 89fb71fea..9a884b1f1 100644 --- a/spec/aruba/api/core_spec.rb +++ b/spec/aruba/api/core_spec.rb @@ -42,7 +42,7 @@ end it 'does not touch other environment variables in the passed block' do - keys = ENV.keys - %w(PWD OLDPWD) + keys = ENV.keys - %w[PWD OLDPWD] old_values = ENV.values_at(*keys) @aruba.create_directory @directory_name @aruba.cd @directory_name do @@ -159,7 +159,7 @@ end it 'does not touch other environment variables in the passed block' do - keys = ENV.keys - %w(PWD OLDPWD) + keys = ENV.keys - %w[PWD OLDPWD] old_values = ENV.values_at(*keys) @aruba.in_current_directory do expect(ENV.values_at(*keys)).to eq old_values diff --git a/spec/aruba/api/filesystem_spec.rb b/spec/aruba/api/filesystem_spec.rb index 0201f5fcf..22a115f87 100644 --- a/spec/aruba/api/filesystem_spec.rb +++ b/spec/aruba/api/filesystem_spec.rb @@ -157,7 +157,7 @@ end it 'creates multiple files when multiple names are given' do - names = %w(file1 file2 file3) + names = %w[file1 file2 file3] @aruba.touch(names) @@ -171,7 +171,7 @@ end context 'when touching an existing directory' do - let(:name) { %w(directory1) } + let(:name) { %w[directory1] } let(:path) { File.join(@aruba.aruba.current_directory, name) } before do @@ -334,7 +334,7 @@ end context 'when source is list of files' do - let(:source) { %w(file1.txt file2.txt file3.txt) } + let(:source) { %w[file1.txt file2.txt file3.txt] } let(:destination) { 'file.d' } let(:destination_files) { source.map { |s| File.join(destination, s) } } @@ -369,7 +369,7 @@ before { create_test_files(source) } context 'when destination is directory' do - let(:source) { %w(file1.txt file2.txt file3.txt) } + let(:source) { %w[file1.txt file2.txt file3.txt] } let(:destination) { 'file.d' } let(:destination_files) { source.map { |s| File.join(destination, s) } } @@ -382,7 +382,7 @@ end context 'when destination is not a directory' do - let(:source) { %w(file1.txt file2.txt file3.txt) } + let(:source) { %w[file1.txt file2.txt file3.txt] } let(:destination) { 'file.txt' } let(:error_message) { 'Multiples sources can only be copied to a directory' } @@ -608,7 +608,7 @@ def actual_permissions describe '#list' do let(:name) { 'test.d' } - let(:content) { %w(subdir.1.d subdir.2.d) } + let(:content) { %w[subdir.1.d subdir.2.d] } let(:path) { File.join(@aruba.aruba.current_directory, name) } before do @@ -682,7 +682,7 @@ def actual_permissions end it 'removes multiple files' do - names = %w(file1 file2 file3) + names = %w[file1 file2 file3] paths = names.map { |it| File.join(@aruba.aruba.current_directory, it) } paths.each { |it| File.write(File.expand_path(it), "foo #{it}") } @@ -718,7 +718,7 @@ def actual_permissions end it 'removes multiple directories' do - names = %w(directory1 directory2 directory3) + names = %w[directory1 directory2 directory3] paths = names.map { |it| File.join(@aruba.aruba.current_directory, it) } paths.each { |path| Aruba.platform.mkdir path } diff --git a/spec/aruba/matchers/directory_spec.rb b/spec/aruba/matchers/directory_spec.rb index a7d2e362a..0fadb8536 100644 --- a/spec/aruba/matchers/directory_spec.rb +++ b/spec/aruba/matchers/directory_spec.rb @@ -27,7 +27,7 @@ describe 'to_have_sub_directory' do let(:name) { 'test.d' } let(:path) { @aruba.expand_path(name) } - let(:content) { %w(subdir.1.d subdir.2.d) } + let(:content) { %w[subdir.1.d subdir.2.d] } context 'when directory exists' do before do From db96963738647abb67f87e71d4794d8bcc594073 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sat, 31 Aug 2024 20:10:33 +0200 Subject: [PATCH 3/6] Switch to default RuboCop SymbolArray style This brings Aruba more in line with other Cucumber Ruby code. --- .rubocop.yml | 4 ---- Rakefile | 2 +- features/support/aruba.rb | 2 +- lib/aruba/aruba_logger.rb | 2 +- lib/aruba/processes/in_process.rb | 2 +- lib/aruba/setup.rb | 6 +++--- spec/support/configs/aruba.rb | 2 +- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e66339c19..d937921ce 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -59,10 +59,6 @@ RSpec/PredicateMatcher: Style/FetchEnvVar: Enabled: false -# SupportedStyles: percent, brackets -Style/SymbolArray: - EnforcedStyle: brackets - # Be relatively lenient with line length Layout/LineLength: Max: 94 diff --git a/Rakefile b/Rakefile index a5a79f76f..52320ce3e 100644 --- a/Rakefile +++ b/Rakefile @@ -24,7 +24,7 @@ end RSpec::Core::RakeTask.new desc 'Run the whole test suite.' -task test: [:spec, :cucumber] +task test: %i[spec cucumber] RuboCop::RakeTask.new diff --git a/features/support/aruba.rb b/features/support/aruba.rb index 57c903533..9d4b5ccf5 100644 --- a/features/support/aruba.rb +++ b/features/support/aruba.rb @@ -5,5 +5,5 @@ Aruba.configure do |config| config.exit_timeout = 120 config.io_wait_timeout = 2 - config.activate_announcer_on_command_failure = [:stderr, :stdout, :command] + config.activate_announcer_on_command_failure = %i[stderr stdout command] end diff --git a/lib/aruba/aruba_logger.rb b/lib/aruba/aruba_logger.rb index 2c20ed4a0..62fd50064 100644 --- a/lib/aruba/aruba_logger.rb +++ b/lib/aruba/aruba_logger.rb @@ -38,7 +38,7 @@ def initialize(opts = {}) # @!method unknown(msg) # Log an unknown level log message - [:fatal, :warn, :debug, :info, :error, :unknown].each do |m| + %i[fatal warn debug info error unknown].each do |m| define_method m do |msg| logger.public_send m, msg end diff --git a/lib/aruba/processes/in_process.rb b/lib/aruba/processes/in_process.rb index e23894c0c..5ac2d6232 100644 --- a/lib/aruba/processes/in_process.rb +++ b/lib/aruba/processes/in_process.rb @@ -112,7 +112,7 @@ def write(input) # Close io def close_io(name) - unless [:stdin, :stdout, :stderr].include? name + unless %i[stdin stdout stderr].include? name raise ArgumentError, 'Only stdin stdout and stderr are allowed to close' end diff --git a/lib/aruba/setup.rb b/lib/aruba/setup.rb index a620305e9..9fe26af71 100644 --- a/lib/aruba/setup.rb +++ b/lib/aruba/setup.rb @@ -76,9 +76,9 @@ def events ) runtime.event_bus.register( - [:changed_environment_variable, - :added_environment_variable, - :deleted_environment_variable], + %i[changed_environment_variable + added_environment_variable + deleted_environment_variable], proc do |event| runtime.announcer.announce :changed_environment, event.entity[:changed][:name], diff --git a/spec/support/configs/aruba.rb b/spec/support/configs/aruba.rb index 3ae9f6d92..cf63c25ff 100644 --- a/spec/support/configs/aruba.rb +++ b/spec/support/configs/aruba.rb @@ -4,5 +4,5 @@ require 'aruba/config/jruby' Aruba.configure do |config| - config.activate_announcer_on_command_failure = [:stderr, :stdout, :command] + config.activate_announcer_on_command_failure = %i[stderr stdout command] end From 8e1715b5f17a1a91d5d93c5f3125c3d83111b3c9 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 1 Sep 2024 19:08:10 +0200 Subject: [PATCH 4/6] Switch to default RuboCop LineContinuationLeadingSpace style --- .rubocop.yml | 4 --- Rakefile | 6 ++-- lib/aruba/api/core.rb | 30 +++++++++---------- .../command/be_successfully_executed.rb | 4 +-- .../matchers/command/have_output_size.rb | 4 +-- lib/aruba/processes/debug_process.rb | 8 ++--- lib/aruba/processes/spawn_process.rb | 6 ++-- spec/aruba/matchers/file_spec.rb | 8 ++--- spec/aruba/platforms/unix_platform_spec.rb | 6 ++-- spec/aruba/platforms/windows_platform_spec.rb | 6 ++-- 10 files changed, 39 insertions(+), 43 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d937921ce..1b87e24a8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -32,10 +32,6 @@ Gemspec/DevelopmentDependencies: Gemspec/RequireMFA: Enabled: false -# Spaces in strings with line continuations go at the beginning of the line. -Layout/LineContinuationLeadingSpace: - EnforcedStyle: leading - # Assume the programmer knows how bracketed block syntax works Lint/AmbiguousBlockAssociation: Enabled: false diff --git a/Rakefile b/Rakefile index 52320ce3e..dd17b0f1c 100644 --- a/Rakefile +++ b/Rakefile @@ -15,9 +15,9 @@ Cucumber::Rake::Task.new do |t| t.cucumber_opts = %w[--format progress] end -Cucumber::Rake::Task.new('cucumber:wip', 'Run Cucumber features' \ - ' which are "WORK IN PROGRESS" and' \ - ' are allowed to fail') do |t| +Cucumber::Rake::Task.new('cucumber:wip', 'Run Cucumber features ' \ + 'which are "WORK IN PROGRESS" and ' \ + 'are allowed to fail') do |t| t.cucumber_opts = %w[--tags @wip:3 --wip] end diff --git a/lib/aruba/api/core.rb b/lib/aruba/api/core.rb index 06e785cb3..0f1489941 100644 --- a/lib/aruba/api/core.rb +++ b/lib/aruba/api/core.rb @@ -145,18 +145,18 @@ def cd(dir, &block) # def expand_path(file_name, dir_string = nil) unless file_name.is_a?(String) && !file_name.empty? - message = "Filename #{file_name} needs to be a string." \ - ' It cannot be nil or empty either.' \ - " Please use `expand_path('.')` if you want" \ - ' the current directory to be expanded.' + message = "Filename #{file_name} needs to be a string. " \ + 'It cannot be nil or empty either. ' \ + "Please use `expand_path('.')` if you want " \ + 'the current directory to be expanded.' raise ArgumentError, message end unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory) - raise "Aruba's working directory does not exist." \ - ' Maybe you forgot to run `setup_aruba` before using its API.' + raise "Aruba's working directory does not exist. " \ + 'Maybe you forgot to run `setup_aruba` before using its API.' end prefix = file_name[0] @@ -169,10 +169,10 @@ def expand_path(file_name, dir_string = nil) .map { |p| format('"%s"', p) }.join(', ') raise ArgumentError, - "Fixture \"#{rest}\" does not exist" \ - " in fixtures directory \"#{aruba.fixtures_directory}\"." \ - ' This was the one we found first on your system from all possible' \ - " candidates: #{aruba_fixture_candidates}." + "Fixture \"#{rest}\" does not exist " \ + "in fixtures directory \"#{aruba.fixtures_directory}\". " \ + 'This was the one we found first on your system from all possible ' \ + "candidates: #{aruba_fixture_candidates}." end path @@ -194,11 +194,11 @@ def expand_path(file_name, dir_string = nil) caller_location = caller_locations(1, 1).first caller_file_line = "#{caller_location.path}:#{caller_location.lineno}" message = - "Aruba's `expand_path` method was called with an absolute path" \ - " at #{caller_file_line}, which is not recommended." \ - " The path passed was '#{file_name}'." \ - ' Change the call to pass a relative path or set' \ - ' `config.allow_absolute_paths = true` to silence this warning' + "Aruba's `expand_path` method was called with an absolute path " \ + "at #{caller_file_line}, which is not recommended. " \ + "The path passed was '#{file_name}'. " \ + 'Change the call to pass a relative path or set ' \ + '`config.allow_absolute_paths = true` to silence this warning' raise UserError, message end file_name diff --git a/lib/aruba/matchers/command/be_successfully_executed.rb b/lib/aruba/matchers/command/be_successfully_executed.rb index d794ce228..7f2d272e6 100644 --- a/lib/aruba/matchers/command/be_successfully_executed.rb +++ b/lib/aruba/matchers/command/be_successfully_executed.rb @@ -29,8 +29,8 @@ end failure_message do |_actual| - "Expected `#{@actual}` to succeed" \ - ' but got non-zero exit status and the following output:' \ + "Expected `#{@actual}` to succeed " \ + 'but got non-zero exit status and the following output:' \ "\n\n#{@old_actual.output}\n" end end diff --git a/lib/aruba/matchers/command/have_output_size.rb b/lib/aruba/matchers/command/have_output_size.rb index e2b6ca037..2138e952f 100644 --- a/lib/aruba/matchers/command/have_output_size.rb +++ b/lib/aruba/matchers/command/have_output_size.rb @@ -28,8 +28,8 @@ match do |actual| if actual.respond_to? :size Aruba.platform.deprecated \ - 'Application of the have_output_size matcher to a string is deprecated.' \ - ' Apply the matcher directly to the process object instead' + 'Application of the have_output_size matcher to a string is deprecated. ' \ + 'Apply the matcher directly to the process object instead' actual_size = actual.size elsif actual.respond_to? :output actual_size = actual.output.size diff --git a/lib/aruba/processes/debug_process.rb b/lib/aruba/processes/debug_process.rb index 18115759e..4efa6a39b 100644 --- a/lib/aruba/processes/debug_process.rb +++ b/lib/aruba/processes/debug_process.rb @@ -43,8 +43,8 @@ def stdin(*); end # @return [String] # A predefined string to make users aware they are using the DebugProcess def stdout(*) - 'This is the debug launcher on STDOUT.' \ - ' If this output is unexpected, please check your setup.' + 'This is the debug launcher on STDOUT. ' \ + 'If this output is unexpected, please check your setup.' end # Return stderr @@ -52,8 +52,8 @@ def stdout(*) # @return [String] # A predefined string to make users aware they are using the DebugProcess def stderr(*) - 'This is the debug launcher on STDERR.' \ - ' If this output is unexpected, please check your setup.' + 'This is the debug launcher on STDERR. ' \ + 'If this output is unexpected, please check your setup.' end # Write to nothing diff --git a/lib/aruba/processes/spawn_process.rb b/lib/aruba/processes/spawn_process.rb index 0bdc73a64..012401660 100644 --- a/lib/aruba/processes/spawn_process.rb +++ b/lib/aruba/processes/spawn_process.rb @@ -146,9 +146,9 @@ def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop: def start if started? error_message = - "Command \"#{commandline}\" has already been started." \ - ' Please `#stop` the command first and `#start` it again.' \ - ' Alternatively use `#restart`.' + "Command \"#{commandline}\" has already been started. " \ + 'Please `#stop` the command first and `#start` it again. ' \ + 'Alternatively use `#restart`.' raise CommandAlreadyStartedError, error_message end diff --git a/spec/aruba/matchers/file_spec.rb b/spec/aruba/matchers/file_spec.rb index 154a15ed8..b35a454b8 100644 --- a/spec/aruba/matchers/file_spec.rb +++ b/spec/aruba/matchers/file_spec.rb @@ -315,8 +315,8 @@ def fail_with(message) it 'provides the correct path value in the message' do expect { expect(file).to be_a_command_found_in_path } .to raise_error RSpec::Expectations::ExpectationNotMetError, - "expected that command \"#{file}\" can be found" \ - " in PATH \"#{expand_path('.')}\"." + "expected that command \"#{file}\" can be found " \ + "in PATH \"#{expand_path('.')}\"." end end @@ -332,8 +332,8 @@ def fail_with(message) it 'provides the correct path value in the message' do expect { expect(file).not_to be_a_command_found_in_path } .to raise_error RSpec::Expectations::ExpectationNotMetError, - "expected that command \"#{file}\" cannot be found" \ - " in PATH \"#{expand_path('.')}\"." + "expected that command \"#{file}\" cannot be found " \ + "in PATH \"#{expand_path('.')}\"." end end end diff --git a/spec/aruba/platforms/unix_platform_spec.rb b/spec/aruba/platforms/unix_platform_spec.rb index 42bfe9bd9..4dc7058ea 100644 --- a/spec/aruba/platforms/unix_platform_spec.rb +++ b/spec/aruba/platforms/unix_platform_spec.rb @@ -10,9 +10,9 @@ it 'works even when ruby is launched with --disable-gems and --disable-rubyopt' do aruba_lib = File.expand_path('../../../lib', __dir__) run_command_and_stop( - "ruby --disable-rubyopt --disable-gems -I#{aruba_lib}" \ - " -e 'require \"aruba/platforms/unix_platform\";" \ - " Aruba::Platforms::UnixPlatform.match?;'" + "ruby --disable-rubyopt --disable-gems -I#{aruba_lib} " \ + "-e 'require \"aruba/platforms/unix_platform\"; " \ + "Aruba::Platforms::UnixPlatform.match?;'" ) expect(last_command_started).to be_successfully_executed end diff --git a/spec/aruba/platforms/windows_platform_spec.rb b/spec/aruba/platforms/windows_platform_spec.rb index d4a801ee4..c3a6d1134 100644 --- a/spec/aruba/platforms/windows_platform_spec.rb +++ b/spec/aruba/platforms/windows_platform_spec.rb @@ -10,9 +10,9 @@ it 'works even when ruby is launched with --disable-gems and --disable-rubyopt' do aruba_lib = File.expand_path('../../../lib', __dir__) run_command_and_stop( - "ruby --disable-rubyopt --disable-gems -I#{aruba_lib}" \ - " -e 'require \"aruba/platforms/windows_platform\";" \ - " Aruba::Platforms::WindowsPlatform.match?;'" + "ruby --disable-rubyopt --disable-gems -I#{aruba_lib} " \ + "-e 'require \"aruba/platforms/windows_platform\"; " \ + "Aruba::Platforms::WindowsPlatform.match?;'" ) expect(last_command_started).to be_successfully_executed end From 3fe7c6e7ca4f288a88a7d9255bc848610a457f56 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 1 Sep 2024 19:33:06 +0200 Subject: [PATCH 5/6] Re-order RuboCop configuration file --- .rubocop.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1b87e24a8..a258664a0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +inherit_from: .rubocop_todo.yml + inherit_mode: merge: - Exclude @@ -32,6 +34,10 @@ Gemspec/DevelopmentDependencies: Gemspec/RequireMFA: Enabled: false +# Be relatively lenient with line length +Layout/LineLength: + Max: 94 + # Assume the programmer knows how bracketed block syntax works Lint/AmbiguousBlockAssociation: Enabled: false @@ -54,9 +60,3 @@ RSpec/PredicateMatcher: # This cop doesn't seem to add much for us. Style/FetchEnvVar: Enabled: false - -# Be relatively lenient with line length -Layout/LineLength: - Max: 94 - -inherit_from: .rubocop_todo.yml From b1a4d2748d07835e84057ce3b535e65924baaf76 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 20 Oct 2024 08:24:53 +0200 Subject: [PATCH 6/6] Switch to Cucumber standard MessageSpies cop configuration This replace #have_received style mocking with #received style, which is the style used in other Ruby code in the Cucumber project --- .rubocop.yml | 4 ++ spec/aruba/api_spec.rb | 6 +-- spec/aruba/command_spec.rb | 51 ++++++++----------- .../matchers/command/have_output_size_spec.rb | 2 +- spec/aruba/processes/spawn_process_spec.rb | 16 +++--- 5 files changed, 34 insertions(+), 45 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a258664a0..ecc9eb709 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -52,6 +52,10 @@ Metrics/BlockLength: - '**/*.gemspec' - 'spec/**/*' +# Stylistic preference for cucumber +RSpec/MessageSpies: + EnforcedStyle: receive + # This cop does not work properly with predicates that take arguments. # TODO: Re-enable once https://github.com/rubocop/rubocop-rspec/issues/466 is resolved. RSpec/PredicateMatcher: diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index e9018b76b..0df3380ce 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -19,12 +19,10 @@ end it 'announces to stdout exactly once' do + expect(@aruba.aruba.announcer).to receive(:announce).with(:stdout).once @aruba.run_command_and_stop('echo "hello world"', fail_on_error: false) - 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 + expect(@aruba.last_command_started.output).to include('hello world') end end diff --git a/spec/aruba/command_spec.rb b/spec/aruba/command_spec.rb index b2fc5c91f..86bff677e 100644 --- a/spec/aruba/command_spec.rb +++ b/spec/aruba/command_spec.rb @@ -3,97 +3,86 @@ require 'spec_helper' RSpec.describe Aruba::Command do + let(:event_bus) { instance_double(Aruba::EventBus) } let(:command) do - described_class.new( - 'true', - event_bus: event_bus, - exit_timeout: exit_timeout, - io_wait_timeout: io_wait_timeout, - working_directory: working_directory, - environment: environment, - main_class: main_class, - stop_signal: stop_signal, - startup_wait_time: startup_wait_time - ) + described_class.new('true', + event_bus: event_bus, + startup_wait_time: 0.01, io_wait_timeout: 0.01, exit_timeout: 0.01, + working_directory: File.expand_path('.'), + environment: ENV.to_hash, + main_class: nil, stop_signal: nil) end - let(:event_bus) { instance_double(Aruba::EventBus) } - let(:exit_timeout) { 0.01 } - let(:io_wait_timeout) { 0.01 } - let(:working_directory) { File.expand_path('.') } - let(:environment) { ENV.to_hash } - let(:main_class) { nil } - let(:stop_signal) { nil } - let(:startup_wait_time) { 0.01 } - describe '#start' do - before do + it 'leaves the command in the started state' do allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStarted) command.start + expect(command).to be_started end - it 'leaves the command in the started state' do - expect(command).to be_started + it 'notifies the event bus' do + expect(event_bus).to receive(:notify).with(Aruba::Events::CommandStarted) + command.start end end describe '#stop' do before do allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStarted) - allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped) command.start end it 'stops the command' do + allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped) command.stop expect(command).to be_stopped end it 'notifies the event bus' do + expect(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped).once command.stop - expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end it 'notifies the event bus only once per run' do + expect(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped).once command.stop command.stop - expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end it 'prevents #terminate from notifying the event bus' do + expect(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped).once command.stop command.terminate - expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end end describe '#terminate' do before do allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStarted) - allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped) command.start end it 'stops the command' do + allow(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped) command.terminate expect(command).to be_stopped end it 'notifies the event bus' do + expect(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped).once command.terminate - expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end it 'notifies the event bus only once per run' do + expect(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped).once command.terminate command.terminate - expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end it 'prevents #stop from notifying the event bus' do + expect(event_bus).to receive(:notify).with(Aruba::Events::CommandStopped).once command.terminate command.stop - expect(event_bus).to have_received(:notify).with(Aruba::Events::CommandStopped).once end end end diff --git a/spec/aruba/matchers/command/have_output_size_spec.rb b/spec/aruba/matchers/command/have_output_size_spec.rb index 4a48ef385..9ee78abbd 100644 --- a/spec/aruba/matchers/command/have_output_size_spec.rb +++ b/spec/aruba/matchers/command/have_output_size_spec.rb @@ -21,8 +21,8 @@ it 'emits a deprecation warning' do aggregate_failures do + expect(Aruba.platform).to receive(:deprecated) expect(obj).to have_output_size 6 - expect(Aruba.platform).to have_received(:deprecated) end end end diff --git a/spec/aruba/processes/spawn_process_spec.rb b/spec/aruba/processes/spawn_process_spec.rb index 376e18852..7ac0de81a 100644 --- a/spec/aruba/processes/spawn_process_spec.rb +++ b/spec/aruba/processes/spawn_process_spec.rb @@ -244,8 +244,8 @@ let(:command_path) { '/path with space/foo' } it 'passes the command path as a single string to ProcessRunner.new' do + expect(Aruba::Processes::ProcessRunner).to receive(:new).with([command_path]) process.start - expect(Aruba::Processes::ProcessRunner).to have_received(:new).with([command_path]) end end @@ -253,9 +253,9 @@ let(:command_line) { 'foo -x "bar baz"' } it 'passes the command and arguments as separate items to ProcessRunner.new' do - process.start - expect(Aruba::Processes::ProcessRunner).to have_received(:new) + expect(Aruba::Processes::ProcessRunner).to receive(:new) .with([command_path, '-x', 'bar baz']) + process.start end end end @@ -293,9 +293,8 @@ context 'with a command without a space in the path' do it 'passes the command as-is' do + expect(Aruba::Processes::ProcessRunner).to receive(:new).with([command_path]) process.start - expect(Aruba::Processes::ProcessRunner).to have_received(:new) - .with([command_path]) end end @@ -303,9 +302,8 @@ let(:command_path) { 'D:\Bar Baz\foo' } it 'passes the command as-is' do + expect(Aruba::Processes::ProcessRunner).to receive(:new).with([command_path]) process.start - expect(Aruba::Processes::ProcessRunner).to have_received(:new) - .with([command_path]) end end @@ -313,9 +311,9 @@ let(:command_line) { "foo -x 'bar \"baz\"'" } it 'passes the command and arguments individually' do - process.start - expect(Aruba::Processes::ProcessRunner).to have_received(:new) + expect(Aruba::Processes::ProcessRunner).to receive(:new) .with([command_path, '-x', 'bar "baz"']) + process.start end end end