diff --git a/.rubocop.yml b/.rubocop.yml index 4e59ead68..da4c54175 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,7 @@ inherit_from: AllCops: TargetRubyVersion: 2.2 Exclude: + - vendor/**/* - db/schema.rb - tmp/aruba/Guardfile - tmp/aruba/Gemfile diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0c086dada..a76553580 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -59,7 +59,7 @@ Style/NumericPredicate: # Offense count: 1 # Cop supports --auto-correct. -Style/SpaceInsideArrayPercentLiteral: +Layout/SpaceInsideArrayPercentLiteral: Exclude: - 'guard.gemspec' @@ -67,7 +67,7 @@ Style/SpaceInsideArrayPercentLiteral: # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: space, no_space -Style/SpaceInsideStringInterpolation: +Layout/SpaceInsideStringInterpolation: Exclude: - 'lib/guard.rb' - 'lib/guard/cli.rb' diff --git a/Gemfile b/Gemfile index a7d9d35de..6fccff982 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" gemspec unless ENV["USE_INSTALLED_GUARD"] == "1" @@ -15,13 +17,13 @@ group :development do # on HoundCI's side. # # See https://github.com/houndci/hound/issues/1250 - gem "rubocop", "0.51.0", require: false + gem "rubocop", "0.54.0", require: false gem "guard-rubocop", require: false - gem "yard", require: false, platform: :mri - gem "redcarpet", require: false, platform: :mri gem "guard-ronn", require: false, platform: :mri + gem "redcarpet", require: false, platform: :mri + gem "yard", require: false, platform: :mri # Used for release gem "gems", require: false, platform: :mri @@ -37,19 +39,19 @@ group :test do gem "guard-cucumber", "~> 2.1", require: false gem "guard-rspec", require: false - gem "codeclimate-test-reporter", require: nil - gem "rspec", ">= 3.0.0", require: false gem "aruba", "~> 0.9", require: false + gem "codeclimate-test-reporter", require: nil gem "notiffany", ">= 0.0.6", require: false + gem "rspec", ">= 3.0.0", require: false end # Needed for Travis # See http://docs.travis-ci.com/user/languages/ruby/#Rubinius # platforms :rbx do - gem "racc" - gem "rubysl", "~> 2.0" - gem "psych" gem "json" + gem "psych" + gem "racc" gem "rubinius-coverage" + gem "rubysl", "~> 2.0" end diff --git a/config/Guardfile b/config/Guardfile index bac3a7027..814c3cc20 100644 --- a/config/Guardfile +++ b/config/Guardfile @@ -26,7 +26,7 @@ group :specs, halt_on_fail: true do # watch(%r{^lib/guard/(guard|plugin).rb$}) { "spec/guard/plugin" } end - guard :rubocop, all_on_start: false, cli: "--rails" do + guard :rubocop, all_on_start: false, cli: "--rails -c .rubocop.yml" do watch(%r{.+\.rb$}) { |m| m[0] } watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } end diff --git a/features/support/env.rb b/features/support/env.rb index b5a8ae9f8..c64fa0b89 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -33,5 +33,5 @@ set_environment_variable "HOME", home FileUtils.mkdir(home) - @aruba_timeout_seconds = Cucumber::JRUBY ? 35 : 15 + @aruba_timeout_seconds = Cucumber::JRUBY ? 45 : 15 end diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index 6a3b71662..bb4b9bd1e 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -1,4 +1,6 @@ -path = File.expand_path("../../../../bin/guard", __FILE__) +# frozen_string_literal: true + +path = File.expand_path("../../../bin/guard", __dir__) load path RSpec.describe GuardReloader do @@ -11,13 +13,13 @@ before do allow(described_class::Config).to receive(:new).and_return(config) - allow(config).to receive(:current_bundler_gemfile). - and_return(bundle_gemfile_env) + allow(config).to receive(:current_bundler_gemfile) + .and_return(bundle_gemfile_env) allow(config).to receive(:using_bundler?).and_return(bundle_gemfile_env) allow(config).to receive(:guard_core_path).and_return(guard_core_path) - allow(config).to receive(:program_arguments).and_return(%w(foo bar baz)) + allow(config).to receive(:program_arguments).and_return(%w[foo bar baz]) allow(config).to receive(:using_rubygems?).and_return(rubygems_deps_env) allow(config).to receive(:program_path).and_return(program_path) end @@ -54,8 +56,8 @@ context "when the relative Gemfile exists" do before do - allow(config).to receive(:exist?). - with(Pathname("/my/project/Gemfile")).and_return(true) + allow(config).to receive(:exist?) + .with(Pathname("/my/project/Gemfile")).and_return(true) allow(config).to receive(:setup_bundler) allow(config).to receive(:setup_bundler_env) @@ -67,19 +69,19 @@ end it "sets the Gemfile" do - expect(config).to receive(:setup_bundler_env). - with("/my/project/Gemfile") + expect(config).to receive(:setup_bundler_env) + .with("/my/project/Gemfile") subject.setup end end context "when the relative Gemfile does not exist" do before do - allow(config).to receive(:exist?). - with(Pathname("/my/project/Gemfile")).and_return(false) + allow(config).to receive(:exist?) + .with(Pathname("/my/project/Gemfile")).and_return(false) - allow(config).to receive(:exist?).with(Pathname("Gemfile")). - and_return(false) + allow(config).to receive(:exist?).with(Pathname("Gemfile")) + .and_return(false) end it "does not setup bundler" do @@ -110,8 +112,8 @@ context "when Gemfile exists" do before do - allow(config).to receive(:exist?).with(Pathname("Gemfile")). - and_return(true) + allow(config).to receive(:exist?).with(Pathname("Gemfile")) + .and_return(true) end it "shows a warning" do @@ -122,8 +124,8 @@ context "when no Gemfile exists" do before do - allow(config).to receive(:exist?).with(Pathname("Gemfile")). - and_return(false) + allow(config).to receive(:exist?).with(Pathname("Gemfile")) + .and_return(false) end it "shows no warning" do diff --git a/spec/lib/guard/cli/environments/bundler_spec.rb b/spec/lib/guard/cli/environments/bundler_spec.rb index 1151ca0c5..6a0a41572 100644 --- a/spec/lib/guard/cli/environments/bundler_spec.rb +++ b/spec/lib/guard/cli/environments/bundler_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/cli/environments/bundler" # TODO: instead of shared examples, use have_received if possible @@ -22,8 +24,8 @@ allow(ENV).to receive(:[]).with("BUNDLE_GEMFILE").and_return(gemfile) allow(ENV).to receive(:[]).with("RUBYGEMS_GEMDEPS").and_return(gemdeps) - allow(File).to receive(:exist?).with("Gemfile"). - and_return(gemfile_present) + allow(File).to receive(:exist?).with("Gemfile") + .and_return(gemfile_present) subject.verify end diff --git a/spec/lib/guard/cli/environments/evaluate_only_spec.rb b/spec/lib/guard/cli/environments/evaluate_only_spec.rb index 6b16b82aa..88aab0ec6 100644 --- a/spec/lib/guard/cli/environments/evaluate_only_spec.rb +++ b/spec/lib/guard/cli/environments/evaluate_only_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/cli/environments/evaluate_only" RSpec.describe Guard::Cli::Environments::EvaluateOnly do @@ -35,11 +37,11 @@ it "passes options to evaluator" do evaluator_options = double("evaluator_options") - allow(session).to receive(:evaluator_options). - and_return(evaluator_options) + allow(session).to receive(:evaluator_options) + .and_return(evaluator_options) - expect(Guard::Guardfile::Evaluator).to receive(:new). - with(evaluator_options).and_return(evaluator) + expect(Guard::Guardfile::Evaluator).to receive(:new) + .with(evaluator_options).and_return(evaluator) subject.evaluate end @@ -52,8 +54,8 @@ ].each do |error_class| context "when a #{error_class} error occurs" do before do - allow(Guard).to receive(:init). - and_raise(error_class, "#{error_class} error!") + allow(Guard).to receive(:init) + .and_raise(error_class, "#{error_class} error!") end it "aborts" do diff --git a/spec/lib/guard/cli/environments/valid_spec.rb b/spec/lib/guard/cli/environments/valid_spec.rb index 4846ca8c5..9b65aebd5 100644 --- a/spec/lib/guard/cli/environments/valid_spec.rb +++ b/spec/lib/guard/cli/environments/valid_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/cli/environments/valid" require "guard/cli/environments/bundler" @@ -14,8 +16,8 @@ let(:bundler) { instance_double("Guard::Cli::Environments::Bundler") } before do - allow(Guard::Cli::Environments::Bundler).to receive(:new). - and_return(bundler) + allow(Guard::Cli::Environments::Bundler).to receive(:new) + .and_return(bundler) allow(bundler).to receive(:verify) end @@ -24,8 +26,8 @@ before do allow(bundler).to receive(:verify) - allow(options).to receive(:[]).with(:no_bundler_warning). - and_return(false) + allow(options).to receive(:[]).with(:no_bundler_warning) + .and_return(false) end it "starts guard" do @@ -52,8 +54,8 @@ ].each do |error_class| context "when a #{error_class} error occurs" do before do - allow(Guard).to receive(:start). - and_raise(error_class, "#{error_class} error!") + allow(Guard).to receive(:start) + .and_raise(error_class, "#{error_class} error!") end it "aborts" do @@ -150,8 +152,8 @@ end it "Only creates the Guardfile without initializing any Guard template" do - allow(evaluator).to receive(:evaluate). - and_raise(Guard::Guardfile::Evaluator::NoGuardfileError) + allow(evaluator).to receive(:evaluate) + .and_raise(Guard::Guardfile::Evaluator::NoGuardfileError) allow(File).to receive(:exist?).with("Gemfile").and_return(false) expect(generator).to receive(:create_guardfile) @@ -178,12 +180,12 @@ end it "creates a Guardfile" do - expect(evaluator).to receive(:evaluate). - and_raise(Guard::Guardfile::Evaluator::NoGuardfileError).once + expect(evaluator).to receive(:evaluate) + .and_raise(Guard::Guardfile::Evaluator::NoGuardfileError).once expect(evaluator).to receive(:evaluate) - expect(Guard::Guardfile::Generator).to receive(:new). - and_return(generator) + expect(Guard::Guardfile::Generator).to receive(:new) + .and_return(generator) expect(generator).to receive(:create_guardfile) subject.initialize_guardfile @@ -203,30 +205,30 @@ expect(generator).to receive(:initialize_template).with("rspec") expect(generator).to receive(:initialize_template).with("pow") - subject.initialize_guardfile(%w(rspec pow)) + subject.initialize_guardfile(%w[rspec pow]) end context "when passed a guard name" do context "when the Guardfile is empty" do before do - allow(evaluator).to receive(:evaluate). - and_raise Guard::Guardfile::Evaluator::NoPluginsError + allow(evaluator).to receive(:evaluate) + .and_raise Guard::Guardfile::Evaluator::NoPluginsError allow(generator).to receive(:initialize_template) end it "works without without errors" do - expect(subject.initialize_guardfile(%w(rspec))).to be_zero + expect(subject.initialize_guardfile(%w[rspec])).to be_zero end it "adds the template" do expect(generator).to receive(:initialize_template).with("rspec") - subject.initialize_guardfile(%w(rspec)) + subject.initialize_guardfile(%w[rspec]) end end it "initializes the template of the passed Guard" do expect(generator).to receive(:initialize_template).with("rspec") - subject.initialize_guardfile(%w(rspec)) + subject.initialize_guardfile(%w[rspec]) end end @@ -236,8 +238,8 @@ context "when passed an unknown guard name" do before do - expect(generator).to receive(:initialize_template).with("foo"). - and_raise(Guard::Guardfile::Generator::NoSuchPlugin, "foo") + expect(generator).to receive(:initialize_template).with("foo") + .and_raise(Guard::Guardfile::Generator::NoSuchPlugin, "foo") end it "returns an exit code" do @@ -245,7 +247,7 @@ "Could not load 'guard/foo' or '~/.guard/templates/foo'"\ " or find class Guard::Foo\n" ) - expect(subject.initialize_guardfile(%w(foo))).to be(1) + expect(subject.initialize_guardfile(%w[foo])).to be(1) end end end diff --git a/spec/lib/guard/cli_spec.rb b/spec/lib/guard/cli_spec.rb index 224950523..7b35e2a54 100644 --- a/spec/lib/guard/cli_spec.rb +++ b/spec/lib/guard/cli_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/cli" RSpec.describe Guard::CLI do @@ -11,14 +13,14 @@ before do @options = {} allow(subject).to receive(:options).and_return(@options) - allow(::Guard::DslDescriber).to receive(:new).with(no_args). - and_return(dsl_describer) + allow(::Guard::DslDescriber).to receive(:new).with(no_args) + .and_return(dsl_describer) - allow(Guard::Cli::Environments::EvaluateOnly).to receive(:new). - and_return(bare_environment) + allow(Guard::Cli::Environments::EvaluateOnly).to receive(:new) + .and_return(bare_environment) - allow(Guard::Cli::Environments::Valid).to receive(:new). - and_return(valid_environment) + allow(Guard::Cli::Environments::Valid).to receive(:new) + .and_return(valid_environment) end describe "#start" do @@ -49,8 +51,8 @@ it "passes options" do pending "needs JRuby support first" if defined?(JRUBY_VERSION) - expect(Guard::Cli::Environments::Valid).to receive(:new).with(@options). - and_return(valid_environment) + expect(Guard::Cli::Environments::Valid).to receive(:new).with(@options) + .and_return(valid_environment) begin subject.start rescue SystemExit @@ -99,8 +101,8 @@ describe "#init" do before do - allow(Guard::Cli::Environments::Valid).to receive(:new). - and_return(valid_environment) + allow(Guard::Cli::Environments::Valid).to receive(:new) + .and_return(valid_environment) allow(valid_environment).to receive(:initialize_guardfile).and_return(0) end @@ -119,8 +121,8 @@ end it "passes options" do - expect(Guard::Cli::Environments::Valid).to receive(:new).with(@options). - and_return(valid_environment) + expect(Guard::Cli::Environments::Valid).to receive(:new).with(@options) + .and_return(valid_environment) begin subject.init rescue SystemExit diff --git a/spec/lib/guard/commander_spec.rb b/spec/lib/guard/commander_spec.rb index 730f6306d..45316f9a3 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/commander" RSpec.describe Guard::Commander do @@ -33,7 +35,7 @@ # from stop() allow(Guard).to receive(:setup) allow(Guard).to receive(:listener).and_return(listener) - allow(session).to receive(:watchdirs).and_return(%w(dir1 dir2)) + allow(session).to receive(:watchdirs).and_return(%w[dir1 dir2]) allow(Guard).to receive(:interactor).and_return(interactor) # Simulate Ctrl-D in Pry, or Ctrl-C in non-interactive mode @@ -49,8 +51,8 @@ end it "displays an info message" do - expect(Guard::UI).to receive(:info). - with("Guard is now watching at 'dir1', 'dir2'") + expect(Guard::UI).to receive(:info) + .with("Guard is now watching at 'dir1', 'dir2'") Guard.start end @@ -205,8 +207,8 @@ context "with invalid parameter" do it "raises an ArgumentError" do - expect { Guard.pause(:invalid) }. - to raise_error(ArgumentError, "invalid mode: :invalid") + expect { Guard.pause(:invalid) } + .to raise_error(ArgumentError, "invalid mode: :invalid") end end end @@ -249,8 +251,8 @@ context "with invalid parameter" do it "raises an ArgumentError" do - expect { Guard.pause(:invalid) }. - to raise_error(ArgumentError, "invalid mode: :invalid") + expect { Guard.pause(:invalid) } + .to raise_error(ArgumentError, "invalid mode: :invalid") end end end @@ -260,8 +262,8 @@ let(:dsl_describer) { instance_double("Guard::DslDescriber") } before do - allow(Guard::DslDescriber).to receive(:new).with(no_args). - and_return(dsl_describer) + allow(Guard::DslDescriber).to receive(:new).with(no_args) + .and_return(dsl_describer) end it "shows list of plugins" do diff --git a/spec/lib/guard/commands/all_spec.rb b/spec/lib/guard/commands/all_spec.rb index ecd438431..795b8e2c7 100644 --- a/spec/lib/guard/commands/all_spec.rb +++ b/spec/lib/guard/commands/all_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/plugin" require "guard/commands/all" @@ -14,13 +16,12 @@ let(:session) { instance_double("Guard::Internals::Session") } class FakePry < Pry::Command - def self.output - end + def self.output; end end before do - allow(session).to receive(:convert_scope).with(given_scope). - and_return(converted_scope) + allow(session).to receive(:convert_scope).with(given_scope) + .and_return(converted_scope) allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) @@ -38,8 +39,8 @@ def self.output let(:converted_scope) { [{ groups: [], plugins: [] }, []] } it "runs the :run_all action" do - expect(Guard).to receive(:async_queue_add). - with([:guard_run_all, groups: [], plugins: []]) + expect(Guard).to receive(:async_queue_add) + .with([:guard_run_all, groups: [], plugins: []]) FakePry.process end @@ -50,8 +51,8 @@ def self.output let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } it "runs the :run_all action with the given scope" do - expect(Guard).to receive(:async_queue_add). - with([:guard_run_all, groups: [foo_group], plugins: []]) + expect(Guard).to receive(:async_queue_add) + .with([:guard_run_all, groups: [foo_group], plugins: []]) FakePry.process("foo") end @@ -62,8 +63,8 @@ def self.output let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } it "runs the :run_all action with the given scope" do - expect(Guard).to receive(:async_queue_add). - with([:guard_run_all, plugins: [bar_guard], groups: []]) + expect(Guard).to receive(:async_queue_add) + .with([:guard_run_all, plugins: [bar_guard], groups: []]) FakePry.process("bar") end diff --git a/spec/lib/guard/commands/change_spec.rb b/spec/lib/guard/commands/change_spec.rb index 639523c2b..3cc1561f1 100644 --- a/spec/lib/guard/commands/change_spec.rb +++ b/spec/lib/guard/commands/change_spec.rb @@ -1,11 +1,12 @@ +# frozen_string_literal: true + require "guard/commands/change" RSpec.describe Guard::Commands::Change do let(:output) { instance_double(Pry::Output) } class FakePry < Pry::Command - def self.output - end + def self.output; end end before do @@ -19,8 +20,8 @@ def self.output context "with a file" do it "runs the :run_on_changes action with the given file" do - expect(::Guard).to receive(:async_queue_add). - with(modified: ["foo"], added: [], removed: []) + expect(::Guard).to receive(:async_queue_add) + .with(modified: ["foo"], added: [], removed: []) FakePry.process("foo") end @@ -28,8 +29,8 @@ def self.output context "with multiple files" do it "runs the :run_on_changes action with the given files" do - expect(::Guard).to receive(:async_queue_add). - with(modified: %w(foo bar baz), added: [], removed: []) + expect(::Guard).to receive(:async_queue_add) + .with(modified: %w[foo bar baz], added: [], removed: []) FakePry.process("foo", "bar", "baz") end diff --git a/spec/lib/guard/commands/notification_spec.rb b/spec/lib/guard/commands/notification_spec.rb index 81fc375c3..86a3d46cd 100644 --- a/spec/lib/guard/commands/notification_spec.rb +++ b/spec/lib/guard/commands/notification_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/commands/notification" RSpec.describe Guard::Commands::Notification do @@ -9,8 +11,8 @@ def self.output; end before do allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command). - with("notification") do |&block| + allow(Pry::Commands).to receive(:create_command) + .with("notification") do |&block| FakePry.instance_eval(&block) end diff --git a/spec/lib/guard/commands/pause_spec.rb b/spec/lib/guard/commands/pause_spec.rb index 674ed6560..3dbce6ec6 100644 --- a/spec/lib/guard/commands/pause_spec.rb +++ b/spec/lib/guard/commands/pause_spec.rb @@ -1,9 +1,10 @@ +# frozen_string_literal: true + require "guard/commands/pause" RSpec.describe Guard::Commands::Pause do class FakePry < Pry::Command - def self.output - end + def self.output; end end before do diff --git a/spec/lib/guard/commands/reload_spec.rb b/spec/lib/guard/commands/reload_spec.rb index b58fde6bb..054a46011 100644 --- a/spec/lib/guard/commands/reload_spec.rb +++ b/spec/lib/guard/commands/reload_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/commands/reload" require "guard/internals/session" @@ -17,8 +19,8 @@ def self.output; end end before do - allow(session).to receive(:convert_scope).with(given_scope). - and_return(converted_scope) + allow(session).to receive(:convert_scope).with(given_scope) + .and_return(converted_scope) allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) @@ -36,8 +38,8 @@ def self.output; end let(:converted_scope) { [{ groups: [], plugins: [] }, []] } it "triggers the :reload action" do - expect(Guard).to receive(:async_queue_add). - with([:guard_reload, { groups: [], plugins: [] }]) + expect(Guard).to receive(:async_queue_add) + .with([:guard_reload, { groups: [], plugins: [] }]) FakePry.process end end @@ -47,8 +49,8 @@ def self.output; end let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } it "triggers the :reload action with the given scope" do - expect(Guard).to receive(:async_queue_add). - with([:guard_reload, { groups: [foo_group], plugins: [] }]) + expect(Guard).to receive(:async_queue_add) + .with([:guard_reload, { groups: [foo_group], plugins: [] }]) FakePry.process("foo") end end @@ -58,8 +60,8 @@ def self.output; end let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } it "triggers the :reload action with the given scope" do - expect(Guard).to receive(:async_queue_add). - with([:guard_reload, { plugins: [bar_guard], groups: [] }]) + expect(Guard).to receive(:async_queue_add) + .with([:guard_reload, { plugins: [bar_guard], groups: [] }]) FakePry.process("bar") end end diff --git a/spec/lib/guard/commands/scope_spec.rb b/spec/lib/guard/commands/scope_spec.rb index 2a877300b..5fd4e5a1c 100644 --- a/spec/lib/guard/commands/scope_spec.rb +++ b/spec/lib/guard/commands/scope_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/commands/scope" require "guard/internals/session" @@ -18,8 +20,8 @@ def self.output; end end before do - allow(session).to receive(:convert_scope).with(given_scope). - and_return(converted_scope) + allow(session).to receive(:convert_scope).with(given_scope) + .and_return(converted_scope) allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) @@ -51,8 +53,8 @@ def self.output; end let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } it "sets up the scope with the given scope" do - expect(scope).to receive(:from_interactor). - with(groups: [foo_group], plugins: []) + expect(scope).to receive(:from_interactor) + .with(groups: [foo_group], plugins: []) FakePry.process("foo") end end @@ -62,8 +64,8 @@ def self.output; end let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } it "runs the :scope= action with the given scope" do - expect(scope).to receive(:from_interactor). - with(plugins: [bar_guard], groups: []) + expect(scope).to receive(:from_interactor) + .with(plugins: [bar_guard], groups: []) FakePry.process("bar") end end diff --git a/spec/lib/guard/commands/show_spec.rb b/spec/lib/guard/commands/show_spec.rb index 4ed7344cb..fbfe2bf9f 100644 --- a/spec/lib/guard/commands/show_spec.rb +++ b/spec/lib/guard/commands/show_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/commands/show" # TODO: we only need the async queue diff --git a/spec/lib/guard/config_spec.rb b/spec/lib/guard/config_spec.rb index 92456df8d..f5574f77a 100644 --- a/spec/lib/guard/config_spec.rb +++ b/spec/lib/guard/config_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/config" RSpec.describe Guard::Config, exclude_stubs: [:Nenv] do diff --git a/spec/lib/guard/deprecated/dsl_spec.rb b/spec/lib/guard/deprecated/dsl_spec.rb index 8e09b536f..4a2594e6f 100644 --- a/spec/lib/guard/deprecated/dsl_spec.rb +++ b/spec/lib/guard/deprecated/dsl_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/config" unless Guard::Config.new.strict? @@ -24,13 +26,13 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } before do # TODO: this is a workaround for a bad require loop - allow_any_instance_of(Guard::Config).to receive(:strict?). - and_return(false) + allow_any_instance_of(Guard::Config).to receive(:strict?) + .and_return(false) require "guard/guardfile/evaluator" - allow(Guard::Guardfile::Evaluator).to receive(:new). - and_return(evaluator) + allow(Guard::Guardfile::Evaluator).to receive(:new) + .and_return(evaluator) allow(evaluator).to receive(:evaluate_guardfile) @@ -38,15 +40,15 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Dsl::ClassMethods::EVALUATE_GUARDFILE) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Dsl::ClassMethods::EVALUATE_GUARDFILE) subject.evaluate_guardfile end it "delegates to Guard::Guardfile::Generator" do - expect(Guard::Guardfile::Evaluator).to receive(:new). - with(foo: "bar") { evaluator } + expect(Guard::Guardfile::Evaluator).to receive(:new) + .with(foo: "bar") { evaluator } expect(evaluator).to receive(:evaluate_guardfile) diff --git a/spec/lib/guard/deprecated/evaluator_spec.rb b/spec/lib/guard/deprecated/evaluator_spec.rb index d656836c3..f8a1d4d69 100644 --- a/spec/lib/guard/deprecated/evaluator_spec.rb +++ b/spec/lib/guard/deprecated/evaluator_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/config" unless Guard::Config.new.strict? @@ -8,8 +10,7 @@ RSpec.describe Guard::Deprecated::Evaluator do subject do class TestClass - def evaluate - end + def evaluate; end end described_class.add_deprecated(TestClass) TestClass.new @@ -28,8 +29,8 @@ def evaluate end it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Evaluator::EVALUATE_GUARDFILE) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Evaluator::EVALUATE_GUARDFILE) subject.evaluate_guardfile end @@ -41,8 +42,8 @@ def evaluate describe "#reevaluate_guardfile" do it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Evaluator::REEVALUATE_GUARDFILE) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Evaluator::REEVALUATE_GUARDFILE) subject.reevaluate_guardfile end end diff --git a/spec/lib/guard/deprecated/guard_spec.rb b/spec/lib/guard/deprecated/guard_spec.rb index f5a76dc21..5981faf57 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/config" unless Guard::Config.new.strict? @@ -17,8 +19,7 @@ subject do module TestModule - def self.listener - end + def self.listener; end def self._pluginless_guardfile? false @@ -44,8 +45,8 @@ def self._pluginless_guardfile? end it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::GUARDS) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::GUARDS) subject.guards end @@ -59,8 +60,8 @@ def self._pluginless_guardfile? before { allow(plugins).to receive(:add).with("rspec", {}) } it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::ADD_GUARD) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::ADD_GUARD) subject.add_guard("rspec") end @@ -78,26 +79,26 @@ def self._pluginless_guardfile? end before do - allow(Guard::PluginUtil).to receive(:new).with("rspec"). - and_return(plugin_util) + allow(Guard::PluginUtil).to receive(:new).with("rspec") + .and_return(plugin_util) end it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::GET_GUARD_CLASS) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::GET_GUARD_CLASS) subject.get_guard_class("rspec") end it "delegates to Guard::PluginUtil" do - expect(plugin_util).to receive(:plugin_class). - with(fail_gracefully: false) + expect(plugin_util).to receive(:plugin_class) + .with(fail_gracefully: false) subject.get_guard_class("rspec") end describe ":fail_gracefully" do it "pass it to get_guard_class" do - expect(plugin_util).to receive(:plugin_class). - with(fail_gracefully: true) + expect(plugin_util).to receive(:plugin_class) + .with(fail_gracefully: true) subject.get_guard_class("rspec", true) end end @@ -113,8 +114,8 @@ def self._pluginless_guardfile? end it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::LOCATE_GUARD) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::LOCATE_GUARD) subject.locate_guard("rspec") end @@ -131,8 +132,8 @@ def self._pluginless_guardfile? before { allow(Guard::PluginUtil).to receive(:plugin_names) } it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::GUARD_GEM_NAMES) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::GUARD_GEM_NAMES) subject.guard_gem_names end @@ -146,8 +147,8 @@ def self._pluginless_guardfile? describe ".running" do it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::RUNNING) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::RUNNING) subject.running end @@ -155,8 +156,8 @@ def self._pluginless_guardfile? describe ".lock" do it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::LOCK) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::LOCK) subject.lock end @@ -164,8 +165,8 @@ def self._pluginless_guardfile? describe ".listener=" do it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::LISTENER_ASSIGN) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::LISTENER_ASSIGN) subject.listener = 123 end @@ -177,20 +178,20 @@ def self._pluginless_guardfile? describe "reset_evaluator" do it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::RESET_EVALUATOR) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::RESET_EVALUATOR) subject.reset_evaluator({}) end end describe "evaluator" do before do - allow(Guard::Guardfile::Evaluator).to receive(:new). - and_return(double("evaluator")) + allow(Guard::Guardfile::Evaluator).to receive(:new) + .and_return(double("evaluator")) end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::EVALUATOR) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::EVALUATOR) subject.evaluator end end @@ -199,14 +200,14 @@ def self._pluginless_guardfile? let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } before do - allow(::Guard::Guardfile::Evaluator).to receive(:new). - and_return(evaluator) + allow(::Guard::Guardfile::Evaluator).to receive(:new) + .and_return(evaluator) allow(evaluator).to receive(:evaluate) end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::EVALUATOR) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::EVALUATOR) subject.evaluate_guardfile end @@ -226,8 +227,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::OPTIONS) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::OPTIONS) subject.options end @@ -277,8 +278,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::ADD_GROUP) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::ADD_GROUP) subject.add_group(:foo) end @@ -295,8 +296,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::ADD_PLUGIN) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::ADD_PLUGIN) subject.add_plugin(:foo) end @@ -316,8 +317,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::GROUP) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::GROUP) subject.group(:foo) end @@ -338,8 +339,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::PLUGIN) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::PLUGIN) subject.plugin(:foo) end @@ -356,8 +357,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::GROUPS) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::GROUPS) subject.groups(:foo) end @@ -374,8 +375,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::PLUGINS) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::PLUGINS) subject.plugins(:foo) end @@ -392,8 +393,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::SCOPE) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::SCOPE) subject.scope end @@ -408,8 +409,8 @@ def self._pluginless_guardfile? end it "show deprecation warning" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guard::ClassMethods::SCOPE_ASSIGN) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guard::ClassMethods::SCOPE_ASSIGN) subject.scope = { foo: :bar } end diff --git a/spec/lib/guard/deprecated/guardfile_spec.rb b/spec/lib/guard/deprecated/guardfile_spec.rb index 997528c7d..c52bd7d5d 100644 --- a/spec/lib/guard/deprecated/guardfile_spec.rb +++ b/spec/lib/guard/deprecated/guardfile_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/config" unless Guard::Config.new.strict? @@ -21,22 +23,22 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } template = Guard::Guardfile::Generator::GUARDFILE_TEMPLATE allow(FileUtils).to receive(:cp).with(template, "Guardfile") - allow(Guard::Guardfile::Generator).to receive(:new). - and_return(generator) + allow(Guard::Guardfile::Generator).to receive(:new) + .and_return(generator) allow(generator).to receive(:create_guardfile) end it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guardfile::ClassMethods::CREATE_GUARDFILE) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guardfile::ClassMethods::CREATE_GUARDFILE) subject.create_guardfile end it "delegates to Guard::Guardfile::Generator" do - expect(Guard::Guardfile::Generator).to receive(:new). - with(foo: "bar") { generator } + expect(Guard::Guardfile::Generator).to receive(:new) + .with(foo: "bar") { generator } expect(generator).to receive(:create_guardfile) @@ -54,8 +56,8 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Guardfile::ClassMethods::INITIALIZE_TEMPLATE) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Guardfile::ClassMethods::INITIALIZE_TEMPLATE) subject.initialize_template("rspec") end @@ -77,8 +79,8 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(described_class::ClassMethods::INITIALIZE_ALL_TEMPLATES) + expect(Guard::UI).to receive(:deprecation) + .with(described_class::ClassMethods::INITIALIZE_ALL_TEMPLATES) subject.initialize_all_templates end diff --git a/spec/lib/guard/deprecated/watcher_spec.rb b/spec/lib/guard/deprecated/watcher_spec.rb index c1db5cbe7..f803b0883 100644 --- a/spec/lib/guard/deprecated/watcher_spec.rb +++ b/spec/lib/guard/deprecated/watcher_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/config" unless Guard::Config.new.strict? @@ -22,27 +24,27 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) - allow(evaluator).to receive(:guardfile_path). - and_return(File.expand_path("foo")) + allow(evaluator).to receive(:guardfile_path) + .and_return(File.expand_path("foo")) - allow(::Guard::Guardfile::Evaluator).to receive(:new).with(options). - and_return(evaluator) + allow(::Guard::Guardfile::Evaluator).to receive(:new).with(options) + .and_return(evaluator) allow(Guard::UI).to receive(:deprecation) end describe ".match_guardfile?" do it "displays a deprecation warning to the user" do - expect(Guard::UI).to receive(:deprecation). - with(Guard::Deprecated::Watcher::ClassMethods::MATCH_GUARDFILE) + expect(Guard::UI).to receive(:deprecation) + .with(Guard::Deprecated::Watcher::ClassMethods::MATCH_GUARDFILE) - files = %w(foo bar) + files = %w[foo bar] subject.match_guardfile?(files) end it "matches against current guardfile" do - expect(subject.match_guardfile?(%w(foo bar))).to be(true) - expect(subject.match_guardfile?(%w(bar))).to be(false) + expect(subject.match_guardfile?(%w[foo bar])).to be(true) + expect(subject.match_guardfile?(%w[bar])).to be(false) end end end diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index 39c55187f..ceef61770 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -1,4 +1,5 @@ -# encoding: utf-8 +# frozen_string_literal: true + require "guard/plugin" require "guard/dsl_describer" require "formatador" @@ -28,7 +29,8 @@ stub_const "Guard::Test", class_double("Guard::Plugin") stub_const "Guard::Another", class_double("Guard::Plugin") - @output = "" + # TODO: Reenable rubocop and refactor to +'' one 2.2 compatibility is dropped + @output = String.new # Strip escape sequences allow(STDOUT).to receive(:tty?).and_return(false) @@ -64,7 +66,7 @@ allow(plugins).to receive(:all).with("more").and_return([]) allow(Guard::PluginUtil).to receive(:plugin_names) do - %w(test another even more) + %w[test another even more] end end @@ -95,7 +97,7 @@ allow(groups).to receive(:all).and_return [ instance_double("Guard::Group", name: :default, title: "Default"), instance_double("Guard::Group", name: :a, title: "A"), - instance_double("Guard::Group", name: :b, title: "B"), + instance_double("Guard::Group", name: :b, title: "B") ] allow(plugins).to receive(:all).with(group: :default) do @@ -139,8 +141,8 @@ ) allow(Guard::Notifier).to receive(:connect).once - allow(Guard::Notifier).to receive(:detected). - and_return([{ name: :gntp, options: { sticky: true } }]) + allow(Guard::Notifier).to receive(:detected) + .and_return([{ name: :gntp, options: { sticky: true } }]) allow(Guard::Notifier).to receive(:disconnect).once end diff --git a/spec/lib/guard/dsl_reader_spec.rb b/spec/lib/guard/dsl_reader_spec.rb index 92efb5df6..5cb1ae71d 100644 --- a/spec/lib/guard/dsl_reader_spec.rb +++ b/spec/lib/guard/dsl_reader_spec.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + require "guard/dsl_reader" RSpec.describe Guard::DslReader, exclude_stubs: [Guard::Dsl] do - methods = %w( + methods = %w[ initialize guard notification interactor group watch callback ignore ignore! logger scope directories clearing - ).map(&:to_sym) + ].map(&:to_sym) methods.each do |meth| describe "\##{meth} signature" do @@ -24,7 +26,7 @@ it "reports the name as a String" do subject.guard("foo", bar: :baz) - expect(subject.plugin_names).to eq(%w(foo)) + expect(subject.plugin_names).to eq(%w[foo]) end end @@ -36,7 +38,7 @@ it "reports the name as a String" do subject.guard(name, bar: :baz) - expect(subject.plugin_names).to eq(%w(foo)) + expect(subject.plugin_names).to eq(%w[foo]) end end end @@ -46,7 +48,7 @@ subject.guard("foo", bar: :baz) subject.guard("bar", bar: :baz) subject.guard("baz", bar: :baz) - expect(subject.plugin_names).to eq(%w(foo bar baz)) + expect(subject.plugin_names).to eq(%w[foo bar baz]) end end diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index 583b4a0b4..2fc788138 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/plugin" require "guard/dsl" @@ -68,8 +70,8 @@ let(:contents) { "ignore! %r{^foo}, /bar/" } it "replaces listener regexps" do - expect(session).to receive(:guardfile_ignore_bang=). - with([[/^foo/, /bar/]]) + expect(session).to receive(:guardfile_ignore_bang=) + .with([[/^foo/, /bar/]]) evaluator.call(contents) end @@ -79,11 +81,11 @@ let(:contents) { "ignore! %r{.txt$}, /.*\\.zip/\n ignore! %r{^foo}" } it "replaces listener ignores, but keeps ignore! ignores" do - allow(session).to receive(:guardfile_ignore_bang=). - with([[/.txt$/, /.*\.zip/]]) + allow(session).to receive(:guardfile_ignore_bang=) + .with([[/.txt$/, /.*\.zip/]]) - expect(session).to receive(:guardfile_ignore_bang=). - with([[/.txt$/, /.*\.zip/], [/^foo/]]) + expect(session).to receive(:guardfile_ignore_bang=) + .with([[/.txt$/, /.*\.zip/], [/^foo/]]) evaluator.call(contents) end @@ -144,10 +146,10 @@ def method_for(klass, meth) end context "with interactor options" do - let(:contents) { 'interactor option1: \'a\', option2: 123' } + let(:contents) { "interactor option1: 'a', option2: 123" } it "passes the options to the interactor" do - expect(Guard::Interactor).to receive(:options=). - with(option1: "a", option2: 123) + expect(Guard::Interactor).to receive(:options=) + .with(option1: "a", option2: 123) evaluator.call(contents) end @@ -159,8 +161,8 @@ def method_for(klass, meth) let(:contents) { "group :w" } it "displays an error" do - expect(::Guard::UI).to receive(:error). - with("No Guard plugins found in the group 'w',"\ + expect(::Guard::UI).to receive(:error) + .with("No Guard plugins found in the group 'w',"\ " please add at least one.") evaluator.call(contents) @@ -171,8 +173,8 @@ def method_for(klass, meth) let(:contents) { "group :all" } it "raises an error" do - expect { evaluator.call(contents) }. - to raise_error( + expect { evaluator.call(contents) } + .to raise_error( Guard::Dsl::Error, /'all' is not an allowed group name!/ ) @@ -183,8 +185,8 @@ def method_for(klass, meth) let(:contents) { "group 'all'" } it "raises an error" do - expect { evaluator.call(contents) }. - to raise_error( + expect { evaluator.call(contents) } + .to raise_error( Guard::Dsl::Error, /'all' is not an allowed group name!/ ) @@ -199,17 +201,17 @@ def method_for(klass, meth) expect(groups).to receive(:add).with(:y, {}) expect(groups).to receive(:add).with(:x, halt_on_fail: true) - expect(plugins).to receive(:add). - with(:pow, watchers: [], callbacks: [], group: :default) + expect(plugins).to receive(:add) + .with(:pow, watchers: [], callbacks: [], group: :default) - expect(plugins).to receive(:add). - with(:test, watchers: [], callbacks: [], group: :w) + expect(plugins).to receive(:add) + .with(:test, watchers: [], callbacks: [], group: :w) - expect(plugins).to receive(:add). - with(:rspec, watchers: [], callbacks: [], group: :x).twice + expect(plugins).to receive(:add) + .with(:rspec, watchers: [], callbacks: [], group: :x).twice - expect(plugins).to receive(:add). - with(:less, watchers: [], callbacks: [], group: :y) + expect(plugins).to receive(:add) + .with(:less, watchers: [], callbacks: [], group: :y) expect(session).to receive(:guardfile_notification=).with(growl: {}) evaluator.call(contents) @@ -229,11 +231,11 @@ def method_for(klass, meth) describe "#guard" do context "with single-quoted name" do - let(:contents) { 'guard \'test\'' } + let(:contents) { "guard 'test'" } it "loads a guard specified as a quoted string from the DSL" do - expect(plugins).to receive(:add). - with("test", watchers: [], callbacks: [], group: :default) + expect(plugins).to receive(:add) + .with("test", watchers: [], callbacks: [], group: :default) evaluator.call(contents) end @@ -243,8 +245,8 @@ def method_for(klass, meth) let(:contents) { 'guard "test"' } it "loads a guard specified as a double quoted string from the DSL" do - expect(plugins).to receive(:add). - with("test", watchers: [], callbacks: [], group: :default) + expect(plugins).to receive(:add) + .with("test", watchers: [], callbacks: [], group: :default) evaluator.call(contents) end @@ -254,8 +256,8 @@ def method_for(klass, meth) let(:contents) { "guard :test" } it "loads a guard specified as a symbol from the DSL" do - expect(plugins).to receive(:add). - with(:test, watchers: [], callbacks: [], group: :default) + expect(plugins).to receive(:add) + .with(:test, watchers: [], callbacks: [], group: :default) evaluator.call(contents) end @@ -265,14 +267,14 @@ def method_for(klass, meth) let(:contents) { "guard(:test)" } it "adds the plugin" do - expect(plugins).to receive(:add). - with(:test, watchers: [], callbacks: [], group: :default) + expect(plugins).to receive(:add) + .with(:test, watchers: [], callbacks: [], group: :default) evaluator.call(contents) end end context "with options" do - let(:contents) { 'guard \'test\', opt_a: 1, opt_b: \'fancy\'' } + let(:contents) { "guard 'test', opt_a: 1, opt_b: 'fancy'" } it "passes options to plugin" do options = { @@ -294,8 +296,8 @@ def method_for(klass, meth) it "adds plugin with group info" do expect(groups).to receive(:add).with(:foo, {}) expect(groups).to receive(:add).with(:bar, {}) - expect(plugins).to receive(:add). - with(:test, watchers: [], callbacks: [], group: :bar) + expect(plugins).to receive(:add) + .with(:test, watchers: [], callbacks: [], group: :bar) evaluator.call(contents) end @@ -310,11 +312,11 @@ def method_for(klass, meth) expect(groups).to receive(:add).with(:foo, {}) expect(groups).to receive(:add).with(:bar, {}) - expect(plugins).to receive(:add). - with(:test, watchers: [], callbacks: [], group: :bar) + expect(plugins).to receive(:add) + .with(:test, watchers: [], callbacks: [], group: :bar) - expect(plugins).to receive(:add). - with(:rspec, watchers: [], callbacks: [], group: :default) + expect(plugins).to receive(:add) + .with(:rspec, watchers: [], callbacks: [], group: :default) evaluator.call(contents) end @@ -347,8 +349,8 @@ def method_for(klass, meth) group: :default } - expect(plugins).to receive(:add). - with(:dummy, call_params) do |_, options| + expect(plugins).to receive(:add) + .with(:dummy, call_params) do |_, options| expect(options[:watchers].size).to eq 2 expect(options[:watchers][0].pattern).to eq "a" expect(options[:watchers][0].action.call).to eq proc { "b" }.call @@ -356,18 +358,18 @@ def method_for(klass, meth) expect(options[:watchers][1].action).to be_nil end - allow(Guard::Watcher).to receive(:new).with("a", anything). - and_return(watcher_a) + allow(Guard::Watcher).to receive(:new).with("a", anything) + .and_return(watcher_a) - allow(Guard::Watcher).to receive(:new).with("c", nil). - and_return(watcher_c) + allow(Guard::Watcher).to receive(:new).with("c", nil) + .and_return(watcher_c) evaluator.call(contents) end end context "with watch in main scope" do - let(:contents) { 'watch(\'a\')' } + let(:contents) { "watch('a')" } let(:watcher) do instance_double("Guard::Watcher", pattern: "a", action: nil) end @@ -379,15 +381,15 @@ def method_for(klass, meth) group: :default } - expect(plugins).to receive(:add). - with(:plugin, plugin_options) do |_, options| + expect(plugins).to receive(:add) + .with(:plugin, plugin_options) do |_, options| expect(options[:watchers].size).to eq 1 expect(options[:watchers][0].pattern).to eq "a" expect(options[:watchers][0].action).to be_nil end - allow(Guard::Watcher).to receive(:new).with("a", nil). - and_return(watcher) + allow(Guard::Watcher).to receive(:new).with("a", nil) + .and_return(watcher) evaluator.call(contents) end @@ -427,19 +429,19 @@ def self.call(_plugin, _event, _args) expect(opt[:callbacks].size).to eq 2 - callback_0 = opt[:callbacks][0] + callback0 = opt[:callbacks][0] - expect(callback_0[:events]).to eq :start_end + expect(callback0[:events]).to eq :start_end plugin = instance_double("Guard::Plugin", title: "RSpec") - result = callback_0[:listener].call(plugin, :start_end, "foo") + result = callback0[:listener].call(plugin, :start_end, "foo") - expect(result).to eq 'RSpec executed \'start_end\' hook'\ + expect(result).to eq "RSpec executed 'start_end' hook"\ " with foo!" - callback_1 = opt[:callbacks][1] - expect(callback_1[:events]).to eq [:start_begin, :run_all_begin] - expect(callback_1[:listener]).to eq MyCustomCallback + callback1 = opt[:callbacks][1] + expect(callback1[:events]).to eq %i[start_begin run_all_begin] + expect(callback1[:listener]).to eq MyCustomCallback end evaluator.call(contents) @@ -483,20 +485,20 @@ def self.call(_plugin, _event, _args) end context "with logger level 'error'" do - let(:contents) { 'logger level: \'error\'' } + let(:contents) { "logger level: 'error'" } it { is_expected.to have_received(:options=).with(level: :error) } end context "with logger template" do - let(:contents) { 'logger template: \':message - :severity\'' } + let(:contents) { "logger template: ':message - :severity'" } it do - is_expected.to have_received(:options=). - with(template: ":message - :severity") + is_expected.to have_received(:options=) + .with(template: ":message - :severity") end end context "with a logger time format" do - let(:contents) { 'logger time_format: \'%Y\'' } + let(:contents) { "logger time_format: '%Y'" } it do is_expected.to have_received(:options=).with(time_format: "%Y") end @@ -508,12 +510,12 @@ def self.call(_plugin, _event, _args) end context "with logger only filter from a string" do - let(:contents) { 'logger only: \'jasmine\'' } + let(:contents) { "logger only: 'jasmine'" } it { is_expected.to have_received(:options=).with(only: /jasmine/i) } end context "with logger only filter from an array of symbols and string" do - let(:contents) { 'logger only: [:rspec, \'cucumber\']' } + let(:contents) { "logger only: [:rspec, 'cucumber']" } it do is_expected.to have_received(:options=).with(only: /rspec|cucumber/i) end @@ -525,15 +527,15 @@ def self.call(_plugin, _event, _args) end context "with logger except filter from a string" do - let(:contents) { 'logger except: \'jasmine\'' } + let(:contents) { "logger except: 'jasmine'" } it { is_expected.to have_received(:options=).with(except: /jasmine/i) } end context "with logger except filter from array of symbols and string" do - let(:contents) { 'logger except: [:rspec, \'cucumber\', :jasmine]' } + let(:contents) { "logger except: [:rspec, 'cucumber', :jasmine]" } it do - is_expected.to have_received(:options=). - with(except: /rspec|cucumber|jasmine/i) + is_expected.to have_received(:options=) + .with(except: /rspec|cucumber|jasmine/i) end end end @@ -543,8 +545,8 @@ def self.call(_plugin, _event, _args) let(:contents) { "logger level: :baz" } it "shows a warning" do - expect(Guard::UI).to receive(:warning). - with "Invalid log level `baz` ignored."\ + expect(Guard::UI).to receive(:warning) + .with "Invalid log level `baz` ignored."\ " Please use either :debug, :info, :warn or :error." evaluator.call(contents) @@ -560,8 +562,8 @@ def self.call(_plugin, _event, _args) let(:contents) { "logger only: :jasmine, except: :rspec" } it "shows a warning" do - expect(Guard::UI).to receive(:warning). - with "You cannot specify the logger options"\ + expect(Guard::UI).to receive(:warning) + .with "You cannot specify the logger options"\ " :only and :except at the same time." evaluator.call(contents) end @@ -579,7 +581,7 @@ def self.call(_plugin, _event, _args) let(:contents) { "scope plugins: [:foo, :bar]" } it "sets the guardfile's default scope" do - expect(session).to receive(:guardfile_scope).with(plugins: [:foo, :bar]) + expect(session).to receive(:guardfile_scope).with(plugins: %i[foo bar]) evaluator.call(contents) end end @@ -594,7 +596,7 @@ def self.call(_plugin, _event, _args) end it "sets the watchdirs to given values" do - expect(session).to receive(:watchdirs=).with(%w(foo bar)) + expect(session).to receive(:watchdirs=).with(%w[foo bar]) evaluator.call(contents) end end diff --git a/spec/lib/guard/group_spec.rb b/spec/lib/guard/group_spec.rb index e516e6f12..e779baf99 100644 --- a/spec/lib/guard/group_spec.rb +++ b/spec/lib/guard/group_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/group" RSpec.describe Guard::Group do diff --git a/spec/lib/guard/guardfile/evaluator_spec.rb b/spec/lib/guard/guardfile/evaluator_spec.rb index 6a1425d5c..e18b653c9 100644 --- a/spec/lib/guard/guardfile/evaluator_spec.rb +++ b/spec/lib/guard/guardfile/evaluator_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/guardfile/evaluator" # TODO: shouldn't be necessary @@ -33,9 +35,9 @@ it "displays an error message and raises original exception" do stub_user_guard_rb - allow(dsl).to receive(:evaluate). - and_raise(Guard::Dsl::Error, - "Invalid Guardfile, original error is:") + allow(dsl).to receive(:evaluate) + .and_raise(Guard::Dsl::Error, + "Invalid Guardfile, original error is:") expect { subject.evaluate }.to raise_error(Guard::Dsl::Error) end @@ -47,8 +49,8 @@ stub_user_guardfile stub_user_project_guardfile - expect { subject.evaluate }. - to raise_error(Guard::Guardfile::Evaluator::NoGuardfileError) + expect { subject.evaluate } + .to raise_error(Guard::Guardfile::Evaluator::NoGuardfileError) end end @@ -76,8 +78,8 @@ stub_guardfile(" ") allow(dsl).to receive(:evaluate).with("", "", 1) - expect { subject.evaluate }. - to raise_error(Guard::Guardfile::Evaluator::NoPluginsError) + expect { subject.evaluate } + .to raise_error(Guard::Guardfile::Evaluator::NoPluginsError) end end @@ -110,8 +112,8 @@ end it "raises error" do - expect { subject.evaluate }. - to raise_error(Guard::Guardfile::Evaluator::NoCustomGuardfile) + expect { subject.evaluate } + .to raise_error(Guard::Guardfile::Evaluator::NoCustomGuardfile) end end end @@ -151,8 +153,8 @@ before do stub_file(File.expand_path("../relative_path_to_Guardfile"), valid_guardfile_string) - allow(dsl).to receive(:evaluate). - with(valid_guardfile_string, anything, 1) + allow(dsl).to receive(:evaluate) + .with(valid_guardfile_string, anything, 1) end end end @@ -197,8 +199,8 @@ let(:options) { { contents: 'guard "test" {watch("c")}' } } it "returns true" do - allow(dsl_reader). - to receive(:evaluate).with('guard "test" {watch("c")}', "", 1) + allow(dsl_reader) + .to receive(:evaluate).with('guard "test" {watch("c")}', "", 1) allow(dsl_reader).to receive(:plugin_names).and_return(["test"]) expect(subject).to be_guardfile_include("test") @@ -209,8 +211,8 @@ let(:options) { { contents: 'guard "other" {watch("c")}' } } it "returns false" do - allow(dsl_reader). - to receive(:evaluate).with('guard "test" {watch("c")}', "", 1) + allow(dsl_reader) + .to receive(:evaluate).with('guard "test" {watch("c")}', "", 1) allow(dsl_reader).to receive(:plugin_names).and_return(["other"]) expect(subject).to_not be_guardfile_include("test") diff --git a/spec/lib/guard/guardfile/generator_spec.rb b/spec/lib/guard/guardfile/generator_spec.rb index 536e14604..0e23ee830 100644 --- a/spec/lib/guard/guardfile/generator_spec.rb +++ b/spec/lib/guard/guardfile/generator_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/guardfile/generator" RSpec.describe Guard::Guardfile::Generator do @@ -5,8 +7,8 @@ let(:guardfile_generator) { described_class.new } it "has a valid Guardfile template" do - allow(File).to receive(:exist?). - with(described_class::GUARDFILE_TEMPLATE).and_call_original + allow(File).to receive(:exist?) + .with(described_class::GUARDFILE_TEMPLATE).and_call_original expect(File.exist?(described_class::GUARDFILE_TEMPLATE)).to be_truthy end @@ -35,8 +37,8 @@ end it "displays an error message" do - expect(::Guard::UI).to receive(:error). - with(%r{Guardfile already exists at .*/Guardfile}) + expect(::Guard::UI).to receive(:error) + .with(%r{Guardfile already exists at .*/Guardfile}) begin subject.create_guardfile rescue SystemExit @@ -89,18 +91,18 @@ let(:template) { File.join(described_class::HOME_TEMPLATES, "/bar") } it "copies the Guardfile template and initializes the Guard" do - expect(IO).to receive(:read). - with(template).and_return "Template content" + expect(IO).to receive(:read) + .with(template).and_return "Template content" expected = "\nTemplate content\n" - expect(IO).to receive(:binwrite). - with("Guardfile", expected, open_args: ["a"]) + expect(IO).to receive(:binwrite) + .with("Guardfile", expected, open_args: ["a"]) allow(plugin_util).to receive(:plugin_class).with(fail_gracefully: true) - allow(Guard::PluginUtil).to receive(:new).with("bar"). - and_return(plugin_util) + allow(Guard::PluginUtil).to receive(:new).with("bar") + .and_return(plugin_util) described_class.new.initialize_template("bar") end @@ -117,14 +119,14 @@ end it "notifies the user about the problem" do - expect { described_class.new.initialize_template("foo") }. - to raise_error(Guard::Guardfile::Generator::Error) + expect { described_class.new.initialize_template("foo") } + .to raise_error(Guard::Guardfile::Generator::Error) end end end describe "#initialize_all_templates" do - let(:plugins) { %w(rspec spork phpunit) } + let(:plugins) { %w[rspec spork phpunit] } before do expect(::Guard::PluginUtil).to receive(:plugin_names) { plugins } diff --git a/spec/lib/guard/interactor_spec.rb b/spec/lib/guard/interactor_spec.rb index 8cfc5d645..b6adc5458 100644 --- a/spec/lib/guard/interactor_spec.rb +++ b/spec/lib/guard/interactor_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/interactor" # TODO: this shouldn't be necessary diff --git a/spec/lib/guard/internals/debugging_spec.rb b/spec/lib/guard/internals/debugging_spec.rb index 02fd1242d..76e9be2d4 100644 --- a/spec/lib/guard/internals/debugging_spec.rb +++ b/spec/lib/guard/internals/debugging_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/internals/debugging" RSpec.describe Guard::Internals::Debugging do diff --git a/spec/lib/guard/internals/groups_spec.rb b/spec/lib/guard/internals/groups_spec.rb index d375c3673..f1c11e2f5 100644 --- a/spec/lib/guard/internals/groups_spec.rb +++ b/spec/lib/guard/internals/groups_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/internals/groups" RSpec.describe Guard::Internals::Groups do @@ -12,7 +14,7 @@ context "with only default groups" do it "initializes the groups" do - expect(subject.all.map(&:name)).to eq [:common, :default] + expect(subject.all.map(&:name)).to eq %i[common default] end end @@ -21,11 +23,11 @@ let(:backend) { instance_double("Guard::Group", name: :backend) } before do - allow(Guard::Group).to receive(:new).with(:frontend, {}). - and_return(frontend) + allow(Guard::Group).to receive(:new).with(:frontend, {}) + .and_return(frontend) - allow(Guard::Group).to receive(:new).with(:backend, {}). - and_return(backend) + allow(Guard::Group).to receive(:new).with(:backend, {}) + .and_return(backend) subject.add(:frontend) subject.add(:backend) @@ -85,8 +87,8 @@ let(:backend) { instance_double("Guard::Group", name: :backend) } before do - allow(Guard::Group).to receive(:new).with("frontend", {}). - and_return(frontend) + allow(Guard::Group).to receive(:new).with("frontend", {}) + .and_return(frontend) subject.add("frontend") end diff --git a/spec/lib/guard/internals/plugins_spec.rb b/spec/lib/guard/internals/plugins_spec.rb index 7dfba5b8e..27eaaee34 100644 --- a/spec/lib/guard/internals/plugins_spec.rb +++ b/spec/lib/guard/internals/plugins_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/internals/plugins" RSpec.describe Guard::Internals::Plugins do @@ -18,23 +20,23 @@ def stub_plugin(name, group) let(:pu_foobaz) { instance_double("Guard::PluginUtil") } before do - allow(Guard::PluginUtil).to receive(:new).with("foobar"). - and_return(pu_foobar) + allow(Guard::PluginUtil).to receive(:new).with("foobar") + .and_return(pu_foobar) - allow(Guard::PluginUtil).to receive(:new).with("foobaz"). - and_return(pu_foobaz) + allow(Guard::PluginUtil).to receive(:new).with("foobaz") + .and_return(pu_foobaz) - allow(pu_foobar).to receive(:initialize_plugin).with(group: "frontend"). - and_return(foo_bar_frontend) + allow(pu_foobar).to receive(:initialize_plugin).with(group: "frontend") + .and_return(foo_bar_frontend) - allow(pu_foobaz).to receive(:initialize_plugin).with(group: "frontend"). - and_return(foo_baz_frontend) + allow(pu_foobaz).to receive(:initialize_plugin).with(group: "frontend") + .and_return(foo_baz_frontend) - allow(pu_foobar).to receive(:initialize_plugin).with(group: "backend"). - and_return(foo_bar_backend) + allow(pu_foobar).to receive(:initialize_plugin).with(group: "backend") + .and_return(foo_bar_backend) - allow(pu_foobaz).to receive(:initialize_plugin).with(group: "backend"). - and_return(foo_baz_backend) + allow(pu_foobaz).to receive(:initialize_plugin).with(group: "backend") + .and_return(foo_baz_backend) end describe "#all" do @@ -59,15 +61,15 @@ def stub_plugin(name, group) context "find a plugin by as string" do it "returns an array of plugins if plugins are found" do - expect(subject.all("foo-bar")). - to match_array([foo_bar_backend, foo_bar_frontend]) + expect(subject.all("foo-bar")) + .to match_array([foo_bar_backend, foo_bar_frontend]) end end context "find a plugin by as symbol" do it "returns an array of plugins if plugins are found" do - expect(subject.all(:'foo-bar')). - to match_array([foo_bar_backend, foo_bar_frontend]) + expect(subject.all(:'foo-bar')) + .to match_array([foo_bar_backend, foo_bar_frontend]) end it "returns an empty array when no plugin is found" do @@ -77,8 +79,8 @@ def stub_plugin(name, group) context "find plugins matching a regexp" do it "returns an array of plugins if plugins are found" do - expect(subject.all(/^foobar/)). - to match_array([foo_bar_backend, foo_bar_frontend]) + expect(subject.all(/^foobar/)) + .to match_array([foo_bar_backend, foo_bar_frontend]) end it "returns an empty array when no plugin is found" do @@ -88,15 +90,15 @@ def stub_plugin(name, group) context "find plugins by their group as a string" do it "returns an array of plugins if plugins are found" do - expect(subject.all(group: "backend")). - to eq [foo_bar_backend, foo_baz_backend] + expect(subject.all(group: "backend")) + .to eq [foo_bar_backend, foo_baz_backend] end end context "find plugins by their group as a symbol" do it "returns an array of plugins if plugins are found" do - expect(subject.all(group: :frontend)). - to eq [foo_bar_frontend, foo_baz_frontend] + expect(subject.all(group: :frontend)) + .to eq [foo_bar_frontend, foo_baz_frontend] end it "returns an empty array when no plugin is found" do @@ -106,13 +108,13 @@ def stub_plugin(name, group) context "find plugins by their group & name" do it "returns an array of plugins if plugins are found" do - expect(subject.all(group: "backend", name: "foo-bar")). - to eq [foo_bar_backend] + expect(subject.all(group: "backend", name: "foo-bar")) + .to eq [foo_bar_backend] end it "returns an empty array when no plugin is found" do - expect(subject.all(group: :unknown, name: :'foo-baz')). - to be_empty + expect(subject.all(group: :unknown, name: :'foo-baz')) + .to be_empty end end end diff --git a/spec/lib/guard/internals/scope_spec.rb b/spec/lib/guard/internals/scope_spec.rb index 353fc84ba..23f02581a 100644 --- a/spec/lib/guard/internals/scope_spec.rb +++ b/spec/lib/guard/internals/scope_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/internals/scope" RSpec.describe Guard::Internals::Scope do @@ -40,7 +42,7 @@ # TODO: move to Session? describe "#to_hash" do - [:group, :plugin].each do |scope| + %i[group plugin].each do |scope| describe scope.inspect do let(:hash) do subject.to_hash[:"#{scope}s"].map(&:name).map(&:to_s) @@ -61,8 +63,8 @@ context "when not set in interactor" do context "when set in commandline" do before do - allow(session).to receive(:"cmdline_#{scope}s"). - and_return(%w(baz)) + allow(session).to receive(:"cmdline_#{scope}s") + .and_return(%w[baz]) end it "uses commandline scope" do @@ -73,8 +75,8 @@ context "when not set in commandline" do context "when set in Guardfile" do before do - allow(session).to receive(:"guardfile_#{scope}_scope"). - and_return(%w(baz)) + allow(session).to receive(:"guardfile_#{scope}_scope") + .and_return(%w[baz]) end it "uses guardfile scope" do diff --git a/spec/lib/guard/internals/session_spec.rb b/spec/lib/guard/internals/session_spec.rb index db9bcc957..bfcec9216 100644 --- a/spec/lib/guard/internals/session_spec.rb +++ b/spec/lib/guard/internals/session_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/internals/session" RSpec.describe Guard::Internals::Session do @@ -43,7 +45,7 @@ context "with the plugin option" do let(:options) do { - plugin: %w(cucumber jasmine), + plugin: %w[cucumber jasmine], guardfile_contents: "guard :jasmine do; end; "\ "guard :cucumber do; end; guard :coffeescript do; end" } @@ -60,20 +62,20 @@ end it "initializes the plugin scope" do - allow(plugins).to receive(:add).with("cucumber", {}). - and_return(cucumber) + allow(plugins).to receive(:add).with("cucumber", {}) + .and_return(cucumber) - allow(plugins).to receive(:add).with("jasmine", {}). - and_return(jasmine) + allow(plugins).to receive(:add).with("jasmine", {}) + .and_return(jasmine) - expect(subject.cmdline_plugins).to match_array(%w(cucumber jasmine)) + expect(subject.cmdline_plugins).to match_array(%w[cucumber jasmine]) end end context "with the group option" do let(:options) do { - group: %w(backend frontend), + group: %w[backend frontend], guardfile_contents: "group :backend do; end; "\ "group :frontend do; end; group :excluded do; end" } @@ -87,7 +89,7 @@ end it "initializes the group scope" do - expect(subject.cmdline_groups).to match_array(%w(backend frontend)) + expect(subject.cmdline_groups).to match_array(%w[backend frontend]) end end end @@ -205,38 +207,38 @@ end it "returns a group scope" do - scopes, = subject.convert_scope %w(backend) + scopes, = subject.convert_scope %w[backend] expect(scopes).to eq(groups: [backend], plugins: []) - scopes, = subject.convert_scope %w(frontend) + scopes, = subject.convert_scope %w[frontend] expect(scopes).to eq(groups: [frontend], plugins: []) end it "returns a plugin scope" do - scopes, = subject.convert_scope %w(foo) + scopes, = subject.convert_scope %w[foo] expect(scopes).to eq(plugins: [foo], groups: []) - scopes, = subject.convert_scope %w(bar) + scopes, = subject.convert_scope %w[bar] expect(scopes).to eq(plugins: [bar], groups: []) end it "returns multiple group scopes" do - scopes, = subject.convert_scope %w(backend frontend) + scopes, = subject.convert_scope %w[backend frontend] expected = { groups: [backend, frontend], plugins: [] } expect(scopes).to eq(expected) end it "returns multiple plugin scopes" do - scopes, = subject.convert_scope %w(foo bar) + scopes, = subject.convert_scope %w[foo bar] expect(scopes).to eq(plugins: [foo, bar], groups: []) end it "returns a plugin and group scope" do - scopes, = subject.convert_scope %w(foo backend) + scopes, = subject.convert_scope %w[foo backend] expect(scopes).to eq(plugins: [foo], groups: [backend]) end it "returns the unkown scopes" do - _, unknown = subject.convert_scope %w(unknown scope) - expect(unknown).to eq %w(unknown scope) + _, unknown = subject.convert_scope %w[unknown scope] + expect(unknown).to eq %w[unknown scope] end end diff --git a/spec/lib/guard/internals/state_spec.rb b/spec/lib/guard/internals/state_spec.rb index daed798d4..f406a8938 100644 --- a/spec/lib/guard/internals/state_spec.rb +++ b/spec/lib/guard/internals/state_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/internals/state" RSpec.describe Guard::Internals::State do diff --git a/spec/lib/guard/internals/tracing_spec.rb b/spec/lib/guard/internals/tracing_spec.rb index 95c1c162a..275e62a3a 100644 --- a/spec/lib/guard/internals/tracing_spec.rb +++ b/spec/lib/guard/internals/tracing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/internals/tracing" RSpec.describe Guard::Internals::Tracing do @@ -54,7 +56,7 @@ end context "with command arguments" do - let(:args) { %w(true 123) } + let(:args) { %w[true 123] } context "when #system" do let(:meth) { "system" } @@ -96,7 +98,7 @@ end context "with command arguments" do - let(:args) { %w(true 123) } + let(:args) { %w[true 123] } context "when #system" do let(:meth) { :system } diff --git a/spec/lib/guard/internals/traps_spec.rb b/spec/lib/guard/internals/traps_spec.rb index 64e8e82a6..bb0b21587 100644 --- a/spec/lib/guard/internals/traps_spec.rb +++ b/spec/lib/guard/internals/traps_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/internals/traps" RSpec.describe Guard::Internals::Traps do diff --git a/spec/lib/guard/jobs/pry_wrapper_spec.rb b/spec/lib/guard/jobs/pry_wrapper_spec.rb index e8bf35696..af3910228 100644 --- a/spec/lib/guard/jobs/pry_wrapper_spec.rb +++ b/spec/lib/guard/jobs/pry_wrapper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/jobs/pry_wrapper" RSpec.describe Guard::Jobs::PryWrapper do @@ -32,7 +34,7 @@ allow(Guard).to receive(:listener).and_return(listener) allow(Pry).to receive(:config).and_return(pry_config) - allow(Shellany::Sheller).to receive(:run).with(*%w(hash stty)) { false } + allow(Shellany::Sheller).to receive(:run).with("hash", "stty") { false } allow(groups).to receive(:all).and_return([]) allow(session).to receive(:groups).and_return(groups) @@ -51,8 +53,8 @@ allow(Guard::Commands::Show).to receive(:import) allow(Guard::Commands::Scope).to receive(:import) - allow(Guard::Jobs::TerminalSettings).to receive(:new). - and_return(terminal_settings) + allow(Guard::Jobs::TerminalSettings).to receive(:new) + .and_return(terminal_settings) allow(terminal_settings).to receive(:configurable?).and_return(false) allow(terminal_settings).to receive(:save) @@ -130,7 +132,7 @@ let(:prompt) { subject.send(:_prompt, ">") } before do - allow(Shellany::Sheller).to receive(:run).with(*%w(hash stty)) { false } + allow(Shellany::Sheller).to receive(:run).with("hash", "stty") { false } allow(scope).to receive(:titles).and_return(["all"]) allow(listener).to receive(:paused?).and_return(false) @@ -142,8 +144,8 @@ context "Guard is not paused" do it 'displays "guard"' do - expect(prompt.call(double, 0, pry)). - to eq "[0] guard(main)> " + expect(prompt.call(double, 0, pry)) + .to eq "[0] guard(main)> " end end @@ -153,25 +155,25 @@ end it 'displays "pause"' do - expect(prompt.call(double, 0, pry)). - to eq "[0] pause(main)> " + expect(prompt.call(double, 0, pry)) + .to eq "[0] pause(main)> " end end context "with a groups scope" do before do - allow(scope).to receive(:titles).and_return(%w(Backend Frontend)) + allow(scope).to receive(:titles).and_return(%w[Backend Frontend]) end it "displays the group scope title in the prompt" do - expect(prompt.call(double, 0, pry)). - to eq "[0] Backend,Frontend guard(main)> " + expect(prompt.call(double, 0, pry)) + .to eq "[0] Backend,Frontend guard(main)> " end end context "with a plugins scope" do before do - allow(scope).to receive(:titles).and_return(%w(RSpec Ronn)) + allow(scope).to receive(:titles).and_return(%w[RSpec Ronn]) end it "displays the group scope title in the prompt" do diff --git a/spec/lib/guard/jobs/sleep_spec.rb b/spec/lib/guard/jobs/sleep_spec.rb index 155240802..6cc171197 100644 --- a/spec/lib/guard/jobs/sleep_spec.rb +++ b/spec/lib/guard/jobs/sleep_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/jobs/sleep" RSpec.describe Guard::Jobs::Sleep do diff --git a/spec/lib/guard/notifier_spec.rb b/spec/lib/guard/notifier_spec.rb index 1230ec973..5f23724d9 100644 --- a/spec/lib/guard/notifier_spec.rb +++ b/spec/lib/guard/notifier_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/notifier" RSpec.describe Guard::Notifier do @@ -59,8 +61,8 @@ context "with multiple parameters" do it "notifies" do - expect(notifier).to receive(:notify). - with("A", priority: 2, image: :failed) + expect(notifier).to receive(:notify) + .with("A", priority: 2, image: :failed) subject.notify("A", priority: 2, image: :failed) end end @@ -71,8 +73,8 @@ end it "shows an error" do - expect(Guard::UI).to receive(:error). - with(/Notification failed for .+: an error/) + expect(Guard::UI).to receive(:error) + .with(/Notification failed for .+: an error/) subject.notify("A", priority: 2, image: :failed) end diff --git a/spec/lib/guard/options_spec.rb b/spec/lib/guard/options_spec.rb index 5d55472d7..683e4cf03 100644 --- a/spec/lib/guard/options_spec.rb +++ b/spec/lib/guard/options_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/options" RSpec.describe Guard::Options do diff --git a/spec/lib/guard/plugin_spec.rb b/spec/lib/guard/plugin_spec.rb index a326fbeb1..a5712dcdf 100644 --- a/spec/lib/guard/plugin_spec.rb +++ b/spec/lib/guard/plugin_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/plugin" require "guard/watcher" @@ -54,7 +56,7 @@ context "with a callback" do it "adds the callback" do block = instance_double(Proc) - events = [:start_begin, :start_end] + events = %i[start_begin start_end] callbacks = [{ events: events, listener: block }] Guard::Plugin.new(callbacks: callbacks) expect(Guard::Plugin.callbacks.first[0][0].callbacks).to eq(callbacks) @@ -93,8 +95,8 @@ class DuMmy < Guard::Plugin end it "reads the default template" do - expect(File).to receive(:read). - with("/guard-dummy/lib/guard/dummy/templates/Guardfile") { true } + expect(File).to receive(:read) + .with("/guard-dummy/lib/guard/dummy/templates/Guardfile") { true } subject.template("/guard-dummy") end @@ -116,8 +118,8 @@ class DuMmy < Guard::Plugin let(:default) { instance_double("Guard::Group", name: :default) } it "output the short plugin name" do - expect(subject.new.to_s). - to match(/#/) + expect(subject.new.to_s) + .to match(/#/) end end end @@ -139,7 +141,7 @@ class DuMmy < Guard::Plugin end it "can add multiple callbacks" do - described_class.add_callback(listener, foo, [:event1, :event2]) + described_class.add_callback(listener, foo, %i[event1 event2]) result = described_class.callbacks[[foo, :event1]] expect(result).to include(listener) @@ -223,11 +225,11 @@ def stop end foo = Foo.new - expect(described_class).to receive(:notify). - with(foo, :stop_begin, "args") + expect(described_class).to receive(:notify) + .with(foo, :stop_begin, "args") - expect(described_class).to receive(:notify). - with(foo, :special_sauce, "first_arg", "second_arg") + expect(described_class).to receive(:notify) + .with(foo, :special_sauce, "first_arg", "second_arg") foo.stop end diff --git a/spec/lib/guard/plugin_util_spec.rb b/spec/lib/guard/plugin_util_spec.rb index b41b78502..6bcc40b95 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/plugin_util" require "guard/guardfile/evaluator" @@ -23,13 +25,13 @@ instance_double(spec, name: "guard-myplugin"), instance_double(spec, name: "gem1", full_gem_path: "/gem1"), instance_double(spec, name: "gem2", full_gem_path: "/gem2"), - instance_double(spec, name: "guard-compat"), + instance_double(spec, name: "guard-compat") ] - allow(File).to receive(:exist?). - with("/gem1/lib/guard/gem1.rb") { false } + allow(File).to receive(:exist?) + .with("/gem1/lib/guard/gem1.rb") { false } - allow(File).to receive(:exist?). - with("/gem2/lib/guard/gem2.rb") { true } + allow(File).to receive(:exist?) + .with("/gem2/lib/guard/gem2.rb") { true } gem = class_double(Gem::Specification) stub_const("Gem::Specification", gem) @@ -64,9 +66,9 @@ let(:plugin_util) { described_class.new("rspec") } before do - allow_any_instance_of(described_class). - to receive(:plugin_class). - and_return(guard_rspec_class) + allow_any_instance_of(described_class) + .to receive(:plugin_class) + .and_return(guard_rspec_class) end context "with a plugin inheriting from Guard::Plugin" do @@ -87,8 +89,8 @@ subject { described_class.new("rspec") } it "returns the path of a Guard gem" do - expect(Gem::Specification).to receive(:find_by_name). - with("guard-rspec") { double(full_gem_path: "gems/guard-rspec") } + expect(Gem::Specification).to receive(:find_by_name) + .with("guard-rspec") { double(full_gem_path: "gems/guard-rspec") } expect(subject.plugin_location).to eq "gems/guard-rspec" end end @@ -96,11 +98,11 @@ describe "#plugin_class" do after do # TODO: use RSpec's stub const - consts = [:Classname, - :DashedClassName, - :UnderscoreClassName, - :VSpec, - :Inline] + consts = %i[Classname + DashedClassName + UnderscoreClassName + VSpec + Inline] consts.each do |const| begin @@ -116,8 +118,8 @@ expect(::Guard::UI).to receive(:error).with(/plugin_util.rb/) plugin = described_class.new("notAGuardClass") - allow(plugin).to receive(:require).with("guard/notaguardclass"). - and_raise(LoadError, "cannot load such file --") + allow(plugin).to receive(:require).with("guard/notaguardclass") + .and_raise(LoadError, "cannot load such file --") plugin.plugin_class end @@ -199,8 +201,8 @@ class VSpec it "returns the Guard class" do allow(Guard).to receive(:constants).and_return([:Inline]) - allow(Guard).to receive(:const_get).with(:Inline). - and_return(plugin_class) + allow(Guard).to receive(:const_get).with(:Inline) + .and_return(plugin_class) expect(subject).to_not receive(:require) expect(subject.plugin_class).to eq plugin_class @@ -231,8 +233,8 @@ class VSpec end it "shows an info message" do - expect(::Guard::UI).to receive(:info). - with "Guardfile already includes myguard guard" + expect(::Guard::UI).to receive(:info) + .with "Guardfile already includes myguard guard" described_class.new("myguard").add_to_guardfile end @@ -246,20 +248,20 @@ class VSpec let(:io) { StringIO.new } before do - allow(evaluator).to receive(:evaluate). - and_raise(Guard::Guardfile::Evaluator::NoPluginsError) + allow(evaluator).to receive(:evaluate) + .and_raise(Guard::Guardfile::Evaluator::NoPluginsError) allow(gem_spec).to receive(:full_gem_path).and_return(location) allow(evaluator).to receive(:guardfile_include?) { false } allow(Guard).to receive(:constants).and_return([:MyGuard]) - allow(Guard).to receive(:const_get).with(:MyGuard). - and_return(plugin_class) + allow(Guard).to receive(:const_get).with(:MyGuard) + .and_return(plugin_class) - allow(Gem::Specification).to receive(:find_by_name). - with("guard-myguard").and_return(gem_spec) + allow(Gem::Specification).to receive(:find_by_name) + .with("guard-myguard").and_return(gem_spec) - allow(plugin_class).to receive(:template).with(location). - and_return("Template content") + allow(plugin_class).to receive(:template).with(location) + .and_return("Template content") allow(File).to receive(:read).with("Guardfile") { "Guardfile content" } allow(File).to receive(:open).with("Guardfile", "wb").and_yield io @@ -282,14 +284,14 @@ class VSpec allow(gem_spec).to receive(:full_gem_path).and_return(location) allow(evaluator).to receive(:guardfile_include?) { false } allow(Guard).to receive(:constants).and_return([:MyGuard]) - allow(Guard).to receive(:const_get).with(:MyGuard). - and_return(plugin_class) + allow(Guard).to receive(:const_get).with(:MyGuard) + .and_return(plugin_class) - allow(Gem::Specification).to receive(:find_by_name). - with("guard-myguard").and_return(gem_spec) + allow(Gem::Specification).to receive(:find_by_name) + .with("guard-myguard").and_return(gem_spec) - allow(plugin_class).to receive(:template).with(location). - and_return("Template content") + allow(plugin_class).to receive(:template).with(location) + .and_return("Template content") allow(File).to receive(:read).with("Guardfile") { "Guardfile content" } allow(File).to receive(:open).with("Guardfile", "wb").and_yield io diff --git a/spec/lib/guard/runner_spec.rb b/spec/lib/guard/runner_spec.rb index 10a9486c2..36c81b6bc 100644 --- a/spec/lib/guard/runner_spec.rb +++ b/spec/lib/guard/runner_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/runner" require "guard/plugin" @@ -41,8 +43,8 @@ describe "#run" do before do - allow(scope).to receive(:grouped_plugins).with({}). - and_return([[nil, [foo_plugin, bar_plugin, baz_plugin]]]) + allow(scope).to receive(:grouped_plugins).with({}) + .and_return([[nil, [foo_plugin, bar_plugin, baz_plugin]]]) allow(ui_config).to receive(:with_progname).and_yield end @@ -75,8 +77,8 @@ let(:scope_hash) { { plugin: :bar } } it "executes the supervised task on the specified plugin only" do - expect(scope).to receive(:grouped_plugins).with(scope_hash). - and_return([[nil, [bar_plugin]]]) + expect(scope).to receive(:grouped_plugins).with(scope_hash) + .and_return([[nil, [bar_plugin]]]) expect(bar_plugin).to receive(:my_task) expect(foo_plugin).to_not receive(:my_task) @@ -129,23 +131,23 @@ end # disable reevaluator - allow(scope).to receive(:grouped_plugins).with(group: :common). - and_return([[nil, []]]) + allow(scope).to receive(:grouped_plugins).with(group: :common) + .and_return([[nil, []]]) # foo in default group - allow(scope).to receive(:grouped_plugins).with(group: :default). - and_return([[nil, [foo_plugin]]]) + allow(scope).to receive(:grouped_plugins).with(group: :default) + .and_return([[nil, [foo_plugin]]]) - allow(scope).to receive(:grouped_plugins).with(no_args). - and_return([[nil, [foo_plugin]]]) + allow(scope).to receive(:grouped_plugins).with(no_args) + .and_return([[nil, [foo_plugin]]]) allow(ui_config).to receive(:with_progname).and_yield end it "always calls UI.clearable" do expect(Guard::UI).to receive(:clearable) - expect(scope).to receive(:grouped_plugins).with(no_args). - and_return([[nil, [foo_plugin]]]) + expect(scope).to receive(:grouped_plugins).with(no_args) + .and_return([[nil, [foo_plugin]]]) subject.run_on_changes(*changes) end @@ -153,21 +155,21 @@ context "when clearable" do it "clear UI" do expect(Guard::UI).to receive(:clear) - expect(scope).to receive(:grouped_plugins).with(no_args). - and_return([[nil, [foo_plugin]]]) + expect(scope).to receive(:grouped_plugins).with(no_args) + .and_return([[nil, [foo_plugin]]]) subject.run_on_changes(*changes) end end context "with no changes" do it "does not run any task" do - %w( + %w[ run_on_modifications run_on_change run_on_additions run_on_removals run_on_deletion - ).each do |task| + ].each do |task| expect(foo_plugin).to_not receive(task.to_sym) end subject.run_on_changes(*changes) @@ -175,12 +177,12 @@ end context "with modified files but modified paths is empty" do - let(:modified) { %w(file.txt image.png) } + let(:modified) { %w[file.txt image.png] } before do changes[0] = modified - expect(watcher_module).to receive(:match_files).once. - with(foo_plugin, modified).and_return([]) + expect(watcher_module).to receive(:match_files).once + .with(foo_plugin, modified).and_return([]) # stub so respond_to? works end @@ -192,12 +194,12 @@ end context "with modified paths" do - let(:modified) { %w(file.txt image.png) } + let(:modified) { %w[file.txt image.png] } before do changes[0] = modified - expect(watcher_module).to receive(:match_files). - with(foo_plugin, modified).and_return(modified) + expect(watcher_module).to receive(:match_files) + .with(foo_plugin, modified).and_return(modified) end it "executes the :run_first_task_found task" do @@ -207,12 +209,12 @@ end context "with added files but added paths is empty" do - let(:added) { %w(file.txt image.png) } + let(:added) { %w[file.txt image.png] } before do changes[0] = added - expect(watcher_module).to receive(:match_files).once. - with(foo_plugin, added).and_return([]) + expect(watcher_module).to receive(:match_files).once + .with(foo_plugin, added).and_return([]) end it "does not call run anything" do @@ -222,12 +224,12 @@ end context "with added paths" do - let(:added) { %w(file.txt image.png) } + let(:added) { %w[file.txt image.png] } before do changes[1] = added - expect(watcher_module).to receive(:match_files). - with(foo_plugin, added).and_return(added) + expect(watcher_module).to receive(:match_files) + .with(foo_plugin, added).and_return(added) end it "executes the :run_on_additions task" do @@ -237,12 +239,12 @@ end context "with non-matching removed paths" do - let(:removed) { %w(file.txt image.png) } + let(:removed) { %w[file.txt image.png] } before do changes[2] = removed - expect(watcher_module).to receive(:match_files).once. - with(foo_plugin, removed) { [] } + expect(watcher_module).to receive(:match_files).once + .with(foo_plugin, removed) { [] } # stub so respond_to? works allow(foo_plugin).to receive(:run_on_removals) @@ -255,12 +257,12 @@ end context "with matching removed paths" do - let(:removed) { %w(file.txt image.png) } + let(:removed) { %w[file.txt image.png] } before do changes[2] = removed - expect(watcher_module).to receive(:match_files). - with(foo_plugin, removed) { removed } + expect(watcher_module).to receive(:match_files) + .with(foo_plugin, removed) { removed } end it "executes the :run_on_removals task" do @@ -297,21 +299,21 @@ end it "calls :begin and :end hooks" do - expect(foo_plugin).to receive(:hook). - with("regular_without_arg_begin") + expect(foo_plugin).to receive(:hook) + .with("regular_without_arg_begin") - expect(foo_plugin).to receive(:hook). - with("regular_without_arg_end", true) + expect(foo_plugin).to receive(:hook) + .with("regular_without_arg_end", true) subject.send(:_supervise, foo_plugin, :regular_without_arg) end it "passes the result of the supervised method to the :end hook" do - expect(foo_plugin).to receive(:hook). - with("regular_without_arg_begin") + expect(foo_plugin).to receive(:hook) + .with("regular_without_arg_begin") - expect(foo_plugin).to receive(:hook). - with("regular_without_arg_end", true) + expect(foo_plugin).to receive(:hook) + .with("regular_without_arg_end", true) subject.send(:_supervise, foo_plugin, :regular_without_arg) end @@ -319,8 +321,8 @@ context "with arguments" do before do - allow(foo_plugin).to receive(:regular_with_arg). - with("given_path") { "I'm a success" } + allow(foo_plugin).to receive(:regular_with_arg) + .with("given_path") { "I'm a success" } end it "does not remove the Guard" do diff --git a/spec/lib/guard/terminal_spec.rb b/spec/lib/guard/terminal_spec.rb index 871896e74..035072d59 100644 --- a/spec/lib/guard/terminal_spec.rb +++ b/spec/lib/guard/terminal_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/terminal" RSpec.describe Guard::Terminal do @@ -18,23 +20,23 @@ let(:result) { [0, "\e[H\e[2J", ""] } it "clears the screen using 'clear'" do - expect(sheller).to receive(:system).with("printf '\33c\e[3J';"). - and_return(result) + expect(sheller).to receive(:system).with("printf '\33c\e[3J';") + .and_return(result) ::Guard::Terminal.clear end end context "when the clear command fails" do - let(:result) { [nil, nil, "Guard failed to run \"clear;\""] } + let(:result) { [nil, nil, 'Guard failed to run "clear;"'] } before do - allow(sheller).to receive(:system).with("printf '\33c\e[3J';"). - and_return(result) + allow(sheller).to receive(:system).with("printf '\33c\e[3J';") + .and_return(result) end it "fails" do - expect { ::Guard::Terminal.clear }. - to raise_error(Errno::ENOENT, /Guard failed to run "clear;"/) + expect { ::Guard::Terminal.clear } + .to raise_error(Errno::ENOENT, /Guard failed to run "clear;"/) end end end @@ -49,15 +51,15 @@ end context "when the clear command fails" do - let(:result) { [nil, nil, "Guard failed to run \"cls\""] } + let(:result) { [nil, nil, 'Guard failed to run "cls"'] } before do allow(sheller).to receive(:system).with("cls").and_return(result) end it "fails" do - expect { ::Guard::Terminal.clear }. - to raise_error(Errno::ENOENT, /Guard failed to run "cls"/) + expect { ::Guard::Terminal.clear } + .to raise_error(Errno::ENOENT, /Guard failed to run "cls"/) end end end diff --git a/spec/lib/guard/ui/config_spec.rb b/spec/lib/guard/ui/config_spec.rb index 37c48a9d2..059dac67b 100644 --- a/spec/lib/guard/ui/config_spec.rb +++ b/spec/lib/guard/ui/config_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/ui/config" RSpec.describe Guard::UI::Config do @@ -30,8 +32,8 @@ let(:logger_config) { instance_double("Guard::UI::Logger::Config") } before do - allow(Guard::UI::Logger::Config).to receive(:new). - and_return(logger_config) + allow(Guard::UI::Logger::Config).to receive(:new) + .and_return(logger_config) end context "with defaults" do @@ -45,8 +47,8 @@ subject { described_class.new('time_format': "foo") } it "passes deprecated options to logger" do - expect(Guard::UI::Logger::Config).to receive(:new). - with(time_format: "foo") + expect(Guard::UI::Logger::Config).to receive(:new) + .with(time_format: "foo") subject end @@ -59,8 +61,8 @@ let(:options) { { time_format: "foo" } } it "passes deprecated options to logger" do - expect(Guard::UI::Logger::Config).to receive(:new). - with(time_format: "foo") + expect(Guard::UI::Logger::Config).to receive(:new) + .with(time_format: "foo") subject end diff --git a/spec/lib/guard/ui/logger_spec.rb b/spec/lib/guard/ui/logger_spec.rb index 987881aab..1374f05b9 100644 --- a/spec/lib/guard/ui/logger_spec.rb +++ b/spec/lib/guard/ui/logger_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/ui/logger" RSpec.describe Guard::UI::Logger::Config do diff --git a/spec/lib/guard/ui_spec.rb b/spec/lib/guard/ui_spec.rb index 657a8f9e1..e70594b37 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/notifier" # NOTE: this is here so that no UI does not require anything, @@ -80,8 +82,8 @@ end it "sets the logger device" do - expect(Lumberjack::Logger).to receive(:new). - with(device, logger_config) + expect(Lumberjack::Logger).to receive(:new) + .with(device, logger_config) Guard::UI.logger end @@ -131,8 +133,8 @@ let(:new_config) { instance_double("Guard::UI::Config") } before do - allow(Guard::UI::Config).to receive(:new).with(hi: :ho). - and_return(new_config) + allow(Guard::UI::Config).to receive(:new).with(hi: :ho) + .and_return(new_config) allow(new_config).to receive(:[]).with(:hi).and_return(:ho) end @@ -212,8 +214,8 @@ describe ".deprecation" do before do - allow(ENV).to receive(:[]).with("GUARD_GEM_SILENCE_DEPRECATIONS"). - and_return(value) + allow(ENV).to receive(:[]).with("GUARD_GEM_SILENCE_DEPRECATIONS") + .and_return(value) end context "with GUARD_GEM_SILENCE_DEPRECATIONS set to 1" do @@ -283,8 +285,8 @@ context "when the command fails" do before do - allow(terminal).to receive(:clear). - and_raise(Errno::ENOENT, "failed to run command") + allow(terminal).to receive(:clear) + .and_raise(Errno::ENOENT, "failed to run command") end it "shows a warning" do @@ -324,8 +326,8 @@ context "with a plugins scope" do it "shows the plugin scoped action" do - allow(scope).to receive(:titles).with(plugins: [rspec, jasmine]). - and_return(%w(Rspec Jasmine)) + allow(scope).to receive(:titles).with(plugins: [rspec, jasmine]) + .and_return(%w[Rspec Jasmine]) expect(Guard::UI).to receive(:info).with("Reload Rspec, Jasmine") Guard::UI.action_with_scopes("Reload", plugins: [rspec, jasmine]) @@ -334,8 +336,8 @@ context "with a groups scope" do it "shows the group scoped action" do - allow(scope).to receive(:titles).with(groups: [group]). - and_return(%w(Frontend)) + allow(scope).to receive(:titles).with(groups: [group]) + .and_return(%w[Frontend]) expect(Guard::UI).to receive(:info).with("Reload Frontend") Guard::UI.action_with_scopes("Reload", groups: [group]) @@ -345,7 +347,7 @@ context "without a scope" do context "with a global plugin scope" do it "shows the global plugin scoped action" do - allow(scope).to receive(:titles).and_return(%w(Rspec Jasmine)) + allow(scope).to receive(:titles).and_return(%w[Rspec Jasmine]) expect(Guard::UI).to receive(:info).with("Reload Rspec, Jasmine") Guard::UI.action_with_scopes("Reload", {}) end @@ -353,7 +355,7 @@ context "with a global group scope" do it "shows the global group scoped action" do - allow(scope).to receive(:titles).and_return(%w(Frontend)) + allow(scope).to receive(:titles).and_return(%w[Frontend]) expect(Guard::UI).to receive(:info).with("Reload Frontend") Guard::UI.action_with_scopes("Reload", {}) end diff --git a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb index abea9cc18..4debd5fee 100644 --- a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb +++ b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/watcher/pattern/deprecated_regexp" RSpec.describe Guard::Watcher::Pattern::DeprecatedRegexp do @@ -15,7 +17,7 @@ "^foo.rb" => /^foo.rb/, "foo.rb$" => /foo.rb$/, 'foo\.rb' => /foo\.rb/, - ".*rb" => /.*rb/, + ".*rb" => /.*rb/ }.each do |pattern, regexp| context "with #{pattern}" do it "creates a Matcher with #{regexp}" do diff --git a/spec/lib/guard/watcher/pattern/match_result_spec.rb b/spec/lib/guard/watcher/pattern/match_result_spec.rb index cffe034d4..19d965adb 100644 --- a/spec/lib/guard/watcher/pattern/match_result_spec.rb +++ b/spec/lib/guard/watcher/pattern/match_result_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/watcher/pattern/match_result" RSpec.describe Guard::Watcher::Pattern::MatchResult do @@ -15,7 +17,7 @@ describe "#[]" do context "with a valid match" do - let(:match_result) { double("match_data", to_a: %w(foo bar baz)) } + let(:match_result) { double("match_data", to_a: %w[foo bar baz]) } context "when asked for the non-first item" do let(:index) { 1 } diff --git a/spec/lib/guard/watcher/pattern/matcher_spec.rb b/spec/lib/guard/watcher/pattern/matcher_spec.rb index 1f31e80f2..b156803f5 100644 --- a/spec/lib/guard/watcher/pattern/matcher_spec.rb +++ b/spec/lib/guard/watcher/pattern/matcher_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/watcher/pattern/matcher" RSpec.describe Guard::Watcher::Pattern::Matcher do @@ -44,13 +46,13 @@ describe "#==" do it "returns true for equal matchers" do - expect(described_class.new(/spec_helper\.rb/)). - to eq(described_class.new(/spec_helper\.rb/)) + expect(described_class.new(/spec_helper\.rb/)) + .to eq(described_class.new(/spec_helper\.rb/)) end it "returns false for unequal matchers" do - expect(described_class.new(/spec_helper\.rb/)). - not_to eq(described_class.new(/spec_helper\.r/)) + expect(described_class.new(/spec_helper\.rb/)) + .not_to eq(described_class.new(/spec_helper\.r/)) end end diff --git a/spec/lib/guard/watcher/pattern/pathname_path_spec.rb b/spec/lib/guard/watcher/pattern/pathname_path_spec.rb index f7b53c5e1..63e665533 100644 --- a/spec/lib/guard/watcher/pattern/pathname_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/pathname_path_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/watcher/pattern/pathname_path" RSpec.describe Guard::Watcher::Pattern::PathnamePath do diff --git a/spec/lib/guard/watcher/pattern/simple_path_spec.rb b/spec/lib/guard/watcher/pattern/simple_path_spec.rb index 54a44c0d7..491525be0 100644 --- a/spec/lib/guard/watcher/pattern/simple_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/simple_path_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/watcher/pattern/simple_path" RSpec.describe Guard::Watcher::Pattern::SimplePath do diff --git a/spec/lib/guard/watcher/pattern_spec.rb b/spec/lib/guard/watcher/pattern_spec.rb index 3db7d5f9f..9f83e1844 100644 --- a/spec/lib/guard/watcher/pattern_spec.rb +++ b/spec/lib/guard/watcher/pattern_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/watcher/pattern" RSpec.describe Guard::Watcher::Pattern do @@ -18,8 +20,8 @@ let(:pattern) { "^foo.*$" } it { is_expected.to be_a(described_class::Matcher) } it "shows a warning" do - expect(described_class::DeprecatedRegexp). - to receive(:show_deprecation).with(pattern) + expect(described_class::DeprecatedRegexp) + .to receive(:show_deprecation).with(pattern) subject end end diff --git a/spec/lib/guard/watcher_spec.rb b/spec/lib/guard/watcher_spec.rb index e870d7bc8..a044f07a9 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard/watcher" # TODO: shouldn't be needed @@ -38,13 +40,13 @@ describe "#==" do it "returns true for equal watchers" do - expect(described_class.new(/spec_helper\.rb/)). - to eq(described_class.new(/spec_helper\.rb/)) + expect(described_class.new(/spec_helper\.rb/)) + .to eq(described_class.new(/spec_helper\.rb/)) end it "returns false for unequal watchers" do - expect(described_class.new(/spec_helper\.rb/)). - not_to eq(described_class.new(/spec_helper\.r/)) + expect(described_class.new(/spec_helper\.rb/)) + .not_to eq(described_class.new(/spec_helper\.r/)) end end @@ -57,21 +59,21 @@ def matched(files) context "without a watcher action" do before do - allow(plugin).to receive(:watchers). - and_return([described_class.new(pattern)]) + allow(plugin).to receive(:watchers) + .and_return([described_class.new(pattern)]) end context "with a regex pattern" do let(:pattern) { /.*_spec\.rb/ } it "returns the paths that matches the regex" do - expect(matched(%w(foo_spec.rb foo.rb))).to eq %w(foo_spec.rb) + expect(matched(%w[foo_spec.rb foo.rb])).to eq %w[foo_spec.rb] end end context "with a string pattern" do let(:pattern) { "foo_spec.rb" } it "returns the path that matches the string" do - expect(matched(%w(foo_spec.rb foo.rb))).to eq ["foo_spec.rb"] + expect(matched(%w[foo_spec.rb foo.rb])).to eq ["foo_spec.rb"] end end end @@ -85,7 +87,7 @@ def matched(files) klass.new("spec_helper.rb", -> { "spec" }), klass.new("addition.rb", -> { 1 + 1 }), klass.new("hash.rb", -> { Hash[:foo, "bar"] }), - klass.new("array.rb", -> { %w(foo bar) }), + klass.new("array.rb", -> { %w[foo bar] }), klass.new("blank.rb", -> { "" }), klass.new(/^uptime\.rb/, -> { "" }) ] @@ -93,29 +95,29 @@ def matched(files) end it "returns a single file specified within the action" do - expect(matched(%w(spec_helper.rb))).to eq ["spec"] + expect(matched(%w[spec_helper.rb])).to eq ["spec"] end it "returns multiple files specified within the action" do - expect(matched(%w(hash.rb))).to eq %w(foo bar) + expect(matched(%w[hash.rb])).to eq %w[foo bar] end it "combines files from results of different actions" do - expect(matched(%w(spec_helper.rb array.rb))).to eq %w(spec foo bar) + expect(matched(%w[spec_helper.rb array.rb])).to eq %w[spec foo bar] end context "when action returns non-string or array of non-strings" do it "returns nothing" do - expect(matched(%w(addition.rb))).to eq [] + expect(matched(%w[addition.rb])).to eq [] end end it "returns nothing if the action response is empty" do - expect(matched(%w(blank.rb))).to eq [] + expect(matched(%w[blank.rb])).to eq [] end it "returns nothing if the action returns nothing" do - expect(matched(%w(uptime.rb))).to eq [] + expect(matched(%w[uptime.rb])).to eq [] end end @@ -129,7 +131,7 @@ def matched(files) klass.new("spec_helper.rb", -> { "spec" }), klass.new("addition.rb", -> { 1 + 1 }), klass.new("hash.rb", -> { Hash[:foo, "bar"] }), - klass.new("array.rb", -> { %w(foo bar) }), + klass.new("array.rb", -> { %w[foo bar] }), klass.new("blank.rb", -> { "" }), klass.new(/^uptime\.rb/, -> { "" }) ] @@ -137,30 +139,30 @@ def matched(files) end it "returns a single file specified within the action" do - expect(matched(%w(spec_helper.rb)).class).to be Array - expect(matched(%w(spec_helper.rb))).to_not be_empty + expect(matched(%w[spec_helper.rb]).class).to be Array + expect(matched(%w[spec_helper.rb])).to_not be_empty end it "returns multiple files specified within the action" do - expect(matched(%w(hash.rb))).to eq [{ foo: "bar" }] + expect(matched(%w[hash.rb])).to eq [{ foo: "bar" }] end it "combines the results of different actions" do - expect(matched(%w(spec_helper.rb array.rb))). - to eq ["spec", %w(foo bar)] + expect(matched(%w[spec_helper.rb array.rb])) + .to eq ["spec", %w[foo bar]] end it "returns the evaluated addition argument in an array" do - expect(matched(%w(addition.rb)).class).to be(Array) - expect(matched(%w(addition.rb))[0]).to eq 2 + expect(matched(%w[addition.rb]).class).to be(Array) + expect(matched(%w[addition.rb])[0]).to eq 2 end it "returns nothing if the action response is empty string" do - expect(matched(%w(blank.rb))).to eq [""] + expect(matched(%w[blank.rb])).to eq [""] end it "returns nothing if the action returns empty string" do - expect(matched(%w(uptime.rb))).to eq [""] + expect(matched(%w[uptime.rb])).to eq [""] end end end @@ -173,35 +175,35 @@ def matched(files) klass.new(%r{lib/(.*)\.rb}, ->(m) { "spec/#{m[1]}_spec.rb" }), klass.new(/addition(.*)\.rb/, ->(_m) { 1 + 1 }), klass.new("hash.rb", ->(_m) { Hash[:foo, "bar"] }), - klass.new(/array(.*)\.rb/, ->(_m) { %w(foo bar) }), + klass.new(/array(.*)\.rb/, ->(_m) { %w[foo bar] }), klass.new(/blank(.*)\.rb/, ->(_m) { "" }), klass.new(/^uptime\.rb/, -> { "" }) ] end it "returns a substituted single file specified within the action" do - expect(matched(%w(lib/foo.rb))).to eq ["spec/foo_spec.rb"] + expect(matched(%w[lib/foo.rb])).to eq ["spec/foo_spec.rb"] end it "returns multiple files specified within the action" do - expect(matched(%w(hash.rb))).to eq %w(foo bar) + expect(matched(%w[hash.rb])).to eq %w[foo bar] end it "combines results of different actions" do - expect(matched(%w(lib/foo.rb array.rb))). - to eq %w(spec/foo_spec.rb foo bar) + expect(matched(%w[lib/foo.rb array.rb])) + .to eq %w[spec/foo_spec.rb foo bar] end it "returns nothing if action returns non-string or non-string array" do - expect(matched(%w(addition.rb))).to eq [] + expect(matched(%w[addition.rb])).to eq [] end it "returns nothing if the action response is empty" do - expect(matched(%w(blank.rb))).to eq [] + expect(matched(%w[blank.rb])).to eq [] end it "returns nothing if the action returns nothing" do - expect(matched(%w(uptime.rb))).to eq [] + expect(matched(%w[uptime.rb])).to eq [] end end @@ -223,30 +225,30 @@ def matched(files) end it "returns a substituted single file specified within the action" do - expect(matched(%w(lib/foo.rb))).to eq %w(spec/foo_spec.rb) + expect(matched(%w[lib/foo.rb])).to eq %w[spec/foo_spec.rb] end it "returns a hash specified within the action" do - expect(matched(%w(hash.rb))).to eq [ + expect(matched(%w[hash.rb])).to eq [ { foo: "bar", file_name: "hash.rb" } ] end it "combinines results of different actions" do - expect(matched(%w(lib/foo.rb array.rb))). - to eq ["spec/foo_spec.rb", %w(foo bar array.rb)] + expect(matched(%w[lib/foo.rb array.rb])) + .to eq ["spec/foo_spec.rb", %w[foo bar array.rb]] end it "returns the evaluated addition argument + the path" do - expect(matched(%w(addition.rb))).to eq ["2addition.rb"] + expect(matched(%w[addition.rb])).to eq ["2addition.rb"] end it "returns nothing if the action response is empty string" do - expect(matched(%w(blank.rb))).to eq [""] + expect(matched(%w[blank.rb])).to eq [""] end it "returns nothing if the action returns is IO::NULL" do - expect(matched(%w(uptime.rb))).to eq [""] + expect(matched(%w[uptime.rb])).to eq [""] end end end @@ -273,7 +275,7 @@ def matched(files) expect(plugin).to receive(:watchers).and_return [ described_class.new("awesome_helper.rb", -> {}), described_class.new(/.+some_helper.rb/, -> { "foo.rb" }), - described_class.new(/.+_helper.rb/, -> { "bar.rb" }), + described_class.new(/.+_helper.rb/, -> { "bar.rb" }) ] end @@ -310,14 +312,14 @@ def matched(files) let(:match) { instance_double(described_class::Pattern::MatchResult) } before do - allow(described_class::Pattern).to receive(:create).with(pattern). - and_return(matcher) + allow(described_class::Pattern).to receive(:create).with(pattern) + .and_return(matcher) - allow(matcher).to receive(:match).with(pattern). - and_return(match_data) + allow(matcher).to receive(:match).with(pattern) + .and_return(match_data) - allow(described_class::Pattern::MatchResult).to receive(:new). - with(match_data, file).and_return(match) + allow(described_class::Pattern::MatchResult).to receive(:new) + .with(match_data, file).and_return(match) end context "with a valid pattern" do diff --git a/spec/lib/guard_spec.rb b/spec/lib/guard_spec.rb index e3f31bccb..79ded1c71 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "guard" RSpec.describe Guard do @@ -76,8 +78,8 @@ end it "initializes the listener" do - allow(Listen).to receive(:to). - with("/foo", latency: 2, wait_for_delay: 1).and_return(listener) + allow(Listen).to receive(:to) + .with("/foo", latency: 2, wait_for_delay: 1).and_return(listener) allow(session).to receive(:listener_args).and_return( [:to, "/foo", { latency: 2, wait_for_delay: 1 }] @@ -97,15 +99,15 @@ it "sets up USR1 trap for pausing" do expect(traps).to receive(:handle).with("USR1") { |_, &b| b.call } - expect(Guard).to receive(:async_queue_add). - with([:guard_pause, :paused]) + expect(Guard).to receive(:async_queue_add) + .with(%i[guard_pause paused]) subject end it "sets up USR2 trap for unpausing" do expect(traps).to receive(:handle).with("USR2") { |_, &b| b.call } - expect(Guard).to receive(:async_queue_add). - with([:guard_pause, :unpaused]) + expect(Guard).to receive(:async_queue_add) + .with(%i[guard_pause unpaused]) subject end @@ -130,8 +132,8 @@ before do allow(evaluator).to receive(:evaluate) do allow(session).to receive(:guardfile_ignore).and_return([/foo/]) - allow(session).to receive(:guardfile_ignore_bang). - and_return([/bar/]) + allow(session).to receive(:guardfile_ignore_bang) + .and_return([/bar/]) end Guard.setup(options) end @@ -148,8 +150,8 @@ end it "displays an error message when no guard are defined in Guardfile" do - expect(Guard::UI).to receive(:error). - with("No plugins found in Guardfile, please add at least one.") + expect(Guard::UI).to receive(:error) + .with("No plugins found in Guardfile, please add at least one.") subject end @@ -160,7 +162,7 @@ end context "with the group option" do - let(:options) { { group: %w(frontend backend) } } + let(:options) { { group: %w[frontend backend] } } it "passes options to session" do expect(Guard::Internals::State).to receive(:new).with(options) subject @@ -168,7 +170,7 @@ end context "with the plugin option" do - let(:options) { { plugin: %w(cucumber jasmine) } } + let(:options) { { plugin: %w[cucumber jasmine] } } it "passes options to session" do expect(Guard::Internals::State).to receive(:new).with(options) subject @@ -233,8 +235,8 @@ let(:pathname) { instance_double(Pathname) } before do - allow_any_instance_of(Pathname).to receive(:relative_path_from). - with(pwd).and_raise(ArgumentError) + allow_any_instance_of(Pathname).to receive(:relative_path_from) + .with(pwd).and_raise(ArgumentError) end it { is_expected.to eq(Pathname.new("d:/project/foo")) } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2c0bf7818..2eed73d15 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -23,7 +25,7 @@ ENV["GUARD_SPECS_RUNNING"] = "1" -path = "#{File.expand_path('..', __FILE__)}/support/**/*.rb" +path = "#{File.expand_path(__dir__)}/support/**/*.rb" Dir[path].each { |f| require f } # TODO: these shouldn't be necessary with proper specs @@ -53,8 +55,8 @@ def stub_mod(mod, excluded) inst = instance_double(klass) allow(klass).to receive(:new).and_return(inst) # TODO: use object_double? - class_double(klass.to_s). - as_stubbed_const(transfer_nested_constants: true) + class_double(klass.to_s) + .as_stubbed_const(transfer_nested_constants: true) end end elsif klass.is_a?(Module) @@ -231,21 +233,21 @@ def stub_file(path, contents = nil, &block) allow(ENV).to receive(:[]).with("THOR_SHELL").and_call_original allow(ENV).to receive(:[]).with("GEM_SKIP").and_call_original - %w(read write exist?).each do |meth| + %w[read write exist?].each do |meth| allow(File).to receive(meth.to_sym).with(anything) do |*args, &_block| abort "stub me! (File.#{meth}(#{args.map(&:inspect).join(', ')}))" end end - %w(read write binwrite binread).each do |meth| + %w[read write binwrite binread].each do |meth| allow(IO).to receive(meth.to_sym).with(anything) do |*args, &_block| abort "stub me! (IO.#{meth}(#{args.map(&:inspect).join(', ')}))" end end - %w(exist?).each do |meth| - allow_any_instance_of(Pathname). - to receive(meth.to_sym) do |*args, &_block| + %w[exist?].each do |meth| + allow_any_instance_of(Pathname) + .to receive(meth.to_sym) do |*args, &_block| obj = args.first formatted_args = args[1..-1].map(&:inspect).join(", ") abort "stub me! (#{obj.inspect}##{meth}(#{formatted_args}))" diff --git a/spec/support/gems_helper.rb b/spec/support/gems_helper.rb index ee0d6a250..e196f0b84 100644 --- a/spec/support/gems_helper.rb +++ b/spec/support/gems_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + def growl_installed? require "growl" true diff --git a/spec/support/platform_helper.rb b/spec/support/platform_helper.rb index 9a63849fd..8acad17ca 100644 --- a/spec/support/platform_helper.rb +++ b/spec/support/platform_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + def mac? RbConfig::CONFIG["target_os"] =~ /darwin/i end diff --git a/vendor/hound/config/style_guides/ruby.yml b/vendor/hound/config/style_guides/ruby.yml index eb375237f..1bcc78557 100644 --- a/vendor/hound/config/style_guides/ruby.yml +++ b/vendor/hound/config/style_guides/ruby.yml @@ -13,15 +13,15 @@ Style/CollectionMethods: find: detect find_all: select reduce: inject -Style/DotPosition: +Layout/DotPosition: Description: Checks the position of the dot in multi-line method calls. StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains Enabled: true - EnforcedStyle: trailing + EnforcedStyle: leading SupportedStyles: - leading - trailing -Style/FileName: +Naming/FileName: Description: Use snake_case for source file names. StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files Enabled: false @@ -35,7 +35,6 @@ Style/IfUnlessModifier: Description: Favor modifier if/unless usage when you have a single-line body. StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier Enabled: false - MaxLineLength: 80 Style/OptionHash: Description: Don't use option hashes when you can use keyword arguments. Enabled: false @@ -53,7 +52,7 @@ Style/PercentLiteralDelimiters: "%w": "()" "%W": "()" "%x": "()" -Style/PredicateName: +Naming/PredicateName: Description: Check the names of predicate methods. StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark Enabled: true @@ -119,19 +118,28 @@ Style/TrailingCommaInArguments: StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' Enabled: false EnforcedStyleForMultiline: no_comma - SupportedStyles: - - comma - - consistent_comma - - no_comma -Style/TrailingCommaInLiteral: - Description: 'Checks for trailing comma in array and hash literals.' + # SupportedStyles: + # - comma + # - consistent_comma + # - no_comma +Style/TrailingCommaInHashLiteral: + Description: 'Checks for trailing comma in hash literals.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' Enabled: false EnforcedStyleForMultiline: no_comma - SupportedStyles: - - comma - - consistent_comma - - no_comma + # SupportedStyles: + # - comma + # - consistent_comma + # - no_comma +Style/TrailingCommaInArrayLiteral: + Description: 'Checks for trailing comma in array literals.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' + Enabled: false + EnforcedStyleForMultiline: no_comma + # SupportedStyles: + # - comma + # - consistent_comma + # - no_comma Metrics/AbcSize: Description: A calculated magnitude based on number of assignments, branches, and conditions. @@ -147,11 +155,31 @@ Metrics/ModuleLength: Max: 100 Description: Avoid modules longer than 100 lines of code. Enabled: false +Metrics/BlockLength: + Exclude: + - spec/**/*.rb Metrics/CyclomaticComplexity: Description: A complexity metric that is strongly correlated to the number of test cases needed to validate a method. Enabled: false Max: 6 +Metrics/LineLength: + Enabled: true + Max: 125 + # To make it possible to copy or click on URIs in the code, we allow lines + # containing a URI to be longer than Max. + AllowHeredoc: true + AllowURI: true + URISchemes: + - http + - https + # The IgnoreCopDirectives option causes the LineLength rule to ignore cop + # directives like '# rubocop: enable ...' when calculating a line's length. + IgnoreCopDirectives: false + # The IgnoredPatterns option is a list of !ruby/regexp and/or string + # elements. Strings will be converted to Regexp objects. A line that matches + # any regular expression listed in this option will be ignored by LineLength. + IgnoredPatterns: [] Metrics/MethodLength: Description: Avoid methods longer than 10 lines of code. StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods @@ -177,7 +205,7 @@ Lint/AssignmentInCondition: Style/InlineComment: Description: Avoid inline comments. Enabled: false -Style/AccessorMethodName: +Naming/AccessorMethodName: Description: Check the naming of accessor methods for get_/set_. Enabled: false Style/Alias: @@ -235,7 +263,7 @@ Lint/HandleExceptions: Description: Don't suppress exception. StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions Enabled: false -Lint/LiteralInCondition: +Lint/LiteralAsCondition: Description: Checks of literals used in conditions. Enabled: false Lint/LiteralInInterpolation: