From 52c64a57115c5983bc97b104e0233e4165f5a6c5 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 07:48:30 +0200 Subject: [PATCH 01/30] Settings: Update rubocop and settings Update rubocop to match hound Adapt hound style to new rubocop version Add style config file for specs Exclude vendor/**/* Default for rubocop is to overwrite arrays. This happens here and leads to uncomfortable usage of rubocop locally. Update target version to minimum supported version Autoupdate rubocop settings using mry --- .rubocop.yml | 3 ++- .rubocop_todo.yml | 4 ++-- Gemfile | 2 +- spec/.rubocop.yml | 2 ++ vendor/hound/config/style_guides/ruby.yml | 26 ++++++++++++++++------- 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 spec/.rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml index 4e59ead68..6abd7d2d5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,8 +4,9 @@ inherit_from: # Files you want to exclude AllCops: - TargetRubyVersion: 2.2 + TargetRubyVersion: 2.3 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..2c6014e03 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ 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 diff --git a/spec/.rubocop.yml b/spec/.rubocop.yml new file mode 100644 index 000000000..d4809fc42 --- /dev/null +++ b/spec/.rubocop.yml @@ -0,0 +1,2 @@ +Metrics/BlockLength: + Max: 50 diff --git a/vendor/hound/config/style_guides/ruby.yml b/vendor/hound/config/style_guides/ruby.yml index eb375237f..fdb129c8e 100644 --- a/vendor/hound/config/style_guides/ruby.yml +++ b/vendor/hound/config/style_guides/ruby.yml @@ -13,7 +13,7 @@ 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 @@ -21,7 +21,7 @@ Style/DotPosition: 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 @@ -123,8 +122,17 @@ Style/TrailingCommaInArguments: - comma - consistent_comma - no_comma -Style/TrailingCommaInLiteral: - Description: 'Checks for trailing comma in array and hash literals.' +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 +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 @@ -152,6 +160,8 @@ Metrics/CyclomaticComplexity: cases needed to validate a method. Enabled: false Max: 6 +Metrics/LineLength: + Max: 80 Metrics/MethodLength: Description: Avoid methods longer than 10 lines of code. StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods @@ -177,7 +187,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 +245,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: From e0eefa7a521294c8835c1f733a49c7f8fb178522 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 08:48:03 +0200 Subject: [PATCH 02/30] Auto correct: Style/StringLiterals in spec --- spec/lib/guard/bin_spec.rb | 66 ++-- .../guard/cli/environments/bundler_spec.rb | 42 +-- .../cli/environments/evaluate_only_spec.rb | 26 +- spec/lib/guard/cli/environments/valid_spec.rb | 106 +++--- spec/lib/guard/cli_spec.rb | 56 ++-- spec/lib/guard/commander_spec.rb | 120 +++---- spec/lib/guard/commands/all_spec.rb | 46 +-- spec/lib/guard/commands/change_spec.rb | 24 +- spec/lib/guard/commands/notification_spec.rb | 6 +- spec/lib/guard/commands/pause_spec.rb | 6 +- spec/lib/guard/commands/reload_spec.rb | 44 +-- spec/lib/guard/commands/scope_spec.rb | 48 +-- spec/lib/guard/commands/show_spec.rb | 8 +- spec/lib/guard/config_spec.rb | 4 +- spec/lib/guard/deprecated/dsl_spec.rb | 26 +- spec/lib/guard/deprecated/evaluator_spec.rb | 18 +- spec/lib/guard/deprecated/guard_spec.rb | 192 +++++------ spec/lib/guard/deprecated/guardfile_spec.rb | 38 +-- spec/lib/guard/deprecated/watcher_spec.rb | 22 +- spec/lib/guard/dsl_describer_spec.rb | 68 ++-- spec/lib/guard/dsl_reader_spec.rb | 36 +- spec/lib/guard/dsl_spec.rb | 312 +++++++++--------- spec/lib/guard/group_spec.rb | 20 +- spec/lib/guard/guardfile/evaluator_spec.rb | 124 +++---- spec/lib/guard/guardfile/generator_spec.rb | 58 ++-- spec/lib/guard/interactor_spec.rb | 84 ++--- spec/lib/guard/internals/debugging_spec.rb | 58 ++-- spec/lib/guard/internals/groups_spec.rb | 78 ++--- spec/lib/guard/internals/plugins_spec.rb | 98 +++--- spec/lib/guard/internals/scope_spec.rb | 60 ++-- spec/lib/guard/internals/session_spec.rb | 174 +++++----- spec/lib/guard/internals/state_spec.rb | 22 +- spec/lib/guard/internals/tracing_spec.rb | 52 +-- spec/lib/guard/internals/traps_spec.rb | 22 +- spec/lib/guard/jobs/pry_wrapper_spec.rb | 66 ++-- spec/lib/guard/jobs/sleep_spec.rb | 20 +- spec/lib/guard/notifier_spec.rb | 42 +-- spec/lib/guard/options_spec.rb | 30 +- spec/lib/guard/plugin_spec.rb | 122 +++---- spec/lib/guard/plugin_util_spec.rb | 182 +++++----- spec/lib/guard/runner_spec.rb | 176 +++++----- spec/lib/guard/terminal_spec.rb | 36 +- spec/lib/guard/ui/config_spec.rb | 50 +-- spec/lib/guard/ui/logger_spec.rb | 14 +- spec/lib/guard/ui_spec.rb | 190 +++++------ .../watcher/pattern/deprecated_regexp_spec.rb | 16 +- .../watcher/pattern/match_result_spec.rb | 38 +-- .../lib/guard/watcher/pattern/matcher_spec.rb | 68 ++-- .../watcher/pattern/pathname_path_spec.rb | 32 +- .../guard/watcher/pattern/simple_path_spec.rb | 32 +- spec/lib/guard/watcher/pattern_spec.rb | 22 +- spec/lib/guard/watcher_spec.rb | 240 +++++++------- spec/lib/guard_spec.rb | 112 +++---- spec/spec_helper.rb | 44 +-- spec/support/gems_helper.rb | 6 +- spec/support/platform_helper.rb | 6 +- 56 files changed, 1854 insertions(+), 1854 deletions(-) diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index 6a3b71662..26b5a5fcb 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -1,4 +1,4 @@ -path = File.expand_path("../../../../bin/guard", __FILE__) +path = File.expand_path('../../../../bin/guard', __FILE__) load path RSpec.describe GuardReloader do @@ -6,7 +6,7 @@ subject { described_class.new(config) } - let(:guard_core_path) { "/home/me/.rvm/gems/ruby-2.2.2/bin/_guard-core" } + let(:guard_core_path) { '/home/me/.rvm/gems/ruby-2.2.2/bin/_guard-core' } before do allow(described_class::Config).to receive(:new).and_return(config) @@ -22,111 +22,111 @@ allow(config).to receive(:program_path).and_return(program_path) end - let(:program_path) { Pathname("/home/me/.rvm/gems/ruby-2.2.2/bin/guard") } + let(:program_path) { Pathname('/home/me/.rvm/gems/ruby-2.2.2/bin/guard') } let(:rubygems_deps_env) { nil } # or any gemfile path - context "when running with bundler" do - let(:bundle_gemfile_env) { "./Gemfile" } + context 'when running with bundler' do + let(:bundle_gemfile_env) { './Gemfile' } - it "sets up bundler" do + it 'sets up bundler' do expect(config).to receive(:setup_bundler) subject.setup end end - context "when not running with bundler" do + context 'when not running with bundler' do let(:bundle_gemfile_env) { nil } - context "when running with rubygems_gemdeps" do - let(:rubygems_deps_env) { "-" } # or any gemfile path + context 'when running with rubygems_gemdeps' do + let(:rubygems_deps_env) { '-' } # or any gemfile path - it "sets up rubygems" do + it 'sets up rubygems' do expect(config).to receive(:setup_rubygems_for_deps) subject.setup end end - context "when not running with rubygems_gemdeps" do + context 'when not running with rubygems_gemdeps' do let(:rubygems_deps_env) { nil } - context "when running as binstub" do - let(:program_path) { Pathname("/my/project/bin/guard") } + context 'when running as binstub' do + let(:program_path) { Pathname('/my/project/bin/guard') } - context "when the relative Gemfile exists" do + context 'when the relative Gemfile exists' do before do allow(config).to receive(:exist?). - with(Pathname("/my/project/Gemfile")).and_return(true) + with(Pathname('/my/project/Gemfile')).and_return(true) allow(config).to receive(:setup_bundler) allow(config).to receive(:setup_bundler_env) end - it "sets up bundler" do + it 'sets up bundler' do expect(config).to receive(:setup_bundler) subject.setup end - it "sets the Gemfile" do + it 'sets the Gemfile' do expect(config).to receive(:setup_bundler_env). - with("/my/project/Gemfile") + with('/my/project/Gemfile') subject.setup end end - context "when the relative Gemfile does not exist" do + context 'when the relative Gemfile does not exist' do before do allow(config).to receive(:exist?). - with(Pathname("/my/project/Gemfile")).and_return(false) + with(Pathname('/my/project/Gemfile')).and_return(false) - allow(config).to receive(:exist?).with(Pathname("Gemfile")). + allow(config).to receive(:exist?).with(Pathname('Gemfile')). and_return(false) end - it "does not setup bundler" do + it 'does not setup bundler' do subject.setup end - it "does not setup rubygems" do + it 'does not setup rubygems' do subject.setup end - it "shows no warning" do + it 'shows no warning' do expect(STDERR).to_not receive(:puts) subject.setup end end end - context "when not run as binstub" do + context 'when not run as binstub' do let(:program_path) do - Pathname("/home/me/.rvm/gems/ruby-2.2.2/bin/guard") + Pathname('/home/me/.rvm/gems/ruby-2.2.2/bin/guard') end before do allow(config).to receive(:exist?).with( - Pathname("/home/me/.rvm/gems/ruby-2.2.2/Gemfile") + Pathname('/home/me/.rvm/gems/ruby-2.2.2/Gemfile') ).and_return(false) end - context "when Gemfile exists" do + context 'when Gemfile exists' do before do - allow(config).to receive(:exist?).with(Pathname("Gemfile")). + allow(config).to receive(:exist?).with(Pathname('Gemfile')). and_return(true) end - it "shows a warning" do + it 'shows a warning' do expect(STDERR).to receive(:puts).with(/Warning: you have a Gemfile/) subject.setup end end - context "when no Gemfile exists" do + context 'when no Gemfile exists' do before do - allow(config).to receive(:exist?).with(Pathname("Gemfile")). + allow(config).to receive(:exist?).with(Pathname('Gemfile')). and_return(false) end - it "shows no warning" do + it 'shows no warning' do expect(STDERR).to_not receive(:puts) subject.setup end diff --git a/spec/lib/guard/cli/environments/bundler_spec.rb b/spec/lib/guard/cli/environments/bundler_spec.rb index 1151ca0c5..81aff1c9f 100644 --- a/spec/lib/guard/cli/environments/bundler_spec.rb +++ b/spec/lib/guard/cli/environments/bundler_spec.rb @@ -1,58 +1,58 @@ -require "guard/cli/environments/bundler" +require 'guard/cli/environments/bundler' # TODO: instead of shared examples, use have_received if possible -RSpec.shared_examples "avoids Bundler warning" do - it "does not show the Bundler warning" do +RSpec.shared_examples 'avoids Bundler warning' do + it 'does not show the Bundler warning' do expect(Guard::UI).to_not have_received(:info).with(/Guard here!/) end end -RSpec.shared_examples "shows Bundler warning" do - it "shows the Bundler warning" do +RSpec.shared_examples 'shows Bundler warning' do + it 'shows the Bundler warning' do expect(Guard::UI).to have_received(:info).with(/Guard here!/) end end RSpec.describe Guard::Cli::Environments::Bundler do - describe "#verify" do + describe '#verify' do let(:gemdeps) { nil } let(:gemfile) { nil } before do - allow(ENV).to receive(:[]).with("BUNDLE_GEMFILE").and_return(gemfile) - allow(ENV).to receive(:[]).with("RUBYGEMS_GEMDEPS").and_return(gemdeps) + 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"). + allow(File).to receive(:exist?).with('Gemfile'). and_return(gemfile_present) subject.verify end - context "without an existing Gemfile" do + context 'without an existing Gemfile' do let(:gemfile_present) { false } - include_examples "avoids Bundler warning" + include_examples 'avoids Bundler warning' end - context "with an existing Gemfile" do + context 'with an existing Gemfile' do let(:gemfile_present) { true } - context "with Bundler" do + context 'with Bundler' do let(:gemdeps) { nil } - let(:gemfile) { "Gemfile" } - include_examples "avoids Bundler warning" + let(:gemfile) { 'Gemfile' } + include_examples 'avoids Bundler warning' end - context "without Bundler" do + context 'without Bundler' do let(:gemfile) { nil } - context "with Rubygems Gemfile autodetection or custom Gemfile" do - let(:gemdeps) { "-" } - include_examples "avoids Bundler warning" + context 'with Rubygems Gemfile autodetection or custom Gemfile' do + let(:gemdeps) { '-' } + include_examples 'avoids Bundler warning' end - context "without Rubygems Gemfile handling" do + context 'without Rubygems Gemfile handling' do let(:gemdeps) { nil } - include_examples "shows Bundler warning" + include_examples 'shows Bundler warning' end end 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..cc8f7acbe 100644 --- a/spec/lib/guard/cli/environments/evaluate_only_spec.rb +++ b/spec/lib/guard/cli/environments/evaluate_only_spec.rb @@ -1,13 +1,13 @@ -require "guard/cli/environments/evaluate_only" +require 'guard/cli/environments/evaluate_only' RSpec.describe Guard::Cli::Environments::EvaluateOnly do subject { described_class.new(options) } - let(:options) { double("options") } + let(:options) { double('options') } - describe "#evaluate" do - let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } - let(:state) { instance_double("Guard::Internals::State") } - let(:session) { instance_double("Guard::Internals::Session") } + describe '#evaluate' do + let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } + let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double('Guard::Internals::Session') } before do allow(Guard::Guardfile::Evaluator).to receive(:new).and_return(evaluator) @@ -18,23 +18,23 @@ allow(session).to receive(:evaluator_options) end - it "calls Guard.init" do + it 'calls Guard.init' do expect(Guard).to receive(:init) subject.evaluate end - it "initializes Guard with options" do + it 'initializes Guard with options' do expect(Guard).to receive(:init).with(options) subject.evaluate end - it "evaluates the guardfile" do + it 'evaluates the guardfile' do expect(evaluator).to receive(:evaluate) subject.evaluate end - it "passes options to evaluator" do - evaluator_options = double("evaluator_options") + it 'passes options to evaluator' do + evaluator_options = double('evaluator_options') allow(session).to receive(:evaluator_options). and_return(evaluator_options) @@ -56,11 +56,11 @@ and_raise(error_class, "#{error_class} error!") end - it "aborts" do + it 'aborts' do expect { subject.evaluate }.to raise_error(SystemExit) end - it "shows error message" do + it 'shows error message' do expect(Guard::UI).to receive(:error).with(/#{error_class} error!/) begin subject.evaluate diff --git a/spec/lib/guard/cli/environments/valid_spec.rb b/spec/lib/guard/cli/environments/valid_spec.rb index 4846ca8c5..34a09309e 100644 --- a/spec/lib/guard/cli/environments/valid_spec.rb +++ b/spec/lib/guard/cli/environments/valid_spec.rb @@ -1,17 +1,17 @@ -require "guard/cli/environments/valid" -require "guard/cli/environments/bundler" +require 'guard/cli/environments/valid' +require 'guard/cli/environments/bundler' RSpec.describe Guard::Cli::Environments::Valid do subject { described_class.new(options) } - let(:options) { double("options") } + let(:options) { double('options') } before do # TODO: start should be an instance method of something allow(Guard).to receive(:start) end - describe "#start_guard" do - let(:bundler) { instance_double("Guard::Cli::Environments::Bundler") } + describe '#start_guard' do + let(:bundler) { instance_double('Guard::Cli::Environments::Bundler') } before do allow(Guard::Cli::Environments::Bundler).to receive(:new). @@ -20,7 +20,7 @@ allow(bundler).to receive(:verify) end - context "with a valid bundler setup" do + context 'with a valid bundler setup' do before do allow(bundler).to receive(:verify) @@ -28,18 +28,18 @@ and_return(false) end - it "starts guard" do + it 'starts guard' do expect(Guard).to receive(:start) subject.start_guard end - it "start guard with options" do + it 'start guard with options' do expect(Guard).to receive(:start).with(options) subject.start_guard end - it "returns exit code" do - exitcode = double("exitcode") + it 'returns exit code' do + exitcode = double('exitcode') expect(Guard).to receive(:start).and_return(exitcode) expect(subject.start_guard).to be(exitcode) end @@ -56,11 +56,11 @@ and_raise(error_class, "#{error_class} error!") end - it "aborts" do + it 'aborts' do expect { subject.start_guard }.to raise_error(SystemExit) end - it "shows error message" do + it 'shows error message' do expect(Guard::UI).to receive(:error).with(/#{error_class} error!/) begin subject.start_guard @@ -71,20 +71,20 @@ end end - context "without no_bundler_warning option" do + context 'without no_bundler_warning option' do subject { described_class.new(no_bundler_warning: false) } - it "verifies bundler presence" do + it 'verifies bundler presence' do expect(bundler).to receive(:verify) subject.start_guard end - context "without a valid bundler setup" do + context 'without a valid bundler setup' do before do allow(bundler).to receive(:verify).and_raise(SystemExit) end - it "does not start guard" do + it 'does not start guard' do expect(Guard).to_not receive(:start) begin @@ -95,42 +95,42 @@ end end - context "with no_bundler_warning option" do + context 'with no_bundler_warning option' do subject { described_class.new(no_bundler_warning: true) } - it "does not verify bundler presence" do + it 'does not verify bundler presence' do expect(bundler).to_not receive(:verify) subject.start_guard end - it "starts guard" do + it 'starts guard' do expect(Guard).to receive(:start) subject.start_guard end end - describe "return value" do - let(:exitcode) { double("Fixnum") } + describe 'return value' do + let(:exitcode) { double('Fixnum') } subject { described_class.new(no_bundler_warning: true) } before do allow(Guard).to receive(:start).and_return(exitcode) end - it "matches return value of Guard.start" do + it 'matches return value of Guard.start' do expect(subject.start_guard).to be(exitcode) end end end - describe "#initialize_guardfile" do - let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } - let(:generator) { instance_double("Guard::Guardfile::Generator") } - let(:state) { instance_double("Guard::Internals::State") } - let(:session) { instance_double("Guard::Internals::Session") } + describe '#initialize_guardfile' do + let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } + let(:generator) { instance_double('Guard::Guardfile::Generator') } + let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double('Guard::Internals::Session') } before do - stub_file("Gemfile") + stub_file('Gemfile') allow(evaluator).to receive(:evaluate) allow(generator).to receive(:create_guardfile) @@ -144,16 +144,16 @@ allow(Guard::Guardfile::Generator).to receive(:new).and_return(generator) end - context "with bare option" do + context 'with bare option' do before do expect(options).to receive(:[]).with(:bare).and_return(true) end - it "Only creates the Guardfile without initializing any Guard template" do + it 'Only creates the Guardfile without initializing any Guard template' do allow(evaluator).to receive(:evaluate). and_raise(Guard::Guardfile::Evaluator::NoGuardfileError) - allow(File).to receive(:exist?).with("Gemfile").and_return(false) + allow(File).to receive(:exist?).with('Gemfile').and_return(false) expect(generator).to receive(:create_guardfile) expect(generator).to_not receive(:initialize_template) expect(generator).to_not receive(:initialize_all_templates) @@ -161,23 +161,23 @@ subject.initialize_guardfile end - it "returns an exit code" do + it 'returns an exit code' do # TODO: ideally, we'd capture known exceptions and return nonzero expect(subject.initialize_guardfile).to be_zero end end - context "with no bare option" do + context 'with no bare option' do before do expect(options).to receive(:[]).with(:bare).and_return(false) end - it "evaluates created or existing guardfile" do + it 'evaluates created or existing guardfile' do expect(evaluator).to receive(:evaluate) subject.initialize_guardfile end - it "creates a Guardfile" do + it 'creates a Guardfile' do expect(evaluator).to receive(:evaluate). and_raise(Guard::Guardfile::Evaluator::NoGuardfileError).once expect(evaluator).to receive(:evaluate) @@ -189,58 +189,58 @@ subject.initialize_guardfile end - it "initializes templates of all installed Guards" do - allow(File).to receive(:exist?).with("Gemfile").and_return(false) + it 'initializes templates of all installed Guards' do + allow(File).to receive(:exist?).with('Gemfile').and_return(false) expect(generator).to receive(:initialize_all_templates) subject.initialize_guardfile end - it "initializes each passed template" do - allow(File).to receive(:exist?).with("Gemfile").and_return(false) + it 'initializes each passed template' do + allow(File).to receive(:exist?).with('Gemfile').and_return(false) - expect(generator).to receive(:initialize_template).with("rspec") - expect(generator).to receive(:initialize_template).with("pow") + expect(generator).to receive(:initialize_template).with('rspec') + expect(generator).to receive(:initialize_template).with('pow') subject.initialize_guardfile(%w(rspec pow)) end - context "when passed a guard name" do - context "when the Guardfile is empty" do + 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(generator).to receive(:initialize_template) end - it "works without without errors" do + it 'works without without errors' do expect(subject.initialize_guardfile(%w(rspec))).to be_zero end - it "adds the template" do - expect(generator).to receive(:initialize_template).with("rspec") + it 'adds the template' do + expect(generator).to receive(:initialize_template).with('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") + it 'initializes the template of the passed Guard' do + expect(generator).to receive(:initialize_template).with('rspec') subject.initialize_guardfile(%w(rspec)) end end - it "returns an exit code" do + it 'returns an exit code' do expect(subject.initialize_guardfile).to be_zero end - context "when passed an unknown guard name" do + 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 + it 'returns an exit code' do expect(::Guard::UI).to receive(:error).with( "Could not load 'guard/foo' or '~/.guard/templates/foo'"\ " or find class Guard::Foo\n" diff --git a/spec/lib/guard/cli_spec.rb b/spec/lib/guard/cli_spec.rb index 224950523..02520cd61 100644 --- a/spec/lib/guard/cli_spec.rb +++ b/spec/lib/guard/cli_spec.rb @@ -1,12 +1,12 @@ -require "guard/cli" +require 'guard/cli' RSpec.describe Guard::CLI do - let(:valid_environment) { instance_double("Guard::Cli::Environments::Valid") } + let(:valid_environment) { instance_double('Guard::Cli::Environments::Valid') } let(:bare_environment) do - instance_double("Guard::Cli::Environments::EvaluateOnly") + instance_double('Guard::Cli::Environments::EvaluateOnly') end - let(:dsl_describer) { instance_double("Guard::DslDescriber") } + let(:dsl_describer) { instance_double('Guard::DslDescriber') } before do @options = {} @@ -21,13 +21,13 @@ and_return(valid_environment) end - describe "#start" do + describe '#start' do before do allow(valid_environment).to receive(:start_guard).and_return(0) end - it "delegates to Guard::Environment.start" do - pending "needs JRuby support first" if defined?(JRUBY_VERSION) + it 'delegates to Guard::Environment.start' do + pending 'needs JRuby support first' if defined?(JRUBY_VERSION) expect(valid_environment).to receive(:start_guard).and_return(0) begin @@ -36,8 +36,8 @@ end end - it "exits with given exit code" do - pending "needs JRuby support first" if defined?(JRUBY_VERSION) + it 'exits with given exit code' do + pending 'needs JRuby support first' if defined?(JRUBY_VERSION) allow(valid_environment).to receive(:start_guard).and_return(4) expect { subject.start }.to raise_error(SystemExit) do |exception| @@ -46,8 +46,8 @@ end end - it "passes options" do - pending "needs JRuby support first" if defined?(JRUBY_VERSION) + 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) @@ -58,67 +58,67 @@ end end - describe "#list" do + describe '#list' do before do allow(bare_environment).to receive(:evaluate) allow(dsl_describer).to receive(:list) subject.list end - it "calls the evaluation" do + it 'calls the evaluation' do expect(bare_environment).to have_received(:evaluate) end - it "outputs the Guard plugins list" do + it 'outputs the Guard plugins list' do expect(dsl_describer).to have_received(:list) end end - describe "#notifiers" do + describe '#notifiers' do before do allow(bare_environment).to receive(:evaluate) allow(dsl_describer).to receive(:notifiers) subject.notifiers end - it "calls the evaluation" do + it 'calls the evaluation' do expect(bare_environment).to have_received(:evaluate) end - it "outputs the notifiers list" do + it 'outputs the notifiers list' do expect(dsl_describer).to have_received(:notifiers) end end - describe "#version" do - it "shows the current version" do + describe '#version' do + it 'shows the current version' do expect(STDOUT).to receive(:puts).with(/#{ ::Guard::VERSION }/) subject.version end end - describe "#init" do + describe '#init' do before do allow(Guard::Cli::Environments::Valid).to receive(:new). and_return(valid_environment) allow(valid_environment).to receive(:initialize_guardfile).and_return(0) end - it "delegates to Guard::Environment.start" do + it 'delegates to Guard::Environment.start' do begin subject.init rescue SystemExit end end - it "exits with given exit code" do + it 'exits with given exit code' do allow(valid_environment).to receive(:initialize_guardfile).and_return(4) expect { subject.init }.to raise_error(SystemExit) do |exception| expect(exception.status).to eq(4) end end - it "passes options" do + it 'passes options' do expect(Guard::Cli::Environments::Valid).to receive(:new).with(@options). and_return(valid_environment) begin @@ -127,8 +127,8 @@ end end - it "passes plugin names" do - plugins = [double("plugin1"), double("plugin2")] + it 'passes plugin names' do + plugins = [double('plugin1'), double('plugin2')] expect(valid_environment).to receive(:initialize_guardfile).with(plugins) begin subject.init(*plugins) @@ -137,18 +137,18 @@ end end - describe "#show" do + describe '#show' do before do allow(bare_environment).to receive(:evaluate) allow(dsl_describer).to receive(:show) subject.show end - it "calls the evaluation" do + it 'calls the evaluation' do expect(bare_environment).to have_received(:evaluate) end - it "outputs the Guard::DslDescriber.list result" do + it 'outputs the Guard::DslDescriber.list result' do expect(dsl_describer).to have_received(:show) end end diff --git a/spec/lib/guard/commander_spec.rb b/spec/lib/guard/commander_spec.rb index 730f6306d..bc5b86e54 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -1,14 +1,14 @@ -require "guard/commander" +require 'guard/commander' RSpec.describe Guard::Commander do subject { Guard } - let(:interactor) { instance_double("Guard::Interactor") } - let(:runner) { instance_double("Guard::Runner", run: true) } + let(:interactor) { instance_double('Guard::Interactor') } + let(:runner) { instance_double('Guard::Runner', run: true) } - let(:scope) { instance_double("Guard::Internals::Scope") } - let(:state) { instance_double("Guard::Internals::State") } - let(:session) { instance_double("Guard::Internals::Session") } + let(:scope) { instance_double('Guard::Internals::Scope') } + let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double('Guard::Internals::Session') } before do allow(state).to receive(:scope).and_return(scope) @@ -19,15 +19,15 @@ allow(Guard::Runner).to receive(:new).and_return(runner) end - describe ".start" do + describe '.start' do let(:listener) do - instance_double("Listen::Listener", start: true, stop: true) + instance_double('Listen::Listener', start: true, stop: true) end let(:watched_dir) { Dir.pwd } before do - stub_guardfile(" ") + stub_guardfile(' ') stub_user_guard_rb # from stop() @@ -43,48 +43,48 @@ allow(Guard::Notifier).to receive(:disconnect) end - it "calls Guard setup" do - expect(Guard).to receive(:setup).with(foo: "bar") - Guard.start(foo: "bar") + it 'calls Guard setup' do + expect(Guard).to receive(:setup).with(foo: 'bar') + Guard.start(foo: 'bar') end - it "displays an info message" do + it 'displays an info message' do expect(Guard::UI).to receive(:info). with("Guard is now watching at 'dir1', 'dir2'") Guard.start end - it "tell the runner to run the :start task" do + it 'tell the runner to run the :start task' do expect(runner).to receive(:run).with(:start) allow(listener).to receive(:stop) Guard.start end - it "start the listener" do + it 'start the listener' do expect(listener).to receive(:start) Guard.start end - context "when finished" do - it "stops everything" do + context 'when finished' do + it 'stops everything' do expect(interactor).to receive(:foreground).and_return(:exit) # From stop() expect(interactor).to receive(:background) expect(listener).to receive(:stop) expect(runner).to receive(:run).with(:stop) - expect(Guard::UI).to receive(:info).with("Bye bye...", reset: true) + expect(Guard::UI).to receive(:info).with('Bye bye...', reset: true) Guard.start end end end - describe ".stop" do - let(:runner) { instance_double("Guard::Runner", run: true) } - let(:listener) { instance_double("Listen::Listener", stop: true) } + describe '.stop' do + let(:runner) { instance_double('Guard::Runner', run: true) } + let(:listener) { instance_double('Listen::Listener', stop: true) } before do allow(Guard::Notifier).to receive(:disconnect) @@ -96,52 +96,52 @@ Guard.stop end - it "turns off the interactor" do + it 'turns off the interactor' do expect(interactor).to have_received(:background) end - it "turns the notifier off" do + it 'turns the notifier off' do expect(Guard::Notifier).to have_received(:disconnect) end - it "tell the runner to run the :stop task" do + it 'tell the runner to run the :stop task' do expect(runner).to have_received(:run).with(:stop) end - it "stops the listener" do + it 'stops the listener' do expect(listener).to have_received(:stop) end end - describe ".reload" do - let(:runner) { instance_double("Guard::Runner", run: true) } - let(:group) { instance_double("Guard::Group", name: "frontend") } + describe '.reload' do + let(:runner) { instance_double('Guard::Runner', run: true) } + let(:group) { instance_double('Guard::Group', name: 'frontend') } before do allow(Guard::Notifier).to receive(:connect) allow(Guard::UI).to receive(:info) allow(Guard::UI).to receive(:clear) - allow(scope).to receive(:titles).and_return(["all"]) + allow(scope).to receive(:titles).and_return(['all']) - stub_guardfile(" ") + stub_guardfile(' ') stub_user_guard_rb end - it "clears the screen" do + it 'clears the screen' do expect(Guard::UI).to receive(:clear) Guard.reload end - it "reloads Guard" do + it 'reloads Guard' do expect(runner).to receive(:run).with(:reload, groups: [group]) Guard.reload(groups: [group]) end end - describe ".run_all" do - let(:group) { instance_double("Guard::Group", name: "frontend") } + describe '.run_all' do + let(:group) { instance_double('Guard::Group', name: 'frontend') } before do allow(::Guard::Notifier).to receive(:connect) @@ -149,16 +149,16 @@ allow(::Guard::UI).to receive(:clear) end - context "with a given scope" do - it "runs all with the scope" do + context 'with a given scope' do + it 'runs all with the scope' do expect(runner).to receive(:run).with(:run_all, groups: [group]) subject.run_all(groups: [group]) end end - context "with an empty scope" do - it "runs all" do + context 'with an empty scope' do + it 'runs all' do expect(runner).to receive(:run).with(:run_all, {}) subject.run_all @@ -166,9 +166,9 @@ end end - describe ".pause" do - context "when unpaused" do - let(:listener) { instance_double("Listen::Listener") } + describe '.pause' do + context 'when unpaused' do + let(:listener) { instance_double('Listen::Listener') } before do allow(::Guard::Notifier).to receive(:connect) @@ -182,12 +182,12 @@ allow(listener).to receive(:pause) end - it "pauses" do + it 'pauses' do expect(listener).to receive(:pause) Guard.pause(mode) end - it "shows a message" do + it 'shows a message' do expected = /File event handling has been paused/ expect(Guard::UI).to receive(:info).with(expected) Guard.pause(mode) @@ -195,24 +195,24 @@ end end - context "with :unpaused" do - it "does nothing" do + context 'with :unpaused' do + it 'does nothing' do expect(listener).to_not receive(:start) expect(listener).to_not receive(:pause) Guard.pause(:unpaused) end end - context "with invalid parameter" do - it "raises an ArgumentError" do + context 'with invalid parameter' do + it 'raises an ArgumentError' do expect { Guard.pause(:invalid) }. - to raise_error(ArgumentError, "invalid mode: :invalid") + to raise_error(ArgumentError, 'invalid mode: :invalid') end end end - context "when already paused" do - let(:listener) { instance_double("Listen::Listener") } + context 'when already paused' do + let(:listener) { instance_double('Listen::Listener') } before do allow(::Guard::Notifier).to receive(:connect) @@ -226,12 +226,12 @@ allow(listener).to receive(:start) end - it "unpauses" do + it 'unpauses' do expect(listener).to receive(:start) Guard.pause(mode) end - it "shows a message" do + it 'shows a message' do expected = /File event handling has been resumed/ expect(Guard::UI).to receive(:info).with(expected) Guard.pause(mode) @@ -239,32 +239,32 @@ end end - context "with :paused" do - it "does nothing" do + context 'with :paused' do + it 'does nothing' do expect(listener).to_not receive(:start) expect(listener).to_not receive(:pause) Guard.pause(:paused) end end - context "with invalid parameter" do - it "raises an ArgumentError" do + context 'with invalid parameter' do + it 'raises an ArgumentError' do expect { Guard.pause(:invalid) }. - to raise_error(ArgumentError, "invalid mode: :invalid") + to raise_error(ArgumentError, 'invalid mode: :invalid') end end end end - describe ".show" do - let(:dsl_describer) { instance_double("Guard::DslDescriber") } + describe '.show' do + let(:dsl_describer) { instance_double('Guard::DslDescriber') } before do allow(Guard::DslDescriber).to receive(:new).with(no_args). and_return(dsl_describer) end - it "shows list of plugins" do + it 'shows list of plugins' do expect(dsl_describer).to receive(:show) Guard.show end diff --git a/spec/lib/guard/commands/all_spec.rb b/spec/lib/guard/commands/all_spec.rb index ecd438431..f6b4868a6 100644 --- a/spec/lib/guard/commands/all_spec.rb +++ b/spec/lib/guard/commands/all_spec.rb @@ -1,17 +1,17 @@ -require "guard/plugin" +require 'guard/plugin' -require "guard/commands/all" +require 'guard/commands/all' -require "guard/internals/session" -require "guard/internals/state" +require 'guard/internals/session' +require 'guard/internals/state' RSpec.describe Guard::Commands::All do let(:foo_group) { instance_double(Guard::Group) } let(:bar_guard) { instance_double(Guard::Plugin) } let(:output) { instance_double(Pry::Output) } - let(:state) { instance_double("Guard::Internals::State") } - let(:session) { instance_double("Guard::Internals::Session") } + let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double('Guard::Internals::Session') } class FakePry < Pry::Command def self.output @@ -26,18 +26,18 @@ def self.output allow(Guard).to receive(:state).and_return(state) allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with("all") do |&block| + allow(Pry::Commands).to receive(:create_command).with('all') do |&block| FakePry.instance_eval(&block) end described_class.import end - context "without scope" do + context 'without scope' do let(:given_scope) { [] } let(:converted_scope) { [{ groups: [], plugins: [] }, []] } - it "runs the :run_all action" do + it 'runs the :run_all action' do expect(Guard).to receive(:async_queue_add). with([:guard_run_all, groups: [], plugins: []]) @@ -45,39 +45,39 @@ def self.output end end - context "with a valid Guard group scope" do - let(:given_scope) { ["foo"] } + context 'with a valid Guard group scope' do + let(:given_scope) { ['foo'] } let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } - it "runs the :run_all action with the given scope" do + 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: []]) - FakePry.process("foo") + FakePry.process('foo') end end - context "with a valid Guard plugin scope" do - let(:given_scope) { ["bar"] } + context 'with a valid Guard plugin scope' do + let(:given_scope) { ['bar'] } let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } - it "runs the :run_all action with the given scope" do + 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: []]) - FakePry.process("bar") + FakePry.process('bar') end end - context "with an invalid scope" do - let(:given_scope) { ["baz"] } - let(:converted_scope) { [{ groups: [], plugins: [] }, ["baz"]] } + context 'with an invalid scope' do + let(:given_scope) { ['baz'] } + let(:converted_scope) { [{ groups: [], plugins: [] }, ['baz']] } - it "does not run the action" do - expect(output).to receive(:puts).with("Unknown scopes: baz") + it 'does not run the action' do + expect(output).to receive(:puts).with('Unknown scopes: baz') expect(Guard).to_not receive(:async_queue_add) - FakePry.process("baz") + FakePry.process('baz') end end end diff --git a/spec/lib/guard/commands/change_spec.rb b/spec/lib/guard/commands/change_spec.rb index 639523c2b..ef508217b 100644 --- a/spec/lib/guard/commands/change_spec.rb +++ b/spec/lib/guard/commands/change_spec.rb @@ -1,4 +1,4 @@ -require "guard/commands/change" +require 'guard/commands/change' RSpec.describe Guard::Commands::Change do let(:output) { instance_double(Pry::Output) } @@ -10,35 +10,35 @@ def self.output before do allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with("change") do |&block| + allow(Pry::Commands).to receive(:create_command).with('change') do |&block| FakePry.instance_eval(&block) end described_class.import end - context "with a file" do - it "runs the :run_on_changes action with the given file" do + 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: []) + with(modified: ['foo'], added: [], removed: []) - FakePry.process("foo") + FakePry.process('foo') end end - context "with multiple files" do - it "runs the :run_on_changes action with the given files" do + 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: []) - FakePry.process("foo", "bar", "baz") + FakePry.process('foo', 'bar', 'baz') end end - context "without a file" do - it "does not run the :run_on_changes action" do + context 'without a file' do + it 'does not run the :run_on_changes action' do expect(::Guard).to_not receive(:async_queue_add) - expect(output).to receive(:puts).with("Please specify a file.") + expect(output).to receive(:puts).with('Please specify a file.') FakePry.process end diff --git a/spec/lib/guard/commands/notification_spec.rb b/spec/lib/guard/commands/notification_spec.rb index 81fc375c3..b9ac0b700 100644 --- a/spec/lib/guard/commands/notification_spec.rb +++ b/spec/lib/guard/commands/notification_spec.rb @@ -1,4 +1,4 @@ -require "guard/commands/notification" +require 'guard/commands/notification' RSpec.describe Guard::Commands::Notification do let(:output) { instance_double(Pry::Output) } @@ -10,14 +10,14 @@ 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| + with('notification') do |&block| FakePry.instance_eval(&block) end described_class.import end - it "toggles the Guard notifier" do + it 'toggles the Guard notifier' do expect(::Guard::Notifier).to receive(:toggle) FakePry.process end diff --git a/spec/lib/guard/commands/pause_spec.rb b/spec/lib/guard/commands/pause_spec.rb index 674ed6560..fabdd235d 100644 --- a/spec/lib/guard/commands/pause_spec.rb +++ b/spec/lib/guard/commands/pause_spec.rb @@ -1,4 +1,4 @@ -require "guard/commands/pause" +require 'guard/commands/pause' RSpec.describe Guard::Commands::Pause do class FakePry < Pry::Command @@ -8,14 +8,14 @@ def self.output before do allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with("pause") do |&block| + allow(Pry::Commands).to receive(:create_command).with('pause') do |&block| FakePry.instance_eval(&block) end described_class.import end - it "tells Guard to pause" do + it 'tells Guard to pause' do expect(::Guard).to receive(:async_queue_add).with([:guard_pause]) FakePry.process end diff --git a/spec/lib/guard/commands/reload_spec.rb b/spec/lib/guard/commands/reload_spec.rb index b58fde6bb..c23ee7f75 100644 --- a/spec/lib/guard/commands/reload_spec.rb +++ b/spec/lib/guard/commands/reload_spec.rb @@ -1,13 +1,13 @@ -require "guard/commands/reload" +require 'guard/commands/reload' -require "guard/internals/session" -require "guard/internals/state" +require 'guard/internals/session' +require 'guard/internals/state' RSpec.describe Guard::Commands::Reload do let(:output) { instance_double(Pry::Output) } - let(:state) { instance_double("Guard::Internals::State") } - let(:session) { instance_double("Guard::Internals::Session") } + let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double('Guard::Internals::Session') } let(:foo_group) { instance_double(Guard::Group) } let(:bar_guard) { instance_double(Guard::Plugin) } @@ -24,54 +24,54 @@ def self.output; end allow(Guard).to receive(:state).and_return(state) allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with("reload") do |&block| + allow(Pry::Commands).to receive(:create_command).with('reload') do |&block| FakePry.instance_eval(&block) end described_class.import end - context "without scope" do + context 'without scope' do let(:given_scope) { [] } let(:converted_scope) { [{ groups: [], plugins: [] }, []] } - it "triggers the :reload action" do + it 'triggers the :reload action' do expect(Guard).to receive(:async_queue_add). with([:guard_reload, { groups: [], plugins: [] }]) FakePry.process end end - context "with a valid Guard group scope" do - let(:given_scope) { ["foo"] } + context 'with a valid Guard group scope' do + let(:given_scope) { ['foo'] } let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } - it "triggers the :reload action with the given scope" do + it 'triggers the :reload action with the given scope' do expect(Guard).to receive(:async_queue_add). with([:guard_reload, { groups: [foo_group], plugins: [] }]) - FakePry.process("foo") + FakePry.process('foo') end end - context "with a valid Guard plugin scope" do - let(:given_scope) { ["bar"] } + context 'with a valid Guard plugin scope' do + let(:given_scope) { ['bar'] } let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } - it "triggers the :reload action with the given scope" do + it 'triggers the :reload action with the given scope' do expect(Guard).to receive(:async_queue_add). with([:guard_reload, { plugins: [bar_guard], groups: [] }]) - FakePry.process("bar") + FakePry.process('bar') end end - context "with an invalid scope" do - let(:given_scope) { ["baz"] } - let(:converted_scope) { [{ groups: [], plugins: [] }, ["baz"]] } + context 'with an invalid scope' do + let(:given_scope) { ['baz'] } + let(:converted_scope) { [{ groups: [], plugins: [] }, ['baz']] } - it "does not trigger the action" do - allow(output).to receive(:puts).with("Unknown scopes: baz") + it 'does not trigger the action' do + allow(output).to receive(:puts).with('Unknown scopes: baz') expect(Guard).to_not receive(:async_queue_add) - FakePry.process("baz") + FakePry.process('baz') end end end diff --git a/spec/lib/guard/commands/scope_spec.rb b/spec/lib/guard/commands/scope_spec.rb index 2a877300b..684a2d818 100644 --- a/spec/lib/guard/commands/scope_spec.rb +++ b/spec/lib/guard/commands/scope_spec.rb @@ -1,14 +1,14 @@ -require "guard/commands/scope" +require 'guard/commands/scope' -require "guard/internals/session" -require "guard/internals/state" +require 'guard/internals/session' +require 'guard/internals/state' RSpec.describe Guard::Commands::Scope do let(:output) { instance_double(Pry::Output) } - let(:state) { instance_double("Guard::Internals::State") } - let(:scope) { instance_double("Guard::Internals::Scope") } - let(:session) { instance_double("Guard::Internals::Session") } + let(:state) { instance_double('Guard::Internals::State') } + let(:scope) { instance_double('Guard::Internals::Scope') } + let(:session) { instance_double('Guard::Internals::Session') } let(:foo_group) { instance_double(Guard::Group) } let(:bar_guard) { instance_double(Guard::PluginUtil) } @@ -25,7 +25,7 @@ def self.output; end allow(Guard).to receive(:state).and_return(state) allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with("scope") do |&block| + allow(Pry::Commands).to receive(:create_command).with('scope') do |&block| FakePry.instance_eval(&block) end @@ -35,47 +35,47 @@ def self.output; end described_class.import end - context "without scope" do + context 'without scope' do let(:given_scope) { [] } let(:converted_scope) { [{ groups: [], plugins: [] }, []] } - it "does not call :scope= and shows usage" do - expect(output).to receive(:puts).with("Usage: scope ") + it 'does not call :scope= and shows usage' do + expect(output).to receive(:puts).with('Usage: scope ') expect(scope).to_not receive(:from_interactor) FakePry.process end end - context "with a valid Guard group scope" do - let(:given_scope) { ["foo"] } + context 'with a valid Guard group scope' do + let(:given_scope) { ['foo'] } let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } - it "sets up the scope with the given scope" do + it 'sets up the scope with the given scope' do expect(scope).to receive(:from_interactor). with(groups: [foo_group], plugins: []) - FakePry.process("foo") + FakePry.process('foo') end end - context "with a valid Guard plugin scope" do - let(:given_scope) { ["bar"] } + context 'with a valid Guard plugin scope' do + let(:given_scope) { ['bar'] } let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } - it "runs the :scope= action with the given scope" do + it 'runs the :scope= action with the given scope' do expect(scope).to receive(:from_interactor). with(plugins: [bar_guard], groups: []) - FakePry.process("bar") + FakePry.process('bar') end end - context "with an invalid scope" do - let(:given_scope) { ["baz"] } - let(:converted_scope) { [{ groups: [], plugins: [] }, ["baz"]] } + context 'with an invalid scope' do + let(:given_scope) { ['baz'] } + let(:converted_scope) { [{ groups: [], plugins: [] }, ['baz']] } - it "does not change the scope and shows unknown scopes" do - expect(output).to receive(:puts).with("Unknown scopes: baz") + it 'does not change the scope and shows unknown scopes' do + expect(output).to receive(:puts).with('Unknown scopes: baz') expect(scope).to_not receive(:from_interactor) - FakePry.process("baz") + FakePry.process('baz') end end end diff --git a/spec/lib/guard/commands/show_spec.rb b/spec/lib/guard/commands/show_spec.rb index 4ed7344cb..d191529ef 100644 --- a/spec/lib/guard/commands/show_spec.rb +++ b/spec/lib/guard/commands/show_spec.rb @@ -1,7 +1,7 @@ -require "guard/commands/show" +require 'guard/commands/show' # TODO: we only need the async queue -require "guard" +require 'guard' RSpec.describe Guard::Commands::Show do let(:output) { instance_double(Pry::Output) } @@ -12,14 +12,14 @@ def self.output; end before do allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with("show") do |&block| + allow(Pry::Commands).to receive(:create_command).with('show') do |&block| FakePry.instance_eval(&block) end described_class.import end - it "tells Guard to output DSL description" do + it 'tells Guard to output DSL description' do expect(::Guard).to receive(:async_queue_add).with([:guard_show]) FakePry.process end diff --git a/spec/lib/guard/config_spec.rb b/spec/lib/guard/config_spec.rb index 92456df8d..6faed2c5b 100644 --- a/spec/lib/guard/config_spec.rb +++ b/spec/lib/guard/config_spec.rb @@ -1,10 +1,10 @@ -require "guard/config" +require 'guard/config' RSpec.describe Guard::Config, exclude_stubs: [:Nenv] do it { is_expected.to respond_to(:strict?) } it { is_expected.to respond_to(:silence_deprecations?) } - describe ".strict?" do + describe '.strict?' do before do allow(subject).to receive(:strict?).and_return(result) end diff --git a/spec/lib/guard/deprecated/dsl_spec.rb b/spec/lib/guard/deprecated/dsl_spec.rb index 8e09b536f..71f934fa6 100644 --- a/spec/lib/guard/deprecated/dsl_spec.rb +++ b/spec/lib/guard/deprecated/dsl_spec.rb @@ -1,33 +1,33 @@ -require "guard/config" +require 'guard/config' unless Guard::Config.new.strict? # Require listen now, so the requiring below doesn't use File methods - require "listen" + require 'listen' - require "guard/deprecated/dsl" + require 'guard/deprecated/dsl' - require "guard/ui" - require "guard/config" + require 'guard/ui' + require 'guard/config' RSpec.describe Guard::Deprecated::Dsl do subject do module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end - describe ".evaluate_guardfile" do + describe '.evaluate_guardfile' do before { stub_user_guard_rb } - before { stub_guardfile(" ") } + before { stub_guardfile(' ') } before { stub_user_guardfile } before { stub_user_project_guardfile } - let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } + let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } before do # TODO: this is a workaround for a bad require loop allow_any_instance_of(Guard::Config).to receive(:strict?). and_return(false) - require "guard/guardfile/evaluator" + require 'guard/guardfile/evaluator' allow(Guard::Guardfile::Evaluator).to receive(:new). and_return(evaluator) @@ -37,20 +37,20 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(Guard::UI).to receive(:deprecation) end - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Dsl::ClassMethods::EVALUATE_GUARDFILE) subject.evaluate_guardfile end - it "delegates to Guard::Guardfile::Generator" do + it 'delegates to Guard::Guardfile::Generator' do expect(Guard::Guardfile::Evaluator).to receive(:new). - with(foo: "bar") { evaluator } + with(foo: 'bar') { evaluator } expect(evaluator).to receive(:evaluate_guardfile) - subject.evaluate_guardfile(foo: "bar") + subject.evaluate_guardfile(foo: 'bar') end end end diff --git a/spec/lib/guard/deprecated/evaluator_spec.rb b/spec/lib/guard/deprecated/evaluator_spec.rb index d656836c3..e9d4d4e2d 100644 --- a/spec/lib/guard/deprecated/evaluator_spec.rb +++ b/spec/lib/guard/deprecated/evaluator_spec.rb @@ -1,9 +1,9 @@ -require "guard/config" +require 'guard/config' unless Guard::Config.new.strict? - require "guard/deprecated/evaluator" - require "guard/internals/state" + require 'guard/deprecated/evaluator' + require 'guard/internals/state' RSpec.describe Guard::Deprecated::Evaluator do subject do @@ -15,32 +15,32 @@ def evaluate TestClass.new end - let(:state) { instance_double("Guard::Internals::State") } + let(:state) { instance_double('Guard::Internals::State') } before do allow(Guard::UI).to receive(:deprecation) allow(Guard).to receive(:state).and_return(state) end - describe "#evaluate_guardfile" do + describe '#evaluate_guardfile' do before do allow(subject).to receive(:evaluate) end - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Evaluator::EVALUATE_GUARDFILE) subject.evaluate_guardfile end - it "calls the recommended method" do + it 'calls the recommended method' do expect(subject).to receive(:evaluate) subject.evaluate_guardfile end end - describe "#reevaluate_guardfile" do - it "displays a deprecation warning to the user" do + 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) subject.reevaluate_guardfile diff --git a/spec/lib/guard/deprecated/guard_spec.rb b/spec/lib/guard/deprecated/guard_spec.rb index f5a76dc21..19a7d8647 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -1,19 +1,19 @@ -require "guard/config" +require 'guard/config' unless Guard::Config.new.strict? # require guard, to avoid circular require - require "guard" + require 'guard' # require "guard/deprecated/guard" - require "guard/config" + require 'guard/config' RSpec.describe Guard::Deprecated::Guard do - let(:session) { instance_double("Guard::Internals::Session") } - let(:state) { instance_double("Guard::Internals::State") } - let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:groups) { instance_double("Guard::Internals::Groups") } - let(:scope) { instance_double("Guard::Internals::Scope") } + let(:session) { instance_double('Guard::Internals::Session') } + let(:state) { instance_double('Guard::Internals::State') } + let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:groups) { instance_double('Guard::Internals::Groups') } + let(:scope) { instance_double('Guard::Internals::Scope') } subject do module TestModule @@ -39,113 +39,113 @@ def self._pluginless_guardfile? allow(groups).to receive(:all) end - describe ".guards" do + describe '.guards' do before do end - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::GUARDS) subject.guards end - it "delegates to Plugins" do - expect(plugins).to receive(:all).with(group: "backend") - subject.guards(group: "backend") + it 'delegates to Plugins' do + expect(plugins).to receive(:all).with(group: 'backend') + subject.guards(group: 'backend') end end - describe ".add_guard" do - before { allow(plugins).to receive(:add).with("rspec", {}) } + describe '.add_guard' do + before { allow(plugins).to receive(:add).with('rspec', {}) } - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::ADD_GUARD) - subject.add_guard("rspec") + subject.add_guard('rspec') end - it "delegates to Guard.plugins" do - expect(subject).to receive(:add_plugin).with("rspec", group: "backend") + it 'delegates to Guard.plugins' do + expect(subject).to receive(:add_plugin).with('rspec', group: 'backend') - subject.add_guard("rspec", group: "backend") + subject.add_guard('rspec', group: 'backend') end end - describe ".get_guard_class" do + describe '.get_guard_class' do let(:plugin_util) do - instance_double("Guard::PluginUtil", plugin_class: true) + instance_double('Guard::PluginUtil', plugin_class: true) end before do - allow(Guard::PluginUtil).to receive(:new).with("rspec"). + allow(Guard::PluginUtil).to receive(:new).with('rspec'). and_return(plugin_util) end - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::GET_GUARD_CLASS) - subject.get_guard_class("rspec") + subject.get_guard_class('rspec') end - it "delegates to Guard::PluginUtil" do + it 'delegates to Guard::PluginUtil' do expect(plugin_util).to receive(:plugin_class). with(fail_gracefully: false) - subject.get_guard_class("rspec") + subject.get_guard_class('rspec') end - describe ":fail_gracefully" do - it "pass it to get_guard_class" do + describe ':fail_gracefully' do + it 'pass it to get_guard_class' do expect(plugin_util).to receive(:plugin_class). with(fail_gracefully: true) - subject.get_guard_class("rspec", true) + subject.get_guard_class('rspec', true) end end end - describe ".locate_guard" do + describe '.locate_guard' do let(:plugin_util) do - instance_double("Guard::PluginUtil", plugin_location: true) + instance_double('Guard::PluginUtil', plugin_location: true) end before do allow(Guard::PluginUtil).to receive(:new) { plugin_util } end - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::LOCATE_GUARD) - subject.locate_guard("rspec") + subject.locate_guard('rspec') end - it "delegates to Guard::PluginUtil" do - expect(Guard::PluginUtil).to receive(:new).with("rspec") { plugin_util } + it 'delegates to Guard::PluginUtil' do + expect(Guard::PluginUtil).to receive(:new).with('rspec') { plugin_util } expect(plugin_util).to receive(:plugin_location) - subject.locate_guard("rspec") + subject.locate_guard('rspec') end end - describe ".guard_gem_names" do + describe '.guard_gem_names' do before { allow(Guard::PluginUtil).to receive(:plugin_names) } - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::GUARD_GEM_NAMES) subject.guard_gem_names end - it "delegates to Guard::PluginUtil" do + it 'delegates to Guard::PluginUtil' do expect(Guard::PluginUtil).to receive(:plugin_names) subject.guard_gem_names end end - describe ".running" do - it "show deprecation warning" do + describe '.running' do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::RUNNING) @@ -153,8 +153,8 @@ def self._pluginless_guardfile? end end - describe ".lock" do - it "show deprecation warning" do + describe '.lock' do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::LOCK) @@ -162,41 +162,41 @@ def self._pluginless_guardfile? end end - describe ".listener=" do - it "show deprecation warning" do + describe '.listener=' do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::LISTENER_ASSIGN) subject.listener = 123 end - it "provides and alternative implementation" do + it 'provides and alternative implementation' do subject.listener = 123 end end - describe "reset_evaluator" do - it "show deprecation warning" do + describe 'reset_evaluator' do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::RESET_EVALUATOR) subject.reset_evaluator({}) end end - describe "evaluator" do + describe 'evaluator' do before do allow(Guard::Guardfile::Evaluator).to receive(:new). - and_return(double("evaluator")) + and_return(double('evaluator')) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::EVALUATOR) subject.evaluator end end - describe "evaluate_guardfile" do - let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } + describe 'evaluate_guardfile' do + let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } before do allow(::Guard::Guardfile::Evaluator).to receive(:new). @@ -204,19 +204,19 @@ def self._pluginless_guardfile? allow(evaluator).to receive(:evaluate) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::EVALUATOR) subject.evaluate_guardfile end - it "evaluates the guardfile" do + it 'evaluates the guardfile' do expect(evaluator).to receive(:evaluate) subject.evaluate_guardfile end end - describe "options" do + describe 'options' do before do allow(session).to receive(:clearing?) allow(session).to receive(:debug?) @@ -225,43 +225,43 @@ def self._pluginless_guardfile? allow(session).to receive(:interactor_name) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::OPTIONS) subject.options end - describe ":clear" do + describe ':clear' do before do allow(session).to receive(:clearing?).and_return(clearing) end - context "when being set to true" do + context 'when being set to true' do let(:clearing) { true } - it "sets the clearing option accordingly" do + it 'sets the clearing option accordingly' do expect(session).to receive(:clearing).with(true) subject.options[:clear] = true end end - context "when being set to false" do + context 'when being set to false' do let(:clearing) { false } - it "sets the clearing option accordingly" do + it 'sets the clearing option accordingly' do expect(session).to receive(:clearing).with(false) subject.options[:clear] = false end end - context "when being read" do - context "when not set" do + context 'when being read' do + context 'when not set' do let(:clearing) { false } - it "provides an alternative implementation" do + it 'provides an alternative implementation' do expect(subject.options).to include(clear: false) end end - context "when set" do + context 'when set' do let(:clearing) { true } - it "provides an alternative implementation" do + it 'provides an alternative implementation' do expect(subject.options).to include(clear: true) end end @@ -271,43 +271,43 @@ def self._pluginless_guardfile? # TODO: other options? end - describe ".add_group" do + describe '.add_group' do before do allow(groups).to receive(:add) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::ADD_GROUP) subject.add_group(:foo) end - it "adds a group" do - group = instance_double("Guard::Group") + it 'adds a group' do + group = instance_double('Guard::Group') expect(groups).to receive(:add).with(:foo, bar: 3).and_return(group) expect(subject.add_group(:foo, bar: 3)).to eq(group) end end - describe ".add_plugin" do + describe '.add_plugin' do before do allow(plugins).to receive(:add) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::ADD_PLUGIN) subject.add_plugin(:foo) end - it "adds a plugin" do - plugin = instance_double("Guard::Plugin") + it 'adds a plugin' do + plugin = instance_double('Guard::Plugin') expect(plugins).to receive(:add).with(:foo, bar: 3).and_return(plugin) expect(subject.add_plugin(:foo, bar: 3)).to be(plugin) end end - describe ".group" do + describe '.group' do let(:array) { instance_double(Array) } before do @@ -315,105 +315,105 @@ def self._pluginless_guardfile? allow(array).to receive(:first) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::GROUP) subject.group(:foo) end - it "provides a similar implementation" do - group = instance_double("Guard::Group") + it 'provides a similar implementation' do + group = instance_double('Guard::Group') expect(array).to receive(:first).and_return(group) expect(subject.group(:foo)).to be(group) end end - describe ".plugin" do + describe '.plugin' do let(:array) { instance_double(Array) } - let(:plugin) { instance_double("Guard::Plugin") } + let(:plugin) { instance_double('Guard::Plugin') } before do allow(plugins).to receive(:all).with(:foo).and_return(array) allow(array).to receive(:first).and_return(plugin) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::PLUGIN) subject.plugin(:foo) end - it "provides a similar implementation" do + it 'provides a similar implementation' do expect(subject.plugin(:foo)).to be(plugin) end end - describe ".groups" do + describe '.groups' do let(:array) { instance_double(Array) } before do allow(groups).to receive(:all).with(:foo).and_return(array) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::GROUPS) subject.groups(:foo) end - it "provides a similar implementation" do + it 'provides a similar implementation' do expect(subject.groups(:foo)).to be(array) end end - describe ".plugins" do + describe '.plugins' do let(:array) { instance_double(Array) } before do allow(plugins).to receive(:all).with(:foo).and_return(array) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::PLUGINS) subject.plugins(:foo) end - it "provides a similar implementation" do + it 'provides a similar implementation' do expect(subject.plugins(:foo)).to be(array) end end - describe ".scope" do + describe '.scope' do let(:hash) { instance_double(Hash) } before do allow(scope).to receive(:to_hash).and_return(hash) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::SCOPE) subject.scope end - it "provides a similar implementation" do + it 'provides a similar implementation' do expect(subject.scope).to be(hash) end end - describe ".scope=" do + describe '.scope=' do before do allow(scope).to receive(:from_interactor).with(foo: :bar) end - it "show deprecation warning" do + it 'show deprecation warning' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guard::ClassMethods::SCOPE_ASSIGN) subject.scope = { foo: :bar } end - it "provides a similar implementation" do + it 'provides a similar implementation' do expect(scope).to receive(:from_interactor).with(foo: :bar) 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..cdb7ccec4 100644 --- a/spec/lib/guard/deprecated/guardfile_spec.rb +++ b/spec/lib/guard/deprecated/guardfile_spec.rb @@ -1,25 +1,25 @@ -require "guard/config" +require 'guard/config' unless Guard::Config.new.strict? - require "guard/deprecated/guardfile" + require 'guard/deprecated/guardfile' RSpec.describe Guard::Deprecated::Guardfile do subject do module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end - let(:generator) { instance_double("Guard::Guardfile::Generator") } + let(:generator) { instance_double('Guard::Guardfile::Generator') } before do allow(Guard::UI).to receive(:deprecation) end - describe ".create_guardfile" do + describe '.create_guardfile' do before do - allow(File).to receive(:exist?).with("Guardfile").and_return(false) + allow(File).to receive(:exist?).with('Guardfile').and_return(false) template = Guard::Guardfile::Generator::GUARDFILE_TEMPLATE - allow(FileUtils).to receive(:cp).with(template, "Guardfile") + allow(FileUtils).to receive(:cp).with(template, 'Guardfile') allow(Guard::Guardfile::Generator).to receive(:new). and_return(generator) @@ -27,24 +27,24 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(generator).to receive(:create_guardfile) end - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guardfile::ClassMethods::CREATE_GUARDFILE) subject.create_guardfile end - it "delegates to Guard::Guardfile::Generator" do + it 'delegates to Guard::Guardfile::Generator' do expect(Guard::Guardfile::Generator).to receive(:new). - with(foo: "bar") { generator } + with(foo: 'bar') { generator } expect(generator).to receive(:create_guardfile) - subject.create_guardfile(foo: "bar") + subject.create_guardfile(foo: 'bar') end end - describe ".initialize_template" do + describe '.initialize_template' do before do expect(Guard::Guardfile::Generator).to receive(:new) do generator @@ -53,21 +53,21 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(generator).to receive(:initialize_template) end - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(Guard::Deprecated::Guardfile::ClassMethods::INITIALIZE_TEMPLATE) - subject.initialize_template("rspec") + subject.initialize_template('rspec') end - it "delegates to Guard::Guardfile::Generator" do - expect(generator).to receive(:initialize_template).with("rspec") + it 'delegates to Guard::Guardfile::Generator' do + expect(generator).to receive(:initialize_template).with('rspec') - subject.initialize_template("rspec") + subject.initialize_template('rspec') end end - describe ".initialize_all_templates" do + describe '.initialize_all_templates' do before do expect(Guard::Guardfile::Generator).to receive(:new) do generator @@ -76,14 +76,14 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(generator).to receive(:initialize_all_templates) end - it "displays a deprecation warning to the user" do + it 'displays a deprecation warning to the user' do expect(Guard::UI).to receive(:deprecation). with(described_class::ClassMethods::INITIALIZE_ALL_TEMPLATES) subject.initialize_all_templates end - it "delegates to Guard::Guardfile::Generator" do + it 'delegates to Guard::Guardfile::Generator' do expect(generator).to receive(:initialize_all_templates) subject.initialize_all_templates diff --git a/spec/lib/guard/deprecated/watcher_spec.rb b/spec/lib/guard/deprecated/watcher_spec.rb index c1db5cbe7..d6fc8e023 100644 --- a/spec/lib/guard/deprecated/watcher_spec.rb +++ b/spec/lib/guard/deprecated/watcher_spec.rb @@ -1,21 +1,21 @@ -require "guard/config" +require 'guard/config' unless Guard::Config.new.strict? - require "guard/deprecated/watcher" - require "guard/guardfile/evaluator" + require 'guard/deprecated/watcher' + require 'guard/guardfile/evaluator' RSpec.describe Guard::Deprecated::Watcher do - let(:session) { instance_double("Guard::Internals::Session") } + let(:session) { instance_double('Guard::Internals::Session') } subject do module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end - let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } - let(:options) { { guardfile: "foo" } } + let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } + let(:options) { { guardfile: 'foo' } } - let(:state) { instance_double("Guard::Internals::State") } + let(:state) { instance_double('Guard::Internals::State') } before do allow(session).to receive(:evaluator_options).and_return(options) @@ -23,7 +23,7 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(Guard).to receive(:state).and_return(state) allow(evaluator).to receive(:guardfile_path). - and_return(File.expand_path("foo")) + and_return(File.expand_path('foo')) allow(::Guard::Guardfile::Evaluator).to receive(:new).with(options). and_return(evaluator) @@ -31,8 +31,8 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(Guard::UI).to receive(:deprecation) end - describe ".match_guardfile?" do - it "displays a deprecation warning to the user" do + 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) @@ -40,7 +40,7 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } subject.match_guardfile?(files) end - it "matches against current guardfile" do + 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) end diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index 39c55187f..036dd505b 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -1,16 +1,16 @@ # encoding: utf-8 -require "guard/plugin" -require "guard/dsl_describer" -require "formatador" +require 'guard/plugin' +require 'guard/dsl_describer' +require 'formatador' RSpec.describe Guard::DslDescriber do let(:interactor) { instance_double(Guard::Interactor) } - let(:env) { double("ENV") } + let(:env) { double('ENV') } - let(:session) { instance_double("Guard::Internals::Session") } - let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:groups) { instance_double("Guard::Internals::Groups") } - let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double('Guard::Internals::Session') } + let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:groups) { instance_double('Guard::Internals::Groups') } + let(:state) { instance_double('Guard::Internals::State') } before do allow(session).to receive(:groups).and_return(groups) @@ -18,17 +18,17 @@ allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) - allow(env).to receive(:[]).with("GUARD_NOTIFY_PID") - allow(env).to receive(:[]).with("GUARD_NOTIFY") - allow(env).to receive(:[]).with("GUARD_NOTIFIERS") - allow(env).to receive(:[]=).with("GUARD_NOTIFIERS", anything) + allow(env).to receive(:[]).with('GUARD_NOTIFY_PID') + allow(env).to receive(:[]).with('GUARD_NOTIFY') + allow(env).to receive(:[]).with('GUARD_NOTIFIERS') + allow(env).to receive(:[]=).with('GUARD_NOTIFIERS', anything) allow(Guard::Notifier).to receive(:turn_on) - stub_const "Guard::Test", class_double("Guard::Plugin") - stub_const "Guard::Another", class_double("Guard::Plugin") + stub_const 'Guard::Test', class_double('Guard::Plugin') + stub_const 'Guard::Another', class_double('Guard::Plugin') - @output = "" + @output = '' # Strip escape sequences allow(STDOUT).to receive(:tty?).and_return(false) @@ -40,7 +40,7 @@ end end - describe "#list" do + describe '#list' do let(:result) do <<-OUTPUT +---------+-----------+ @@ -54,27 +54,27 @@ OUTPUT end - let(:another) { instance_double("Guard::Plugin", title: "Another") } - let(:test) { instance_double("Guard::Plugin", title: "Test") } + let(:another) { instance_double('Guard::Plugin', title: 'Another') } + let(:test) { instance_double('Guard::Plugin', title: 'Test') } before do - allow(plugins).to receive(:all).with("another").and_return([another]) - allow(plugins).to receive(:all).with("test").and_return([test]) - allow(plugins).to receive(:all).with("even").and_return([]) - allow(plugins).to receive(:all).with("more").and_return([]) + allow(plugins).to receive(:all).with('another').and_return([another]) + allow(plugins).to receive(:all).with('test').and_return([test]) + allow(plugins).to receive(:all).with('even').and_return([]) + allow(plugins).to receive(:all).with('more').and_return([]) allow(Guard::PluginUtil).to receive(:plugin_names) do %w(test another even more) end end - it "lists the available Guards declared as strings or symbols" do + it 'lists the available Guards declared as strings or symbols' do subject.list expect(@output).to eq result end end - describe ".show" do + describe '.show' do let(:result) do <<-OUTPUT +---------+---------+--------+-------+ @@ -93,33 +93,33 @@ before do 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: :default, title: 'Default'), + instance_double('Guard::Group', name: :a, title: 'A'), + instance_double('Guard::Group', name: :b, title: 'B'), ] allow(plugins).to receive(:all).with(group: :default) do options = { a: :b, c: :d } - [instance_double("Guard::Plugin", title: "Test", options: options)] + [instance_double('Guard::Plugin', title: 'Test', options: options)] end allow(plugins).to receive(:all).with(group: :a) do options = { x: 1, y: 2 } - [instance_double("Guard::Plugin", title: "Test", options: options)] + [instance_double('Guard::Plugin', title: 'Test', options: options)] end allow(plugins).to receive(:all).with(group: :b).and_return [ - instance_double("Guard::Plugin", title: "Another", options: []) + instance_double('Guard::Plugin', title: 'Another', options: []) ] end - it "shows the Guards and their options" do + it 'shows the Guards and their options' do subject.show expect(@output).to eq result end end - describe ".notifiers" do + describe '.notifiers' do let(:result) do <<-OUTPUT +----------------+-----------+------+--------+-------+ @@ -145,7 +145,7 @@ allow(Guard::Notifier).to receive(:disconnect).once end - it "properly connects and disconnects" do + it 'properly connects and disconnects' do expect(Guard::Notifier).to receive(:connect).once.ordered expect(::Guard::Notifier).to receive(:detected).once.ordered.and_return [ { name: :gntp, options: { sticky: true } } @@ -156,7 +156,7 @@ subject.notifiers end - it "shows the notifiers and their options" do + it 'shows the notifiers and their options' do subject.notifiers expect(@output).to eq result end diff --git a/spec/lib/guard/dsl_reader_spec.rb b/spec/lib/guard/dsl_reader_spec.rb index 92efb5df6..165036583 100644 --- a/spec/lib/guard/dsl_reader_spec.rb +++ b/spec/lib/guard/dsl_reader_spec.rb @@ -1,4 +1,4 @@ -require "guard/dsl_reader" +require 'guard/dsl_reader' RSpec.describe Guard::DslReader, exclude_stubs: [Guard::Dsl] do methods = %w( @@ -8,50 +8,50 @@ methods.each do |meth| describe "\##{meth} signature" do - it "matches base signature" do + it 'matches base signature' do expected = Guard::Dsl.instance_method(meth).arity expect(subject.method(meth).arity).to eq(expected) end end end - describe "guard" do - context "when it is a String" do - let(:name) { "foo" } - it "works without errors" do + describe 'guard' do + context 'when it is a String' do + let(:name) { 'foo' } + it 'works without errors' do expect { subject.guard(name, bar: :baz) }.to_not raise_error end - it "reports the name as a String" do - subject.guard("foo", bar: :baz) + it 'reports the name as a String' do + subject.guard('foo', bar: :baz) expect(subject.plugin_names).to eq(%w(foo)) end end - context "when it is a Symbol" do + context 'when it is a Symbol' do let(:name) { :foo } - it "works without errors" do + it 'works without errors' do expect { subject.guard(name, bar: :baz) }.to_not raise_error end - it "reports the name as a String" do + it 'reports the name as a String' do subject.guard(name, bar: :baz) expect(subject.plugin_names).to eq(%w(foo)) end end end - describe "plugin_names" do - it "returns encountered names" do - subject.guard("foo", bar: :baz) - subject.guard("bar", bar: :baz) - subject.guard("baz", bar: :baz) + describe 'plugin_names' do + it 'returns encountered names' do + 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)) end end - describe "notification" do - it "handles arguments without errors" do + describe 'notification' do + it 'handles arguments without errors' do expect { subject.notification(:off) }.to_not raise_error end end diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index 583b4a0b4..c57c32293 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -1,31 +1,31 @@ -require "guard/plugin" +require 'guard/plugin' -require "guard/dsl" +require 'guard/dsl' RSpec.describe Guard::Dsl do - let(:ui_config) { instance_double("Guard::UI::Config") } + let(:ui_config) { instance_double('Guard::UI::Config') } let(:guardfile_evaluator) { instance_double(Guard::Guardfile::Evaluator) } let(:interactor) { instance_double(Guard::Interactor) } - let(:listener) { instance_double("Listen::Listener") } + let(:listener) { instance_double('Listen::Listener') } - let(:session) { instance_double("Guard::Internals::Session") } - let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:groups) { instance_double("Guard::Internals::Groups") } - let(:state) { instance_double("Guard::Internals::State") } - let(:scope) { instance_double("Guard::Internals::Scope") } + let(:session) { instance_double('Guard::Internals::Session') } + let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:groups) { instance_double('Guard::Internals::Groups') } + let(:state) { instance_double('Guard::Internals::State') } + let(:scope) { instance_double('Guard::Internals::Scope') } let(:evaluator) do proc do |contents| - Guard::Dsl.new.evaluate(contents, "", 1) + Guard::Dsl.new.evaluate(contents, '', 1) end end before do stub_user_guard_rb - stub_const "Guard::Foo", instance_double(Guard::Plugin) - stub_const "Guard::Bar", instance_double(Guard::Plugin) - stub_const "Guard::Baz", instance_double(Guard::Plugin) + stub_const 'Guard::Foo', instance_double(Guard::Plugin) + stub_const 'Guard::Bar', instance_double(Guard::Plugin) + stub_const 'Guard::Baz', instance_double(Guard::Plugin) allow(Guard::Notifier).to receive(:turn_on) allow(Guard::Interactor).to receive(:new).and_return(interactor) @@ -36,26 +36,26 @@ allow(Guard).to receive(:state).and_return(state) # For backtrace cleanup - allow(ENV).to receive(:[]).with("GEM_HOME").and_call_original - allow(ENV).to receive(:[]).with("GEM_PATH").and_call_original + allow(ENV).to receive(:[]).with('GEM_HOME').and_call_original + allow(ENV).to receive(:[]).with('GEM_PATH').and_call_original allow(Guard::UI::Config).to receive(:new).and_return(ui_config) end - describe "#ignore" do - context "with ignore regexps" do - let(:contents) { "ignore %r{^foo}, /bar/" } + describe '#ignore' do + context 'with ignore regexps' do + let(:contents) { 'ignore %r{^foo}, /bar/' } - it "adds ignored regexps to the listener" do + it 'adds ignored regexps to the listener' do expect(session).to receive(:guardfile_ignore=).with([/^foo/, /bar/]) evaluator.call(contents) end end - context "with multiple ignore calls" do - let(:contents) { "ignore(/foo/); ignore(/bar/)" } + context 'with multiple ignore calls' do + let(:contents) { 'ignore(/foo/); ignore(/bar/)' } - it "adds all ignored regexps to the listener" do + it 'adds all ignored regexps to the listener' do expect(session).to receive(:guardfile_ignore=).with([/foo/]).once expect(session).to receive(:guardfile_ignore=).with([/bar/]).once evaluator.call(contents) @@ -63,11 +63,11 @@ end end - describe "#ignore!" do - context "when ignoring only foo* and *bar*" do - let(:contents) { "ignore! %r{^foo}, /bar/" } + describe '#ignore!' do + context 'when ignoring only foo* and *bar*' do + let(:contents) { 'ignore! %r{^foo}, /bar/' } - it "replaces listener regexps" do + it 'replaces listener regexps' do expect(session).to receive(:guardfile_ignore_bang=). with([[/^foo/, /bar/]]) @@ -75,10 +75,10 @@ end end - context "when ignoring *.txt and *.zip and ignoring! only foo*" do + context 'when ignoring *.txt and *.zip and ignoring! only foo*' do let(:contents) { "ignore! %r{.txt$}, /.*\\.zip/\n ignore! %r{^foo}" } - it "replaces listener ignores, but keeps ignore! ignores" do + it 'replaces listener ignores, but keeps ignore! ignores' do allow(session).to receive(:guardfile_ignore_bang=). with([[/.txt$/, /.*\.zip/]]) @@ -96,37 +96,37 @@ def method_for(klass, meth) end # TODO: deprecated #filter - describe "#filter alias method" do + describe '#filter alias method' do subject { method_for(described_class, :filter) } it { is_expected.to eq(method_for(described_class, :ignore)) } end # TODO: deprecated #filter - describe "#filter! alias method" do + describe '#filter! alias method' do subject { method_for(described_class, :filter!) } it { is_expected.to eq(method_for(described_class, :ignore!)) } end - describe "#notification" do - context "when notification" do - let(:contents) { "notification :growl" } + describe '#notification' do + context 'when notification' do + let(:contents) { 'notification :growl' } - it "adds a notification to the notifier" do + it 'adds a notification to the notifier' do expect(session).to receive(:guardfile_notification=).with(growl: {}) evaluator.call(contents) end end - context "with multiple notifications" do + context 'with multiple notifications' do let(:contents) do "notification :growl\nnotification :ruby_gntp, host: '192.168.1.5'" end - it "adds multiple notifiers" do + it 'adds multiple notifiers' do expect(session).to receive(:guardfile_notification=).with(growl: {}) expect(session).to receive(:guardfile_notification=).with( - ruby_gntp: { host: "192.168.1.5" } + ruby_gntp: { host: '192.168.1.5' } ) evaluator.call(contents) @@ -134,43 +134,43 @@ def method_for(klass, meth) end end - describe "#interactor" do - context "with interactor :off" do - let(:contents) { "interactor :off" } - it "disables the interactions with :off" do + describe '#interactor' do + context 'with interactor :off' do + let(:contents) { 'interactor :off' } + it 'disables the interactions with :off' do expect(Guard::Interactor).to receive(:enabled=).with(false) evaluator.call(contents) end end - context "with interactor options" do + context 'with interactor options' do let(:contents) { 'interactor option1: \'a\', option2: 123' } - it "passes the options to the interactor" do + it 'passes the options to the interactor' do expect(Guard::Interactor).to receive(:options=). - with(option1: "a", option2: 123) + with(option1: 'a', option2: 123) evaluator.call(contents) end end end - describe "#group" do - context "no plugins in group" do - let(:contents) { "group :w" } + describe '#group' do + context 'no plugins in group' do + let(:contents) { 'group :w' } - it "displays an error" do + it 'displays an error' do expect(::Guard::UI).to receive(:error). with("No Guard plugins found in the group 'w',"\ - " please add at least one.") + ' please add at least one.') evaluator.call(contents) end end - context "group named :all" do - let(:contents) { "group :all" } + context 'group named :all' do + let(:contents) { 'group :all' } - it "raises an error" do + it 'raises an error' do expect { evaluator.call(contents) }. to raise_error( Guard::Dsl::Error, @@ -182,7 +182,7 @@ def method_for(klass, meth) context 'group named "all"' do let(:contents) { "group 'all'" } - it "raises an error" do + it 'raises an error' do expect { evaluator.call(contents) }. to raise_error( Guard::Dsl::Error, @@ -191,10 +191,10 @@ def method_for(klass, meth) end end - context "with a valid guardfile" do + context 'with a valid guardfile' do let(:contents) { valid_guardfile_string } - it "evaluates all groups" do + it 'evaluates all groups' do expect(groups).to receive(:add).with(:w, {}) expect(groups).to receive(:add).with(:y, {}) expect(groups).to receive(:add).with(:x, halt_on_fail: true) @@ -216,9 +216,9 @@ def method_for(klass, meth) end end - context "with multiple names" do - let(:contents) { "group :foo, :bar do; end" } - it "adds all given groups" do + context 'with multiple names' do + let(:contents) { 'group :foo, :bar do; end' } + it 'adds all given groups' do expect(groups).to receive(:add).with(:foo, {}) expect(groups).to receive(:add).with(:bar, {}) @@ -227,33 +227,33 @@ def method_for(klass, meth) end end - describe "#guard" do - context "with single-quoted name" do + describe '#guard' do + context 'with single-quoted name' do let(:contents) { 'guard \'test\'' } - it "loads a guard specified as a quoted string from the DSL" do + it 'loads a guard specified as a quoted string from the DSL' do expect(plugins).to receive(:add). - with("test", watchers: [], callbacks: [], group: :default) + with('test', watchers: [], callbacks: [], group: :default) evaluator.call(contents) end end - context "with double-quoted name" do + context 'with double-quoted name' do let(:contents) { 'guard "test"' } - it "loads a guard specified as a double quoted string from the DSL" do + 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) + with('test', watchers: [], callbacks: [], group: :default) evaluator.call(contents) end end - context "with symbol for name" do - let(:contents) { "guard :test" } + context 'with symbol for name' do + let(:contents) { 'guard :test' } - it "loads a guard specified as a symbol from the DSL" do + it 'loads a guard specified as a symbol from the DSL' do expect(plugins).to receive(:add). with(:test, watchers: [], callbacks: [], group: :default) @@ -261,37 +261,37 @@ def method_for(klass, meth) end end - context "with name as symbol in parens" do - let(:contents) { "guard(:test)" } + context 'with name as symbol in parens' do + let(:contents) { 'guard(:test)' } - it "adds the plugin" do + it 'adds the plugin' do expect(plugins).to receive(:add). with(:test, watchers: [], callbacks: [], group: :default) evaluator.call(contents) end end - context "with options" do + context 'with options' do let(:contents) { 'guard \'test\', opt_a: 1, opt_b: \'fancy\'' } - it "passes options to plugin" do + it 'passes options to plugin' do options = { watchers: [], callbacks: [], opt_a: 1, - opt_b: "fancy", + opt_b: 'fancy', group: :default } - expect(plugins).to receive(:add).with("test", options) + expect(plugins).to receive(:add).with('test', options) evaluator.call(contents) end end - context "with groups" do - let(:contents) { "group :foo do; group :bar do; guard :test; end; end" } + context 'with groups' do + let(:contents) { 'group :foo do; group :bar do; guard :test; end; end' } - it "adds plugin with group info" do + 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). @@ -301,12 +301,12 @@ def method_for(klass, meth) end end - context "with plugins in custom and default groups" do + context 'with plugins in custom and default groups' do let(:contents) do - "group :foo do; group :bar do; guard :test; end; end; guard :rspec" + 'group :foo do; group :bar do; guard :test; end; end; guard :rspec' end - it "assigns plugins to correct groups" do + it 'assigns plugins to correct groups' do expect(groups).to receive(:add).with(:foo, {}) expect(groups).to receive(:add).with(:bar, {}) @@ -321,15 +321,15 @@ def method_for(klass, meth) end end - describe "#watch" do + describe '#watch' do # TODO: this is testing too much - context "with watchers" do + context 'with watchers' do let(:watcher_a) do - instance_double("Guard::Watcher", pattern: "a", action: proc { "b" }) + instance_double('Guard::Watcher', pattern: 'a', action: proc { 'b' }) end let(:watcher_c) do - instance_double("Guard::Watcher", pattern: "c", action: nil) + instance_double('Guard::Watcher', pattern: 'c', action: nil) end let(:contents) do @@ -340,7 +340,7 @@ def method_for(klass, meth) end' end - it "should receive watchers when specified" do + it 'should receive watchers when specified' do call_params = { watchers: [anything, anything], callbacks: [], @@ -350,29 +350,29 @@ def method_for(klass, meth) 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 - expect(options[:watchers][1].pattern).to eq "c" + expect(options[:watchers][0].pattern).to eq 'a' + expect(options[:watchers][0].action.call).to eq proc { 'b' }.call + expect(options[:watchers][1].pattern).to eq 'c' expect(options[:watchers][1].action).to be_nil end - allow(Guard::Watcher).to receive(:new).with("a", anything). + allow(Guard::Watcher).to receive(:new).with('a', anything). and_return(watcher_a) - allow(Guard::Watcher).to receive(:new).with("c", nil). + 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 + context 'with watch in main scope' do let(:contents) { 'watch(\'a\')' } let(:watcher) do - instance_double("Guard::Watcher", pattern: "a", action: nil) + instance_double('Guard::Watcher', pattern: 'a', action: nil) end - it "should create an implicit no-op guard when outside a guard block" do + it 'should create an implicit no-op guard when outside a guard block' do plugin_options = { watchers: [anything], callbacks: [], @@ -382,11 +382,11 @@ def method_for(klass, meth) 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].pattern).to eq 'a' expect(options[:watchers][0].action).to be_nil end - allow(Guard::Watcher).to receive(:new).with("a", nil). + allow(Guard::Watcher).to receive(:new).with('a', nil). and_return(watcher) evaluator.call(contents) @@ -394,8 +394,8 @@ def method_for(klass, meth) end end - describe "#callback" do - context "with " do + describe '#callback' do + context 'with ' do let(:contents) do ' guard :rspec do @@ -408,7 +408,7 @@ def method_for(klass, meth) end' end - it "creates callbacks for the guard" do + it 'creates callbacks for the guard' do class MyCustomCallback def self.call(_plugin, _event, _args) # do nothing @@ -431,11 +431,11 @@ def self.call(_plugin, _event, _args) expect(callback_0[:events]).to eq :start_end - plugin = instance_double("Guard::Plugin", title: "RSpec") - result = callback_0[:listener].call(plugin, :start_end, "foo") + plugin = instance_double('Guard::Plugin', title: 'RSpec') + result = callback_0[:listener].call(plugin, :start_end, 'foo') expect(result).to eq 'RSpec executed \'start_end\' hook'\ - " with foo!" + ' with foo!' callback_1 = opt[:callbacks][1] expect(callback_1[:events]).to eq [:start_begin, :run_all_begin] @@ -446,7 +446,7 @@ def self.call(_plugin, _event, _args) end end - context "without a guard block" do + context 'without a guard block' do let(:contents) do ' callback(:start_end) do |plugin, event, args| @@ -456,20 +456,20 @@ def self.call(_plugin, _event, _args) callback(MyCustomCallback, [:start_begin, :run_all_begin])' end - it "fails" do + it 'fails' do expect { evaluator.call(contents) }.to raise_error(/guard block/i) end end end - describe "#logger" do + describe '#logger' do before do allow(Guard::UI).to receive(:options).and_return({}) allow(Guard::UI).to receive(:options=) end - describe "options" do - let(:contents) { "" } + describe 'options' do + let(:contents) { '' } before do evaluator.call(contents) @@ -477,8 +477,8 @@ def self.call(_plugin, _event, _args) subject { Guard::UI } - context "with logger level :error" do - let(:contents) { "logger level: :error" } + context 'with logger level :error' do + let(:contents) { 'logger level: :error' } it { is_expected.to have_received(:options=).with(level: :error) } end @@ -487,49 +487,49 @@ def self.call(_plugin, _event, _args) it { is_expected.to have_received(:options=).with(level: :error) } end - context "with logger template" do + context 'with logger template' do let(:contents) { 'logger template: \':message - :severity\'' } it do is_expected.to have_received(:options=). - with(template: ":message - :severity") + with(template: ':message - :severity') end end - context "with a logger time format" do + context 'with a logger time format' do let(:contents) { 'logger time_format: \'%Y\'' } it do - is_expected.to have_received(:options=).with(time_format: "%Y") + is_expected.to have_received(:options=).with(time_format: '%Y') end end - context "with a logger only filter from a symbol" do - let(:contents) { "logger only: :cucumber" } + context 'with a logger only filter from a symbol' do + let(:contents) { 'logger only: :cucumber' } it { is_expected.to have_received(:options=).with(only: /cucumber/i) } end - context "with logger only filter from a string" do + context 'with logger only filter from a string' do 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 + context 'with logger only filter from an array of symbols and string' do let(:contents) { 'logger only: [:rspec, \'cucumber\']' } it do is_expected.to have_received(:options=).with(only: /rspec|cucumber/i) end end - context "with logger except filter from a symbol" do - let(:contents) { "logger except: :jasmine" } + context 'with logger except filter from a symbol' do + let(:contents) { 'logger except: :jasmine' } it { is_expected.to have_received(:options=).with(except: /jasmine/i) } end - context "with logger except filter from a string" do + context 'with logger except filter from a string' do 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 + context 'with logger except filter from array of symbols and string' do let(:contents) { 'logger except: [:rspec, \'cucumber\', :jasmine]' } it do is_expected.to have_received(:options=). @@ -538,35 +538,35 @@ def self.call(_plugin, _event, _args) end end - context "with invalid options" do - context "for the log level" do - let(:contents) { "logger level: :baz" } + context 'with invalid options' do + context 'for the log level' do + let(:contents) { 'logger level: :baz' } - it "shows a warning" do + it 'shows a warning' do expect(Guard::UI).to receive(:warning). - with "Invalid log level `baz` ignored."\ - " Please use either :debug, :info, :warn or :error." + with 'Invalid log level `baz` ignored.'\ + ' Please use either :debug, :info, :warn or :error.' evaluator.call(contents) end - it "does not set the invalid value" do + it 'does not set the invalid value' do expect(Guard::UI).to receive(:options=).with({}) evaluator.call(contents) end end - context "when having both the :only and :except options" do - let(:contents) { "logger only: :jasmine, except: :rspec" } + context 'when having both the :only and :except options' do + let(:contents) { 'logger only: :jasmine, except: :rspec' } - it "shows a warning" do + it 'shows a warning' do expect(Guard::UI).to receive(:warning). - with "You cannot specify the logger options"\ - " :only and :except at the same time." + with 'You cannot specify the logger options'\ + ' :only and :except at the same time.' evaluator.call(contents) end - it "removes the options" do + it 'removes the options' do expect(Guard::UI).to receive(:options=).with({}) evaluator.call(contents) end @@ -574,9 +574,9 @@ def self.call(_plugin, _event, _args) end end - describe "#scope" do - context "with any parameters" do - let(:contents) { "scope plugins: [:foo, :bar]" } + describe '#scope' do + context 'with any parameters' do + let(:contents) { 'scope plugins: [:foo, :bar]' } it "sets the guardfile's default scope" do expect(session).to receive(:guardfile_scope).with(plugins: [:foo, :bar]) @@ -585,37 +585,37 @@ def self.call(_plugin, _event, _args) end end - describe "#directories" do - context "with valid directories" do - let(:contents) { "directories %w(foo bar)" } + describe '#directories' do + context 'with valid directories' do + let(:contents) { 'directories %w(foo bar)' } before do - allow(Dir).to receive(:exist?).with("foo").and_return(true) - allow(Dir).to receive(:exist?).with("bar").and_return(true) + allow(Dir).to receive(:exist?).with('foo').and_return(true) + allow(Dir).to receive(:exist?).with('bar').and_return(true) end - it "sets the watchdirs to given values" do + it 'sets the watchdirs to given values' do expect(session).to receive(:watchdirs=).with(%w(foo bar)) evaluator.call(contents) end end - context "with no parameters" do - let(:contents) { "directories []" } + context 'with no parameters' do + let(:contents) { 'directories []' } - it "sets the watchdirs to empty" do + it 'sets the watchdirs to empty' do expect(session).to receive(:watchdirs=).with([]) evaluator.call(contents) end end - context "with non-existing directory" do + context 'with non-existing directory' do let(:contents) { "directories ['foo']" } before do - allow(Dir).to receive(:exist?).with("foo").and_return(false) + allow(Dir).to receive(:exist?).with('foo').and_return(false) end - it "fails with an error" do + it 'fails with an error' do expect(session).to_not receive(:watchdirs=) expect do evaluator.call(contents) @@ -624,18 +624,18 @@ def self.call(_plugin, _event, _args) end end - describe "#clear" do - context "with clear :off" do - let(:contents) { "clearing :off" } - it "disables clearing the screen after every task" do + describe '#clear' do + context 'with clear :off' do + let(:contents) { 'clearing :off' } + it 'disables clearing the screen after every task' do expect(session).to receive(:clearing).with(false) evaluator.call(contents) end end - context "with clear :on" do - let(:contents) { "clearing :on" } - it "enabled clearing the screen after every task" do + context 'with clear :on' do + let(:contents) { 'clearing :on' } + it 'enabled clearing the screen after every task' do expect(session).to receive(:clearing).with(true) evaluator.call(contents) end diff --git a/spec/lib/guard/group_spec.rb b/spec/lib/guard/group_spec.rb index e516e6f12..2577736c3 100644 --- a/spec/lib/guard/group_spec.rb +++ b/spec/lib/guard/group_spec.rb @@ -1,4 +1,4 @@ -require "guard/group" +require 'guard/group' RSpec.describe Guard::Group do subject { described_class.new(name, options) } @@ -6,29 +6,29 @@ let(:name) { :foo } let(:options) { {} } - describe "#name" do + describe '#name' do specify { expect(subject.name).to eq :foo } - context "when initialized from a string" do - let(:name) { "foo" } + context 'when initialized from a string' do + let(:name) { 'foo' } specify { expect(subject.name).to eq :foo } end end - describe "#options" do - context "when provided" do + describe '#options' do + context 'when provided' do let(:options) { { halt_on_fail: true } } specify { expect(subject.options).to eq options } end end - describe "#title" do - specify { expect(subject.title).to eq "Foo" } + describe '#title' do + specify { expect(subject.title).to eq 'Foo' } end - describe "#to_s" do + describe '#to_s' do specify do - expect(subject.to_s).to eq "#" + expect(subject.to_s).to eq '#' end end end diff --git a/spec/lib/guard/guardfile/evaluator_spec.rb b/spec/lib/guard/guardfile/evaluator_spec.rb index 6a1425d5c..c67a32ac8 100644 --- a/spec/lib/guard/guardfile/evaluator_spec.rb +++ b/spec/lib/guard/guardfile/evaluator_spec.rb @@ -1,22 +1,22 @@ -require "guard/guardfile/evaluator" +require 'guard/guardfile/evaluator' # TODO: shouldn't be necessary -require "guard" +require 'guard' RSpec.describe Guard::Guardfile::Evaluator do let(:options) { {} } subject { described_class.new(options) } - let!(:local_guardfile) { (Pathname.pwd + "Guardfile").to_s } - let!(:home_guardfile) { (Pathname("~").expand_path + ".Guardfile").to_s } - let!(:home_config) { (Pathname("~").expand_path + ".guard.rb").to_s } + let!(:local_guardfile) { (Pathname.pwd + 'Guardfile').to_s } + let!(:home_guardfile) { (Pathname('~').expand_path + '.Guardfile').to_s } + let!(:home_config) { (Pathname('~').expand_path + '.guard.rb').to_s } - let(:valid_guardfile_string) { "group :foo; do guard :bar; end; end; " } + let(:valid_guardfile_string) { 'group :foo; do guard :bar; end; end; ' } - let(:dsl) { instance_double("Guard::Dsl") } + let(:dsl) { instance_double('Guard::Dsl') } let(:rel_guardfile) do - Pathname("../relative_path_to_Guardfile").expand_path.to_s + Pathname('../relative_path_to_Guardfile').expand_path.to_s end before do @@ -25,24 +25,24 @@ allow(dsl).to receive(:instance_eval) end - describe ".evaluate" do - describe "error cases" do - context "with an invalid Guardfile" do - let(:options) { { contents: "guard :foo Bad Guardfile" } } + describe '.evaluate' do + describe 'error cases' do + context 'with an invalid Guardfile' do + let(:options) { { contents: 'guard :foo Bad Guardfile' } } - it "displays an error message and raises original exception" do + 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:") + 'Invalid Guardfile, original error is:') expect { subject.evaluate }.to raise_error(Guard::Dsl::Error) end end - context "with no Guardfile at all" do - it "displays an error message and exits" do + context 'with no Guardfile at all' do + it 'displays an error message and exits' do stub_guardfile stub_user_guardfile stub_user_project_guardfile @@ -52,47 +52,47 @@ end end - context "with a problem reading a Guardfile" do - let(:path) { File.expand_path("Guardfile") } + context 'with a problem reading a Guardfile' do + let(:path) { File.expand_path('Guardfile') } before do stub_user_project_guardfile - stub_guardfile(" ") do - fail Errno::EACCES.new("permission error") + stub_guardfile(' ') do + fail Errno::EACCES.new('permission error') end end - it "displays an error message and exits" do + it 'displays an error message and exits' do expect(Guard::UI).to receive(:error).with(/^Error reading file/) expect { subject.evaluate }.to raise_error(SystemExit) end end - context "with empty Guardfile content" do - let(:options) { { contents: "" } } + context 'with empty Guardfile content' do + let(:options) { { contents: '' } } - it "displays an error message about no plugins" do + it 'displays an error message about no plugins' do stub_user_guard_rb - stub_guardfile(" ") - allow(dsl).to receive(:evaluate).with("", "", 1) + stub_guardfile(' ') + allow(dsl).to receive(:evaluate).with('', '', 1) expect { subject.evaluate }. to raise_error(Guard::Guardfile::Evaluator::NoPluginsError) end end - context "when provided :contents is nil" do + context 'when provided :contents is nil' do before do # Anything - stub_guardfile("guard :foo") + stub_guardfile('guard :foo') stub_user_guard_rb stub_user_project_guardfile stub_user_guardfile end - it "does not raise error and skip it" do - allow(dsl).to receive(:evaluate).with("guard :foo", anything, 1) + it 'does not raise error and skip it' do + allow(dsl).to receive(:evaluate).with('guard :foo', anything, 1) expect(Guard::UI).to_not receive(:error) expect do @@ -101,55 +101,55 @@ end end - context "with a non-existing Guardfile given" do - let(:non_existing_path) { "/non/existing/path/to/Guardfile" } + context 'with a non-existing Guardfile given' do + let(:non_existing_path) { '/non/existing/path/to/Guardfile' } let(:options) { { guardfile: non_existing_path } } before do stub_file(non_existing_path) end - it "raises error" do + it 'raises error' do expect { subject.evaluate }. to raise_error(Guard::Guardfile::Evaluator::NoCustomGuardfile) end end end - describe "selection of the Guardfile data contents" do - context "with a valid :contents option" do + describe 'selection of the Guardfile data contents' do + context 'with a valid :contents option' do before do stub_user_guard_rb allow(dsl).to receive(:evaluate) end - context "with inline content and other Guardfiles available" do - let(:inline_code) { "guard :foo" } + context 'with inline content and other Guardfiles available' do + let(:inline_code) { 'guard :foo' } let(:options) do { contents: inline_code, - guardfile: "/abc/Guardfile" + guardfile: '/abc/Guardfile' } end before do - stub_file("/abc/Guardfile", "guard :bar") - stub_guardfile("guard :baz") - stub_user_guardfile("guard :buz") + stub_file('/abc/Guardfile', 'guard :bar') + stub_guardfile('guard :baz') + stub_user_guardfile('guard :buz') end - it "gives ultimate precedence to inline content" do - expect(dsl).to receive(:evaluate).with(inline_code, "", 1) + it 'gives ultimate precedence to inline content' do + expect(dsl).to receive(:evaluate).with(inline_code, '', 1) subject.evaluate end end end - context "with the :guardfile option" do - let(:options) { { guardfile: "../relative_path_to_Guardfile" } } + context 'with the :guardfile option' do + let(:options) { { guardfile: '../relative_path_to_Guardfile' } } before do - stub_file(File.expand_path("../relative_path_to_Guardfile"), + stub_file(File.expand_path('../relative_path_to_Guardfile'), valid_guardfile_string) allow(dsl).to receive(:evaluate). with(valid_guardfile_string, anything, 1) @@ -158,26 +158,26 @@ end end - describe "#inline?" do + describe '#inline?' do before do allow(dsl).to receive(:evaluate) - stub_guardfile("guard :bar") + stub_guardfile('guard :bar') stub_user_guard_rb subject.evaluate end - context "when content is provided" do - let(:options) { { guardfile_contents: "guard :foo" } } + context 'when content is provided' do + let(:options) { { guardfile_contents: 'guard :foo' } } it { is_expected.to be_inline } end - context "when no content is provided" do + context 'when no content is provided' do let(:options) { {} } it { is_expected.to_not be_inline } end end - describe ".guardfile_include?" do + describe '.guardfile_include?' do subject do evaluator = described_class.new(options) evaluator.evaluate @@ -193,27 +193,27 @@ stub_user_guard_rb end - context "when plugin is present" do + context 'when plugin is present' do let(:options) { { contents: 'guard "test" {watch("c")}' } } - it "returns true" do + it 'returns true' do allow(dsl_reader). - to receive(:evaluate).with('guard "test" {watch("c")}', "", 1) + 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") + allow(dsl_reader).to receive(:plugin_names).and_return(['test']) + expect(subject).to be_guardfile_include('test') end end - context "when plugin is not present" do + context 'when plugin is not present' do let(:options) { { contents: 'guard "other" {watch("c")}' } } - it "returns false" do + it 'returns false' do allow(dsl_reader). - to receive(:evaluate).with('guard "test" {watch("c")}', "", 1) + 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") + allow(dsl_reader).to receive(:plugin_names).and_return(['other']) + expect(subject).to_not be_guardfile_include('test') end end end diff --git a/spec/lib/guard/guardfile/generator_spec.rb b/spec/lib/guard/guardfile/generator_spec.rb index 536e14604..280aca844 100644 --- a/spec/lib/guard/guardfile/generator_spec.rb +++ b/spec/lib/guard/guardfile/generator_spec.rb @@ -1,23 +1,23 @@ -require "guard/guardfile/generator" +require 'guard/guardfile/generator' RSpec.describe Guard::Guardfile::Generator do - let(:plugin_util) { instance_double("Guard::PluginUtil") } + let(:plugin_util) { instance_double('Guard::PluginUtil') } let(:guardfile_generator) { described_class.new } - it "has a valid Guardfile template" do + it 'has a valid Guardfile template' do allow(File).to receive(:exist?). with(described_class::GUARDFILE_TEMPLATE).and_call_original expect(File.exist?(described_class::GUARDFILE_TEMPLATE)).to be_truthy end - describe "#create_guardfile" do - context "with an existing Guardfile" do + describe '#create_guardfile' do + context 'with an existing Guardfile' do before do allow_any_instance_of(Pathname).to receive(:exist?).and_return(true) end - it "does not copy the Guardfile template or notify the user" do + it 'does not copy the Guardfile template or notify the user' do expect(::Guard::UI).to_not receive(:info) expect(FileUtils).to_not receive(:cp) begin @@ -26,7 +26,7 @@ end end - it "does not display information" do + it 'does not display information' do expect(::Guard::UI).to_not receive(:info) begin subject.create_guardfile @@ -34,7 +34,7 @@ end end - it "displays an error message" do + it 'displays an error message' do expect(::Guard::UI).to receive(:error). with(%r{Guardfile already exists at .*/Guardfile}) begin @@ -43,24 +43,24 @@ end end - it "aborts" do + it 'aborts' do expect { subject.create_guardfile }.to raise_error(SystemExit) end end - context "without an existing Guardfile" do + context 'without an existing Guardfile' do before do allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) allow(FileUtils).to receive(:cp) end - it "does not display any kind of error or abort" do + it 'does not display any kind of error or abort' do expect(::Guard::UI).to_not receive(:error) expect(described_class).to_not receive(:abort) described_class.new.create_guardfile end - it "copies the Guardfile template and notifies the user" do + it 'copies the Guardfile template and notifies the user' do expect(::Guard::UI).to receive(:info) expect(FileUtils).to receive(:cp) @@ -69,40 +69,40 @@ end end - describe "#initialize_template" do - context "with an installed Guard implementation" do + describe '#initialize_template' do + context 'with an installed Guard implementation' do before do expect(Guard::PluginUtil).to receive(:new) { plugin_util } expect(plugin_util).to receive(:plugin_class) do - double("Guard::Foo").as_null_object + double('Guard::Foo').as_null_object end end - it "initializes the Guard" do + it 'initializes the Guard' do expect(plugin_util).to receive(:add_to_guardfile) - described_class.new.initialize_template("foo") + described_class.new.initialize_template('foo') end end - context "with a user defined template" do - let(:template) { File.join(described_class::HOME_TEMPLATES, "/bar") } + context 'with a user defined template' do + let(:template) { File.join(described_class::HOME_TEMPLATES, '/bar') } - it "copies the Guardfile template and initializes the Guard" do + it 'copies the Guardfile template and initializes the Guard' do expect(IO).to receive(:read). - with(template).and_return "Template content" + with(template).and_return 'Template content' expected = "\nTemplate content\n" expect(IO).to receive(:binwrite). - with("Guardfile", expected, open_args: ["a"]) + 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"). + allow(Guard::PluginUtil).to receive(:new).with('bar'). and_return(plugin_util) - described_class.new.initialize_template("bar") + described_class.new.initialize_template('bar') end end @@ -110,27 +110,27 @@ before do expect(::Guard::PluginUtil).to receive(:new) { plugin_util } allow(plugin_util).to receive(:plugin_class) { nil } - path = File.expand_path("~/.guard/templates/foo") + path = File.expand_path('~/.guard/templates/foo') expect(IO).to receive(:read).with(path) do fail Errno::ENOENT end end - it "notifies the user about the problem" do - expect { described_class.new.initialize_template("foo") }. + it 'notifies the user about the problem' do + expect { described_class.new.initialize_template('foo') }. to raise_error(Guard::Guardfile::Generator::Error) end end end - describe "#initialize_all_templates" do + describe '#initialize_all_templates' do let(:plugins) { %w(rspec spork phpunit) } before do expect(::Guard::PluginUtil).to receive(:plugin_names) { plugins } end - it "calls Guard.initialize_template on all installed plugins" do + it 'calls Guard.initialize_template on all installed plugins' do plugins.each do |g| expect(subject).to receive(:initialize_template).with(g) end diff --git a/spec/lib/guard/interactor_spec.rb b/spec/lib/guard/interactor_spec.rb index 8cfc5d645..66dcc9750 100644 --- a/spec/lib/guard/interactor_spec.rb +++ b/spec/lib/guard/interactor_spec.rb @@ -1,18 +1,18 @@ -require "guard/interactor" +require 'guard/interactor' # TODO: this shouldn't be necessary -require "guard/jobs/pry_wrapper" -require "guard/jobs/sleep" +require 'guard/jobs/pry_wrapper' +require 'guard/jobs/sleep' RSpec.describe Guard::Interactor do - let!(:pry_interactor) { instance_double("Guard::Jobs::PryWrapper") } - let!(:sleep_interactor) { instance_double("Guard::Jobs::Sleep") } - let(:pry_class) { class_double("Guard::Jobs::PryWrapper") } - let(:sleep_class) { class_double("Guard::Jobs::Sleep") } + let!(:pry_interactor) { instance_double('Guard::Jobs::PryWrapper') } + let!(:sleep_interactor) { instance_double('Guard::Jobs::Sleep') } + let(:pry_class) { class_double('Guard::Jobs::PryWrapper') } + let(:sleep_class) { class_double('Guard::Jobs::Sleep') } before do - stub_const("Guard::Jobs::PryWrapper", pry_class) - stub_const("Guard::Jobs::Sleep", sleep_class) + stub_const('Guard::Jobs::PryWrapper', pry_class) + stub_const('Guard::Jobs::Sleep', sleep_class) allow(Guard::Jobs::PryWrapper).to receive(:new).and_return(pry_interactor) allow(Guard::Jobs::Sleep).to receive(:new).and_return(sleep_interactor) @@ -23,87 +23,87 @@ after { described_class.enabled = @interactor_enabled } - describe ".enabled & .enabled=" do - it "returns true by default" do + describe '.enabled & .enabled=' do + it 'returns true by default' do expect(described_class).to be_enabled end - context "interactor not enabled" do + context 'interactor not enabled' do before { described_class.enabled = false } - it "returns false" do + it 'returns false' do expect(described_class).to_not be_enabled end end end - describe ".options & .options=" do + describe '.options & .options=' do before { described_class.options = nil } - it "returns {} by default" do + it 'returns {} by default' do expect(described_class.options).to eq({}) end - context "options set to { foo: :bar }" do + context 'options set to { foo: :bar }' do before { described_class.options = { foo: :bar } } - it "returns { foo: :bar }" do + it 'returns { foo: :bar }' do expect(described_class.options).to eq(foo: :bar) end end end - context "when enabled" do + context 'when enabled' do before { described_class.enabled = true } - describe "#foreground" do - it "starts Pry" do + describe '#foreground' do + it 'starts Pry' do expect(pry_interactor).to receive(:foreground) subject.foreground end end - describe "#background" do - it "hides Pry" do + describe '#background' do + it 'hides Pry' do expect(pry_interactor).to receive(:background) subject.background end end - describe "#handle_interrupt" do - it "interrupts Pry" do + describe '#handle_interrupt' do + it 'interrupts Pry' do expect(pry_interactor).to receive(:handle_interrupt) subject.handle_interrupt end end end - context "when disabled" do + context 'when disabled' do before { described_class.enabled = false } - describe "#foreground" do - it "sleeps" do + describe '#foreground' do + it 'sleeps' do expect(sleep_interactor).to receive(:foreground) subject.foreground end end - describe "#background" do - it "wakes up from sleep" do + describe '#background' do + it 'wakes up from sleep' do expect(sleep_interactor).to receive(:background) subject.background end end - describe "#handle_interrupt" do - it "interrupts sleep" do + describe '#handle_interrupt' do + it 'interrupts sleep' do expect(sleep_interactor).to receive(:handle_interrupt) subject.handle_interrupt end end end - describe "job selection" do + describe 'job selection' do subject do Guard::Interactor.new(no_interactions) Guard::Interactor @@ -113,12 +113,12 @@ Guard::Interactor.enabled = dsl_enabled end - context "when enabled from the DSL" do + context 'when enabled from the DSL' do let(:dsl_enabled) { true } - context "when enabled from the commandline" do + context 'when enabled from the commandline' do let(:no_interactions) { false } - it "uses only pry" do + it 'uses only pry' do expect(pry_class).to receive(:new) expect(sleep_class).to_not receive(:new) subject @@ -126,9 +126,9 @@ it { is_expected.to be_enabled } end - context "when disabled from the commandline" do + context 'when disabled from the commandline' do let(:no_interactions) { true } - it "uses only sleeper" do + it 'uses only sleeper' do expect(pry_class).to_not receive(:new) expect(sleep_class).to receive(:new) subject @@ -139,12 +139,12 @@ end end - context "when disabled from the DSL" do + context 'when disabled from the DSL' do let(:dsl_enabled) { false } - context "when enabled from the commandline" do + context 'when enabled from the commandline' do let(:no_interactions) { false } - it "uses only sleeper" do + it 'uses only sleeper' do expect(pry_class).to_not receive(:new) expect(sleep_class).to receive(:new) subject @@ -152,9 +152,9 @@ it { is_expected.to_not be_enabled } end - context "when disabled from the commandline" do + context 'when disabled from the commandline' do let(:no_interactions) { true } - it "uses only sleeper" do + it 'uses only sleeper' do expect(pry_class).to_not receive(:new) expect(sleep_class).to receive(:new) subject diff --git a/spec/lib/guard/internals/debugging_spec.rb b/spec/lib/guard/internals/debugging_spec.rb index 02fd1242d..f71f3ab79 100644 --- a/spec/lib/guard/internals/debugging_spec.rb +++ b/spec/lib/guard/internals/debugging_spec.rb @@ -1,4 +1,4 @@ -require "guard/internals/debugging" +require 'guard/internals/debugging' RSpec.describe Guard::Internals::Debugging do let(:null) { IO::NULL } @@ -6,8 +6,8 @@ let(:tracing) { class_spy(::Guard::Internals::Tracing) } before do - stub_const("::Guard::Internals::Tracing", tracing) - stub_const("::Guard::UI", ui) + stub_const('::Guard::Internals::Tracing', tracing) + stub_const('::Guard::UI', ui) allow(ui).to receive(:debug) allow(ui).to receive(:level=) allow(Thread).to receive(:abort_on_exception=) @@ -17,93 +17,93 @@ described_class.send(:_reset) end - describe "#start" do - it "traces Kernel.system" do + describe '#start' do + it 'traces Kernel.system' do expect(tracing).to receive(:trace).with(Kernel, :system) do |*_, &block| - expect(ui).to receive(:debug).with("Command execution: foo") - block.call "foo" + expect(ui).to receive(:debug).with('Command execution: foo') + block.call 'foo' end described_class.start end - it "traces Kernel.`" do + it 'traces Kernel.`' do expect(tracing).to receive(:trace).with(Kernel, :`) do |*_, &block| - expect(ui).to receive(:debug).with("Command execution: foo") - block.call("foo") + expect(ui).to receive(:debug).with('Command execution: foo') + block.call('foo') end described_class.start end - it "traces Open3.popen3" do + it 'traces Open3.popen3' do expect(tracing).to receive(:trace).with(Open3, :popen3) do |*_, &block| - expect(ui).to receive(:debug).with("Command execution: foo") - block.call("foo") + expect(ui).to receive(:debug).with('Command execution: foo') + block.call('foo') end described_class.start end - it "traces Kernel.spawn" do + it 'traces Kernel.spawn' do expect(tracing).to receive(:trace).with(Kernel, :spawn) do |*_, &block| - expect(ui).to receive(:debug).with("Command execution: foo") - block.call("foo") + expect(ui).to receive(:debug).with('Command execution: foo') + block.call('foo') end described_class.start end - context "when not started" do + context 'when not started' do before { described_class.start } - it "sets logger to debug" do + it 'sets logger to debug' do expect(ui).to have_received(:level=).with(Logger::DEBUG) end - it "makes threads abort on exceptions" do + it 'makes threads abort on exceptions' do expect(Thread).to have_received(:abort_on_exception=).with(true) end end - context "when already started" do + context 'when already started' do before do allow(tracing).to receive(:trace) described_class.start end - it "does not set log level" do + it 'does not set log level' do expect(ui).to_not receive(:level=) described_class.start end end end - describe "#stop" do - context "when already started" do + describe '#stop' do + context 'when already started' do before do described_class.start described_class.stop end - it "sets logger level to info" do + it 'sets logger level to info' do expect(ui).to have_received(:level=).with(Logger::INFO) end - it "untraces Kernel.system" do + it 'untraces Kernel.system' do expect(tracing).to have_received(:untrace).with(Kernel, :system) end - it "untraces Kernel.`" do + it 'untraces Kernel.`' do expect(tracing).to have_received(:untrace).with(Kernel, :`) end - it "untraces Open3.popen3" do + it 'untraces Open3.popen3' do expect(tracing).to have_received(:untrace).with(Kernel, :popen3) end end - context "when not started" do - it "does not set logger level" do + context 'when not started' do + it 'does not set logger level' do described_class.stop expect(ui).to_not have_received(:level=) end diff --git a/spec/lib/guard/internals/groups_spec.rb b/spec/lib/guard/internals/groups_spec.rb index d375c3673..73c4f3296 100644 --- a/spec/lib/guard/internals/groups_spec.rb +++ b/spec/lib/guard/internals/groups_spec.rb @@ -1,24 +1,24 @@ -require "guard/internals/groups" +require 'guard/internals/groups' RSpec.describe Guard::Internals::Groups do - describe "#all" do - let(:common) { instance_double("Guard::Group", name: :common) } - let(:default) { instance_double("Guard::Group", name: :default) } + describe '#all' do + let(:common) { instance_double('Guard::Group', name: :common) } + let(:default) { instance_double('Guard::Group', name: :default) } before do allow(Guard::Group).to receive(:new).with(:common).and_return(common) allow(Guard::Group).to receive(:new).with(:default).and_return(default) end - context "with only default groups" do - it "initializes the groups" do + context 'with only default groups' do + it 'initializes the groups' do expect(subject.all.map(&:name)).to eq [:common, :default] end end - context "with existing groups" do - let(:frontend) { instance_double("Guard::Group", name: :frontend) } - let(:backend) { instance_double("Guard::Group", name: :backend) } + context 'with existing groups' do + let(:frontend) { instance_double('Guard::Group', name: :frontend) } + let(:backend) { instance_double('Guard::Group', name: :backend) } before do allow(Guard::Group).to receive(:new).with(:frontend, {}). @@ -31,39 +31,39 @@ subject.add(:backend) end - context "with no arguments" do + context 'with no arguments' do let(:args) { [] } - it "returns all groups" do + it 'returns all groups' do expect(subject.all(*args)).to eq [common, default, frontend, backend] end end - context "with a string argument" do - it "returns an array of groups if plugins are found" do - expect(subject.all("backend")).to eq [backend] + context 'with a string argument' do + it 'returns an array of groups if plugins are found' do + expect(subject.all('backend')).to eq [backend] end end - context "with a symbol argument matching a group" do - it "returns an array of groups if plugins are found" do + context 'with a symbol argument matching a group' do + it 'returns an array of groups if plugins are found' do expect(subject.all(:backend)).to eq [backend] end end - context "with a symbol argument not matching a group" do - it "returns an empty array when no group is found" do + context 'with a symbol argument not matching a group' do + it 'returns an empty array when no group is found' do expect(subject.all(:foo)).to be_empty end end - context "with a regexp argument matching a group" do - it "returns an array of groups" do + context 'with a regexp argument matching a group' do + it 'returns an array of groups' do expect(subject.all(/^back/)).to eq [backend] end end - context "with a regexp argument not matching a group" do - it "returns an empty array when no group is found" do + context 'with a regexp argument not matching a group' do + it 'returns an empty array when no group is found' do expect(subject.all(/back$/)).to be_empty end end @@ -71,47 +71,47 @@ end # TOOD: test adding with options - describe "#add" do - let(:common) { instance_double("Guard::Group", name: :common) } - let(:default) { instance_double("Guard::Group", name: :default) } + describe '#add' do + let(:common) { instance_double('Guard::Group', name: :common) } + let(:default) { instance_double('Guard::Group', name: :default) } before do allow(Guard::Group).to receive(:new).with(:common).and_return(common) allow(Guard::Group).to receive(:new).with(:default).and_return(default) end - context "with existing groups" do - let(:frontend) { instance_double("Guard::Group", name: :frontend) } - let(:backend) { instance_double("Guard::Group", name: :backend) } + context 'with existing groups' do + let(:frontend) { instance_double('Guard::Group', name: :frontend) } + let(:backend) { instance_double('Guard::Group', name: :backend) } before do - allow(Guard::Group).to receive(:new).with("frontend", {}). + allow(Guard::Group).to receive(:new).with('frontend', {}). and_return(frontend) - subject.add("frontend") + subject.add('frontend') end - it "add the given group" do - subject.add("frontend") + it 'add the given group' do + subject.add('frontend') expect(subject.all).to match_array([common, default, frontend]) end - it "add the given group with options" do - subject.add("frontend", foo: :bar) + it 'add the given group with options' do + subject.add('frontend', foo: :bar) expect(subject.all).to match_array([common, default, frontend]) end # TODO: what if group is added multiple times with different options? - context "with an existing group" do - before { subject.add("frontend") } + context 'with an existing group' do + before { subject.add('frontend') } - it "does not add duplicate groups when name is a string" do - subject.add("frontend") + it 'does not add duplicate groups when name is a string' do + subject.add('frontend') expect(subject.all).to match_array([common, default, frontend]) end - it "does not add duplicate groups when name is a symbol" do + it 'does not add duplicate groups when name is a symbol' do subject.add(:frontend) expect(subject.all).to match_array([common, default, frontend]) end diff --git a/spec/lib/guard/internals/plugins_spec.rb b/spec/lib/guard/internals/plugins_spec.rb index 7dfba5b8e..8faac0269 100644 --- a/spec/lib/guard/internals/plugins_spec.rb +++ b/spec/lib/guard/internals/plugins_spec.rb @@ -1,53 +1,53 @@ -require "guard/internals/plugins" +require 'guard/internals/plugins' RSpec.describe Guard::Internals::Plugins do def stub_plugin(name, group) - instance_double("Guard::Plugin", name: name, group: group) + instance_double('Guard::Plugin', name: name, group: group) end # TODO: all this is crazy - let(:frontend) { instance_double("Guard::Group", name: :frontend) } - let(:backend) { instance_double("Guard::Group", name: :backend) } + let(:frontend) { instance_double('Guard::Group', name: :frontend) } + let(:backend) { instance_double('Guard::Group', name: :backend) } - let(:foo_bar_frontend) { stub_plugin("foobar", frontend) } - let(:foo_baz_frontend) { stub_plugin("foobaz", frontend) } - let(:foo_bar_backend) { stub_plugin("foobar", backend) } - let(:foo_baz_backend) { stub_plugin("foobaz", backend) } + let(:foo_bar_frontend) { stub_plugin('foobar', frontend) } + let(:foo_baz_frontend) { stub_plugin('foobaz', frontend) } + let(:foo_bar_backend) { stub_plugin('foobar', backend) } + let(:foo_baz_backend) { stub_plugin('foobaz', backend) } - let(:pu_foobar) { instance_double("Guard::PluginUtil") } - let(:pu_foobaz) { instance_double("Guard::PluginUtil") } + let(:pu_foobar) { instance_double('Guard::PluginUtil') } + let(:pu_foobaz) { instance_double('Guard::PluginUtil') } before do - allow(Guard::PluginUtil).to receive(:new).with("foobar"). + allow(Guard::PluginUtil).to receive(:new).with('foobar'). and_return(pu_foobar) - allow(Guard::PluginUtil).to receive(:new).with("foobaz"). + allow(Guard::PluginUtil).to receive(:new).with('foobaz'). and_return(pu_foobaz) - allow(pu_foobar).to receive(:initialize_plugin).with(group: "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"). + 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"). + 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"). + allow(pu_foobaz).to receive(:initialize_plugin).with(group: 'backend'). and_return(foo_baz_backend) end - describe "#all" do + describe '#all' do before do - subject.add("foobar", group: "frontend") - subject.add("foobaz", group: "frontend") - subject.add("foobar", group: "backend") - subject.add("foobaz", group: "backend") + subject.add('foobar', group: 'frontend') + subject.add('foobaz', group: 'frontend') + subject.add('foobar', group: 'backend') + subject.add('foobaz', group: 'backend') end - context "with no arguments" do + context 'with no arguments' do let(:args) { [] } - it "returns all plugins" do + it 'returns all plugins' do expect(subject.all(*args)).to eq [ foo_bar_frontend, foo_baz_frontend, @@ -57,75 +57,75 @@ def stub_plugin(name, group) end end - context "find a plugin by as string" do - it "returns an array of plugins if plugins are found" do - expect(subject.all("foo-bar")). + 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]) end end - context "find a plugin by as symbol" do - it "returns an array of plugins if plugins are found" do + 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]) end - it "returns an empty array when no plugin is found" do - expect(subject.all("foo-foo")).to be_empty + it 'returns an empty array when no plugin is found' do + expect(subject.all('foo-foo')).to be_empty end end - context "find plugins matching a regexp" do - it "returns an array of plugins if plugins are found" do + 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]) end - it "returns an empty array when no plugin is found" do + it 'returns an empty array when no plugin is found' do expect(subject.all(/foo$/)).to be_empty end end - 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")). + 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] end end - context "find plugins by their group as a symbol" do - it "returns an array of plugins if plugins are found" do + 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] end - it "returns an empty array when no plugin is found" do + it 'returns an empty array when no plugin is found' do expect(subject.all(group: :unknown)).to be_empty end end - 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")). + 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] end - it "returns an empty array when no plugin is found" do + it 'returns an empty array when no plugin is found' do expect(subject.all(group: :unknown, name: :'foo-baz')). to be_empty end end end - describe "#remove" do + describe '#remove' do before do - subject.add("foobar", group: "frontend") - subject.add("foobaz", group: "frontend") - subject.add("foobar", group: "backend") - subject.add("foobaz", group: "backend") + subject.add('foobar', group: 'frontend') + subject.add('foobaz', group: 'frontend') + subject.add('foobar', group: 'backend') + subject.add('foobaz', group: 'backend') end - it "removes given plugin" do + it 'removes given plugin' do subject.remove(foo_bar_frontend) expect(subject.all).to match_array [ diff --git a/spec/lib/guard/internals/scope_spec.rb b/spec/lib/guard/internals/scope_spec.rb index 353fc84ba..d46b2b082 100644 --- a/spec/lib/guard/internals/scope_spec.rb +++ b/spec/lib/guard/internals/scope_spec.rb @@ -1,29 +1,29 @@ -require "guard/internals/scope" +require 'guard/internals/scope' RSpec.describe Guard::Internals::Scope do - let(:session) { instance_double("Guard::Internals::Session") } - let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double('Guard::Internals::Session') } + let(:state) { instance_double('Guard::Internals::State') } - let(:groups) { instance_double("Guard::Internals::Groups") } - let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:groups) { instance_double('Guard::Internals::Groups') } + let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:foo_plugin) { instance_double("Guard::Plugin", name: :foo) } - let(:bar_plugin) { instance_double("Guard::Plugin", name: :bar) } - let(:baz_plugin) { instance_double("Guard::Plugin", name: :baz) } + let(:foo_plugin) { instance_double('Guard::Plugin', name: :foo) } + let(:bar_plugin) { instance_double('Guard::Plugin', name: :bar) } + let(:baz_plugin) { instance_double('Guard::Plugin', name: :baz) } - let(:foo_group) { instance_double("Guard::Group", name: :foo) } - let(:bar_group) { instance_double("Guard::Group", name: :bar) } - let(:baz_group) { instance_double("Guard::Group", name: :baz) } + let(:foo_group) { instance_double('Guard::Group', name: :foo) } + let(:bar_group) { instance_double('Guard::Group', name: :bar) } + let(:baz_group) { instance_double('Guard::Group', name: :baz) } before do - allow(groups).to receive(:all).with("foo").and_return([foo_group]) - allow(groups).to receive(:all).with("bar").and_return([bar_group]) - allow(groups).to receive(:all).with("baz").and_return([baz_group]) + allow(groups).to receive(:all).with('foo').and_return([foo_group]) + allow(groups).to receive(:all).with('bar').and_return([bar_group]) + allow(groups).to receive(:all).with('baz').and_return([baz_group]) allow(groups).to receive(:all).with(:baz).and_return([baz_group]) - allow(plugins).to receive(:all).with("foo").and_return([foo_plugin]) - allow(plugins).to receive(:all).with("bar").and_return([bar_plugin]) - allow(plugins).to receive(:all).with("baz").and_return([baz_plugin]) + allow(plugins).to receive(:all).with('foo').and_return([foo_plugin]) + allow(plugins).to receive(:all).with('bar').and_return([bar_plugin]) + allow(plugins).to receive(:all).with('baz').and_return([baz_plugin]) allow(plugins).to receive(:all).with(:baz).and_return([baz_plugin]) allow(session).to receive(:cmdline_plugins).and_return([]) @@ -39,7 +39,7 @@ end # TODO: move to Session? - describe "#to_hash" do + describe '#to_hash' do [:group, :plugin].each do |scope| describe scope.inspect do let(:hash) do @@ -47,38 +47,38 @@ end # NOTE: interactor returns objects - context "when set from interactor" do + context 'when set from interactor' do before do stub_obj = send("baz_#{scope}") subject.from_interactor(:"#{scope}s" => stub_obj) end - it "uses interactor scope" do - expect(hash).to contain_exactly("baz") + it 'uses interactor scope' do + expect(hash).to contain_exactly('baz') end end - context "when not set in interactor" do - context "when set in commandline" do + 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)) end - it "uses commandline scope" do - expect(hash).to contain_exactly("baz") + it 'uses commandline scope' do + expect(hash).to contain_exactly('baz') end end - context "when not set in commandline" do - context "when set in Guardfile" do + 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)) end - it "uses guardfile scope" do - expect(hash).to contain_exactly("baz") + it 'uses guardfile scope' do + expect(hash).to contain_exactly('baz') end end end @@ -87,7 +87,7 @@ end end - describe "#titles" do + describe '#titles' do pending end end diff --git a/spec/lib/guard/internals/session_spec.rb b/spec/lib/guard/internals/session_spec.rb index db9bcc957..807648ef0 100644 --- a/spec/lib/guard/internals/session_spec.rb +++ b/spec/lib/guard/internals/session_spec.rb @@ -1,129 +1,129 @@ -require "guard/internals/session" +require 'guard/internals/session' RSpec.describe Guard::Internals::Session do let(:options) { {} } subject { described_class.new(options) } - let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:groups) { instance_double("Guard::Internals::Plugins") } + let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:groups) { instance_double('Guard::Internals::Plugins') } before do allow(Guard::Internals::Plugins).to receive(:new).and_return(plugins) allow(Guard::Internals::Groups).to receive(:new).and_return(groups) end - describe "#initialize" do - describe "#listener_args" do + describe '#initialize' do + describe '#listener_args' do subject { described_class.new(options).listener_args } - context "with a single watchdir" do - let(:options) { { watchdir: ["/usr"] } } - let(:dir) { Gem.win_platform? ? "C:/usr" : "/usr" } + context 'with a single watchdir' do + let(:options) { { watchdir: ['/usr'] } } + let(:dir) { Gem.win_platform? ? 'C:/usr' : '/usr' } it { is_expected.to eq [:to, dir, {}] } end - context "with multiple watchdirs" do - let(:options) { { watchdir: ["/usr", "/bin"] } } - let(:dir1) { Gem.win_platform? ? "C:/usr" : "/usr" } - let(:dir2) { Gem.win_platform? ? "C:/bin" : "/bin" } + context 'with multiple watchdirs' do + let(:options) { { watchdir: ['/usr', '/bin'] } } + let(:dir1) { Gem.win_platform? ? 'C:/usr' : '/usr' } + let(:dir2) { Gem.win_platform? ? 'C:/bin' : '/bin' } it { is_expected.to eq [:to, dir1, dir2, {}] } end - context "with force_polling option" do + context 'with force_polling option' do let(:options) { { force_polling: true } } it { is_expected.to eq [:to, Dir.pwd, force_polling: true] } end - context "with latency option" do + context 'with latency option' do let(:options) { { latency: 1.5 } } it { is_expected.to eq [:to, Dir.pwd, latency: 1.5] } end end - context "with the plugin option" do + context 'with the plugin option' do let(:options) do { plugin: %w(cucumber jasmine), - guardfile_contents: "guard :jasmine do; end; "\ - "guard :cucumber do; end; guard :coffeescript do; end" + guardfile_contents: 'guard :jasmine do; end; '\ + 'guard :cucumber do; end; guard :coffeescript do; end' } end - let(:jasmine) { instance_double("Guard::Plugin") } - let(:cucumber) { instance_double("Guard::Plugin") } - let(:coffeescript) { instance_double("Guard::Plugin") } + let(:jasmine) { instance_double('Guard::Plugin') } + let(:cucumber) { instance_double('Guard::Plugin') } + let(:coffeescript) { instance_double('Guard::Plugin') } before do - stub_const "Guard::Jasmine", jasmine - stub_const "Guard::Cucumber", cucumber - stub_const "Guard::CoffeeScript", coffeescript + stub_const 'Guard::Jasmine', jasmine + stub_const 'Guard::Cucumber', cucumber + stub_const 'Guard::CoffeeScript', coffeescript end - it "initializes the plugin scope" do - allow(plugins).to receive(:add).with("cucumber", {}). + it 'initializes the plugin scope' do + allow(plugins).to receive(:add).with('cucumber', {}). and_return(cucumber) - allow(plugins).to receive(:add).with("jasmine", {}). + allow(plugins).to receive(:add).with('jasmine', {}). and_return(jasmine) expect(subject.cmdline_plugins).to match_array(%w(cucumber jasmine)) end end - context "with the group option" do + context 'with the group option' do let(:options) do { group: %w(backend frontend), - guardfile_contents: "group :backend do; end; "\ - "group :frontend do; end; group :excluded do; end" + guardfile_contents: 'group :backend do; end; '\ + 'group :frontend do; end; group :excluded do; end' } end before do - g3 = instance_double("Guard::Group", name: :backend, options: {}) - g4 = instance_double("Guard::Group", name: :frontend, options: {}) - allow(Guard::Group).to receive(:new).with("backend", {}).and_return(g3) - allow(Guard::Group).to receive(:new).with("frontend", {}).and_return(g4) + g3 = instance_double('Guard::Group', name: :backend, options: {}) + g4 = instance_double('Guard::Group', name: :frontend, options: {}) + allow(Guard::Group).to receive(:new).with('backend', {}).and_return(g3) + allow(Guard::Group).to receive(:new).with('frontend', {}).and_return(g4) end - it "initializes the group scope" do + it 'initializes the group scope' do expect(subject.cmdline_groups).to match_array(%w(backend frontend)) end end end - describe "#clearing" do - context "when not set" do - context "when clearing is not set from commandline" do + describe '#clearing' do + context 'when not set' do + context 'when clearing is not set from commandline' do it { is_expected.to_not be_clearing } end - context "when clearing is set from commandline" do + context 'when clearing is set from commandline' do let(:options) { { clear: false } } it { is_expected.to_not be_clearing } end end - context "when set from guardfile" do - context "when set to :on" do + context 'when set from guardfile' do + context 'when set to :on' do before { subject.clearing(true) } it { is_expected.to be_clearing } end - context "when set to :off" do + context 'when set to :off' do before { subject.clearing(false) } it { is_expected.to_not be_clearing } end end end - describe "#guardfile_ignore=" do - context "when set from guardfile" do + describe '#guardfile_ignore=' do + context 'when set from guardfile' do before { subject.guardfile_ignore = [/foo/] } specify { expect(subject.guardfile_ignore).to eq([/foo/]) } end - context "when set multiple times from guardfile" do + context 'when set multiple times from guardfile' do before do subject.guardfile_ignore = [/foo/] subject.guardfile_ignore = [/bar/] @@ -131,117 +131,117 @@ specify { expect(subject.guardfile_ignore).to eq([/foo/, /bar/]) } end - context "when unset" do + context 'when unset' do specify { expect(subject.guardfile_ignore).to eq([]) } end end - describe "#guardfile_ignore_bang=" do - context "when set from guardfile" do + describe '#guardfile_ignore_bang=' do + context 'when set from guardfile' do before { subject.guardfile_ignore_bang = [/foo/] } specify { expect(subject.guardfile_ignore_bang).to eq([/foo/]) } end - context "when unset" do + context 'when unset' do specify { expect(subject.guardfile_ignore_bang).to eq([]) } end end - describe "#guardfile_scope" do + describe '#guardfile_scope' do before do subject.guardfile_scope(scope) end - context "with a groups scope" do + context 'with a groups scope' do let(:scope) { { groups: [:foo] } } - it "sets the groups" do + it 'sets the groups' do expect(subject.guardfile_group_scope).to eq([:foo]) end end - context "with a group scope" do + context 'with a group scope' do let(:scope) { { group: [:foo] } } - it "sets the groups" do + it 'sets the groups' do expect(subject.guardfile_group_scope).to eq([:foo]) end end - context "with a plugin scope" do + context 'with a plugin scope' do let(:scope) { { plugin: [:foo] } } - it "sets the plugins" do + it 'sets the plugins' do expect(subject.guardfile_plugin_scope).to eq([:foo]) end end - context "with a plugins scope" do + context 'with a plugins scope' do let(:scope) { { plugins: [:foo] } } - it "sets the plugins" do + it 'sets the plugins' do expect(subject.guardfile_plugin_scope).to eq([:foo]) end end end - describe ".convert_scope" do - let(:foo) { instance_double("Guard::Plugin", name: "foo") } - let(:bar) { instance_double("Guard::Plugin", name: "bar") } - let(:backend) { instance_double("Guard::Group", name: "backend") } - let(:frontend) { instance_double("Guard::Group", name: "frontend") } + describe '.convert_scope' do + let(:foo) { instance_double('Guard::Plugin', name: 'foo') } + let(:bar) { instance_double('Guard::Plugin', name: 'bar') } + let(:backend) { instance_double('Guard::Group', name: 'backend') } + let(:frontend) { instance_double('Guard::Group', name: 'frontend') } before do - stub_const "Guard::Foo", class_double("Guard::Plugin") - stub_const "Guard::Bar", class_double("Guard::Plugin") - - allow(plugins).to receive(:all).with("backend").and_return([]) - allow(plugins).to receive(:all).with("frontend").and_return([]) - allow(plugins).to receive(:all).with("foo").and_return([foo]) - allow(plugins).to receive(:all).with("bar").and_return([bar]) - allow(plugins).to receive(:all).with("unknown").and_return([]) - allow(plugins).to receive(:all).with("scope").and_return([]) - - allow(groups).to receive(:all).with("backend").and_return([backend]) - allow(groups).to receive(:all).with("frontend").and_return([frontend]) - allow(groups).to receive(:all).with("unknown").and_return([]) - allow(groups).to receive(:all).with("scope").and_return([]) + stub_const 'Guard::Foo', class_double('Guard::Plugin') + stub_const 'Guard::Bar', class_double('Guard::Plugin') + + allow(plugins).to receive(:all).with('backend').and_return([]) + allow(plugins).to receive(:all).with('frontend').and_return([]) + allow(plugins).to receive(:all).with('foo').and_return([foo]) + allow(plugins).to receive(:all).with('bar').and_return([bar]) + allow(plugins).to receive(:all).with('unknown').and_return([]) + allow(plugins).to receive(:all).with('scope').and_return([]) + + allow(groups).to receive(:all).with('backend').and_return([backend]) + allow(groups).to receive(:all).with('frontend').and_return([frontend]) + allow(groups).to receive(:all).with('unknown').and_return([]) + allow(groups).to receive(:all).with('scope').and_return([]) end - it "returns a group scope" do + it 'returns a group scope' do scopes, = subject.convert_scope %w(backend) expect(scopes).to eq(groups: [backend], plugins: []) scopes, = subject.convert_scope %w(frontend) expect(scopes).to eq(groups: [frontend], plugins: []) end - it "returns a plugin scope" do + it 'returns a plugin scope' do scopes, = subject.convert_scope %w(foo) expect(scopes).to eq(plugins: [foo], groups: []) scopes, = subject.convert_scope %w(bar) expect(scopes).to eq(plugins: [bar], groups: []) end - it "returns multiple group scopes" do + it 'returns multiple group scopes' do scopes, = subject.convert_scope %w(backend frontend) expected = { groups: [backend, frontend], plugins: [] } expect(scopes).to eq(expected) end - it "returns multiple plugin scopes" do + it 'returns multiple plugin scopes' do scopes, = subject.convert_scope %w(foo bar) expect(scopes).to eq(plugins: [foo, bar], groups: []) end - it "returns a plugin and group scope" do + it 'returns a plugin and group scope' do scopes, = subject.convert_scope %w(foo backend) expect(scopes).to eq(plugins: [foo], groups: [backend]) end - it "returns the unkown scopes" do + it 'returns the unkown scopes' do _, unknown = subject.convert_scope %w(unknown scope) expect(unknown).to eq %w(unknown scope) end end - describe "#guardfile_notification=" do - context "when set from guardfile" do + describe '#guardfile_notification=' do + context 'when set from guardfile' do before do subject.guardfile_notification = { foo: { bar: :baz } } end @@ -256,13 +256,13 @@ end end - context "when set multiple times from guardfile" do + context 'when set multiple times from guardfile' do before do subject.guardfile_notification = { foo: { param: 1 } } subject.guardfile_notification = { bar: { param: 2 } } end - it "merges results" do + it 'merges results' do expect(subject.notify_options).to eq( notify: true, notifiers: { @@ -273,7 +273,7 @@ end end - context "when unset" do + context 'when unset' do specify do expect(subject.notify_options).to eq(notify: true, notifiers: {}) end diff --git a/spec/lib/guard/internals/state_spec.rb b/spec/lib/guard/internals/state_spec.rb index daed798d4..f6d50a154 100644 --- a/spec/lib/guard/internals/state_spec.rb +++ b/spec/lib/guard/internals/state_spec.rb @@ -1,13 +1,13 @@ -require "guard/internals/state" +require 'guard/internals/state' RSpec.describe Guard::Internals::State do let(:options) { {} } subject { described_class.new(options) } - let(:scope) { instance_double("Guard::Internals::Scope") } - let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:groups) { instance_double("Guard::Internals::Groups") } - let(:session) { instance_double("Guard::Internals::Session") } + let(:scope) { instance_double('Guard::Internals::Scope') } + let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:groups) { instance_double('Guard::Internals::Groups') } + let(:session) { instance_double('Guard::Internals::Session') } before do allow(Guard::Internals::Session).to receive(:new).and_return(session) @@ -17,25 +17,25 @@ allow(session).to receive(:groups).and_return(groups) end - describe "#initialize" do - describe "debugging" do + describe '#initialize' do + describe 'debugging' do let(:options) { { debug: debug } } before do allow(session).to receive(:debug?).and_return(debug) expect(Guard::Internals::Session).to receive(:new).with(debug: debug) end - context "when debug is set to true" do + context 'when debug is set to true' do let(:debug) { true } - it "sets up debugging" do + it 'sets up debugging' do expect(Guard::Internals::Debugging).to receive(:start) subject end end - context "when debug is set to false" do + context 'when debug is set to false' do let(:debug) { false } - it "does not set up debugging" do + it 'does not set up debugging' do expect(Guard::Internals::Debugging).to_not receive(:start) subject end diff --git a/spec/lib/guard/internals/tracing_spec.rb b/spec/lib/guard/internals/tracing_spec.rb index 95c1c162a..3b537973b 100644 --- a/spec/lib/guard/internals/tracing_spec.rb +++ b/spec/lib/guard/internals/tracing_spec.rb @@ -1,4 +1,4 @@ -require "guard/internals/tracing" +require 'guard/internals/tracing' RSpec.describe Guard::Internals::Tracing do let(:null) { IO::NULL } @@ -11,17 +11,17 @@ # Stubbing just Kernel.system isn't "deep" enough, but not only that, # we don't want to stub here, we want to TEST the stubbing # - describe "Module method tracing" do + describe 'Module method tracing' do let(:result) { Kernel.send(meth, *args) } subject { result } - let(:callback) { double("callback", call: true) } + let(:callback) { double('callback', call: true) } # Since we can't stub the C code in Ruby, only "right" way to test this is: # actually call a real command and compare the output before { allow(Kernel).to receive(meth).and_call_original } - context "when tracing" do + context 'when tracing' do before do described_class.trace(Kernel, meth) { |*args| callback.call(*args) } subject @@ -29,81 +29,81 @@ after { described_class.untrace(Kernel, meth) } - context "with no command arguments" do + context 'with no command arguments' do let(:args) { ["echo >#{null}"] } - context "when #system" do - let(:meth) { "system" } + context 'when #system' do + let(:meth) { 'system' } it { is_expected.to eq(true) } - it "outputs command" do + it 'outputs command' do expect(callback).to have_received(:call).with("echo >#{null}") end end - context "when backticks" do + context 'when backticks' do let(:meth) { :` } - it { is_expected.to eq("") } + it { is_expected.to eq('') } - it "outputs command" do + it 'outputs command' do expect(callback).to have_received(:call).with("echo >#{null}") end end end - context "with command arguments" do + context 'with command arguments' do let(:args) { %w(true 123) } - context "when #system" do - let(:meth) { "system" } + context 'when #system' do + let(:meth) { 'system' } it { is_expected.to eq(true) } - it "outputs command arguments" do - expect(callback).to have_received(:call).with("true", "123") + it 'outputs command arguments' do + expect(callback).to have_received(:call).with('true', '123') end end end end - context "when not tracing" do + context 'when not tracing' do before { subject } - context "with no command arguments" do + context 'with no command arguments' do let(:args) { ["echo test > #{null}"] } - context "when #system" do + context 'when #system' do let(:meth) { :system } it { is_expected.to eq(true) } - it "does not output anything" do + it 'does not output anything' do expect(callback).to_not have_received(:call) end end - context "when backticks" do + context 'when backticks' do let(:meth) { :` } - it { is_expected.to eq("") } + it { is_expected.to eq('') } - it "does not output anything" do + it 'does not output anything' do expect(callback).to_not have_received(:call) end end end - context "with command arguments" do + context 'with command arguments' do let(:args) { %w(true 123) } - context "when #system" do + context 'when #system' do let(:meth) { :system } it { is_expected.to eq(true) } - it "does not output anything" do + it 'does not output anything' do expect(callback).to_not have_received(:call) end end diff --git a/spec/lib/guard/internals/traps_spec.rb b/spec/lib/guard/internals/traps_spec.rb index 64e8e82a6..09b9222d8 100644 --- a/spec/lib/guard/internals/traps_spec.rb +++ b/spec/lib/guard/internals/traps_spec.rb @@ -1,18 +1,18 @@ -require "guard/internals/traps" +require 'guard/internals/traps' RSpec.describe Guard::Internals::Traps do - describe ".handle" do + describe '.handle' do let(:signal_class) { class_double(Signal) } before do - stub_const("Signal", signal_class) + stub_const('Signal', signal_class) end - context "with a supported signal name" do - let(:signal) { "USR1" } + context 'with a supported signal name' do + let(:signal) { 'USR1' } - it "sets up a handler" do - allow(Signal).to receive(:list).and_return("USR1" => 10) + it 'sets up a handler' do + allow(Signal).to receive(:list).and_return('USR1' => 10) allow(Signal).to receive(:trap).with(signal) do |_, &block| block.call end @@ -21,11 +21,11 @@ end end - context "with an unsupported signal name" do - let(:signal) { "ABCD" } + context 'with an unsupported signal name' do + let(:signal) { 'ABCD' } - it "does not set a handler" do - allow(Signal).to receive(:list).and_return("KILL" => 9) + it 'does not set a handler' do + allow(Signal).to receive(:list).and_return('KILL' => 9) expect(Signal).to_not receive(:trap) described_class.handle(signal) end diff --git a/spec/lib/guard/jobs/pry_wrapper_spec.rb b/spec/lib/guard/jobs/pry_wrapper_spec.rb index e8bf35696..47ed6d5ad 100644 --- a/spec/lib/guard/jobs/pry_wrapper_spec.rb +++ b/spec/lib/guard/jobs/pry_wrapper_spec.rb @@ -1,19 +1,19 @@ -require "guard/jobs/pry_wrapper" +require 'guard/jobs/pry_wrapper' RSpec.describe Guard::Jobs::PryWrapper do subject { described_class.new({}) } - let(:listener) { instance_double("Listen::Listener") } - let(:pry_config) { double("pry_config") } - let(:pry_history) { double("pry_history") } - let(:pry_commands) { double("pry_commands") } - let(:pry_hooks) { double("pry_hooks") } - let(:terminal_settings) { instance_double("Guard::Jobs::TerminalSettings") } - - let(:session) { instance_double("Guard::Internals::Session") } - let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:groups) { instance_double("Guard::Internals::Groups") } - let(:state) { instance_double("Guard::Internals::State") } - let(:scope) { instance_double("Guard::Internals::Scope") } + let(:listener) { instance_double('Listen::Listener') } + let(:pry_config) { double('pry_config') } + let(:pry_history) { double('pry_history') } + let(:pry_commands) { double('pry_commands') } + let(:pry_hooks) { double('pry_hooks') } + let(:terminal_settings) { instance_double('Guard::Jobs::TerminalSettings') } + + let(:session) { instance_double('Guard::Internals::Session') } + let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:groups) { instance_double('Guard::Internals::Groups') } + let(:state) { instance_double('Guard::Internals::State') } + let(:scope) { instance_double('Guard::Internals::Scope') } before do # TODO: this are here to mock out Pry completely @@ -59,7 +59,7 @@ allow(terminal_settings).to receive(:restore) end - describe "#foreground" do + describe '#foreground' do before do allow(Pry).to receive(:start) do # sleep for a long time (anything > 0.6) @@ -71,7 +71,7 @@ subject.background end - it "waits for Pry thread to finish" do + it 'waits for Pry thread to finish' do was_alive = false Thread.new do @@ -84,7 +84,7 @@ expect(was_alive).to be end - it "prevents the Pry thread from being killed too quickly" do + it 'prevents the Pry thread from being killed too quickly' do start = Time.now.to_f Thread.new do @@ -98,7 +98,7 @@ expect(killed_moment - start).to be > 0.5 end - it "return :stopped when brought into background" do + it 'return :stopped when brought into background' do Thread.new do sleep 0.1 subject.background @@ -108,7 +108,7 @@ end end - describe "#background" do + describe '#background' do before do allow(Pry).to receive(:start) do # 0.5 is enough for Pry, so we use 0.4 @@ -116,7 +116,7 @@ end end - it "kills the Pry thread" do + it 'kills the Pry thread' do subject.foreground sleep 1 # give Pry 0.5 sec to boot subject.background @@ -126,57 +126,57 @@ end end - describe "#_prompt(ending_char)" do - let(:prompt) { subject.send(:_prompt, ">") } + describe '#_prompt(ending_char)' do + let(:prompt) { subject.send(:_prompt, '>') } before do allow(Shellany::Sheller).to receive(:run).with(*%w(hash stty)) { false } - allow(scope).to receive(:titles).and_return(["all"]) + allow(scope).to receive(:titles).and_return(['all']) allow(listener).to receive(:paused?).and_return(false) - expect(Pry).to receive(:view_clip).and_return("main") + expect(Pry).to receive(:view_clip).and_return('main') end let(:pry) { instance_double(Pry, input_array: []) } - context "Guard is not paused" do + context 'Guard is not paused' do it 'displays "guard"' do expect(prompt.call(double, 0, pry)). - to eq "[0] guard(main)> " + to eq '[0] guard(main)> ' end end - context "Guard is paused" do + context 'Guard is paused' do before do allow(listener).to receive(:paused?).and_return(true) end it 'displays "pause"' do expect(prompt.call(double, 0, pry)). - to eq "[0] pause(main)> " + to eq '[0] pause(main)> ' end end - context "with a groups scope" do + context 'with a groups scope' do before do allow(scope).to receive(:titles).and_return(%w(Backend Frontend)) end - it "displays the group scope title in the prompt" do + it 'displays the group scope title in the prompt' do expect(prompt.call(double, 0, pry)). - to eq "[0] Backend,Frontend guard(main)> " + to eq '[0] Backend,Frontend guard(main)> ' end end - context "with a plugins scope" do + context 'with a plugins scope' do before do allow(scope).to receive(:titles).and_return(%w(RSpec Ronn)) end - it "displays the group scope title in the prompt" do + it 'displays the group scope title in the prompt' do result = prompt.call(double, 0, pry) - expect(result).to eq "[0] RSpec,Ronn guard(main)> " + expect(result).to eq '[0] RSpec,Ronn guard(main)> ' end end end diff --git a/spec/lib/guard/jobs/sleep_spec.rb b/spec/lib/guard/jobs/sleep_spec.rb index 155240802..070d313a2 100644 --- a/spec/lib/guard/jobs/sleep_spec.rb +++ b/spec/lib/guard/jobs/sleep_spec.rb @@ -1,11 +1,11 @@ -require "guard/jobs/sleep" +require 'guard/jobs/sleep' RSpec.describe Guard::Jobs::Sleep do subject { described_class.new({}) } - describe "#foreground" do - it "sleeps" do - status = "unknown" + describe '#foreground' do + it 'sleeps' do + status = 'unknown' Thread.new do sleep 0.1 @@ -15,10 +15,10 @@ subject.foreground - expect(status).to eq("sleep") + expect(status).to eq('sleep') end - it "returns :stopped when put to background" do + it 'returns :stopped when put to background' do Thread.new do sleep 0.1 subject.background @@ -28,9 +28,9 @@ end end - describe "#background" do - it "wakes up main thread" do - status = "unknown" + describe '#background' do + it 'wakes up main thread' do + status = 'unknown' Thread.new do sleep 0.1 # give enough time for foreground to put main thread to sleep @@ -53,7 +53,7 @@ rescue Timeout::Error end - expect(status).to eq("run") + expect(status).to eq('run') end end end diff --git a/spec/lib/guard/notifier_spec.rb b/spec/lib/guard/notifier_spec.rb index 1230ec973..4e80f57b2 100644 --- a/spec/lib/guard/notifier_spec.rb +++ b/spec/lib/guard/notifier_spec.rb @@ -1,8 +1,8 @@ -require "guard/notifier" +require 'guard/notifier' RSpec.describe Guard::Notifier do subject { described_class } - let(:notifier) { instance_double("Notiffany::Notifier") } + let(:notifier) { instance_double('Notiffany::Notifier') } before do allow(Notiffany::Notifier).to receive(:new).and_return(notifier) @@ -12,31 +12,31 @@ Guard::Notifier.instance_variable_set(:@notifier, nil) end - describe "toggle_notification" do + describe 'toggle_notification' do before do allow(notifier).to receive(:enabled?).and_return(true) end - context "with available notifiers" do - context "when currently on" do + context 'with available notifiers' do + context 'when currently on' do before do allow(notifier).to receive(:active?).and_return(true) subject.connect end - it "suspends notifications" do + it 'suspends notifications' do expect(notifier).to receive(:turn_off) subject.toggle end end - context "when currently off" do + context 'when currently off' do before do subject.connect allow(notifier).to receive(:active?).and_return(false) end - it "resumes notifications" do + it 'resumes notifications' do expect(notifier).to receive(:turn_on) subject.toggle end @@ -44,37 +44,37 @@ end end - describe ".notify" do + describe '.notify' do before do subject.connect allow(notifier).to receive(:notify) end - context "with no options" do - it "notifies" do - expect(notifier).to receive(:notify).with("A", {}) - subject.notify("A") + context 'with no options' do + it 'notifies' do + expect(notifier).to receive(:notify).with('A', {}) + subject.notify('A') end end - context "with multiple parameters" do - it "notifies" do + context 'with multiple parameters' do + it 'notifies' do expect(notifier).to receive(:notify). - with("A", priority: 2, image: :failed) - subject.notify("A", priority: 2, image: :failed) + with('A', priority: 2, image: :failed) + subject.notify('A', priority: 2, image: :failed) end end - context "with a runtime error" do + context 'with a runtime error' do before do - allow(notifier).to receive(:notify).and_raise(RuntimeError, "an error") + allow(notifier).to receive(:notify).and_raise(RuntimeError, 'an error') end - it "shows an error" do + it 'shows an error' do expect(Guard::UI).to receive(:error). with(/Notification failed for .+: an error/) - subject.notify("A", priority: 2, image: :failed) + subject.notify('A', priority: 2, image: :failed) end end end diff --git a/spec/lib/guard/options_spec.rb b/spec/lib/guard/options_spec.rb index 5d55472d7..f6ea02fbc 100644 --- a/spec/lib/guard/options_spec.rb +++ b/spec/lib/guard/options_spec.rb @@ -1,31 +1,31 @@ -require "guard/options" +require 'guard/options' RSpec.describe Guard::Options do - describe ".initialize" do - it "handles nil options" do + describe '.initialize' do + it 'handles nil options' do expect { described_class.new(nil) }.to_not raise_error end - it "has indifferent access" do - options = described_class.new({ foo: "bar" }, "foo2" => "baz") + it 'has indifferent access' do + options = described_class.new({ foo: 'bar' }, 'foo2' => 'baz') - expect(options[:foo]).to eq "bar" - expect(options["foo"]).to eq "bar" + expect(options[:foo]).to eq 'bar' + expect(options['foo']).to eq 'bar' - expect(options[:foo2]).to eq "baz" - expect(options["foo2"]).to eq "baz" + expect(options[:foo2]).to eq 'baz' + expect(options['foo2']).to eq 'baz' end - it "can be passed defaults" do - options = described_class.new({}, foo: "bar") + it 'can be passed defaults' do + options = described_class.new({}, foo: 'bar') - expect(options[:foo]).to eq "bar" + expect(options[:foo]).to eq 'bar' end - it "merges the sensible defaults to the given options" do - options = described_class.new({ plugin: ["rspec"] }, plugin: ["test"]) + it 'merges the sensible defaults to the given options' do + options = described_class.new({ plugin: ['rspec'] }, plugin: ['test']) - expect(options[:plugin]).to eq ["rspec"] + expect(options[:plugin]).to eq ['rspec'] end end end diff --git a/spec/lib/guard/plugin_spec.rb b/spec/lib/guard/plugin_spec.rb index a326fbeb1..bae4a7cbd 100644 --- a/spec/lib/guard/plugin_spec.rb +++ b/spec/lib/guard/plugin_spec.rb @@ -1,14 +1,14 @@ -require "guard/plugin" +require 'guard/plugin' -require "guard/watcher" +require 'guard/watcher' RSpec.describe Guard::Plugin do - let(:default) { instance_double("Guard::Group") } - let(:test) { instance_double("Guard::Group") } + let(:default) { instance_double('Guard::Group') } + let(:test) { instance_double('Guard::Group') } - let(:session) { instance_double("Guard::Internals::Session") } - let(:groups) { instance_double("Guard::Internals::Groups") } - let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double('Guard::Internals::Session') } + let(:groups) { instance_double('Guard::Internals::Groups') } + let(:state) { instance_double('Guard::Internals::State') } before do allow(groups).to receive(:add).with(:default).and_return(default) @@ -27,32 +27,32 @@ end end - describe "#initialize" do - it "assigns the defined watchers" do - watchers = [double("foo")] + describe '#initialize' do + it 'assigns the defined watchers' do + watchers = [double('foo')] expect(Guard::Plugin.new(watchers: watchers).watchers).to eq watchers end - it "assigns the defined options" do + it 'assigns the defined options' do options = { a: 1, b: 2 } expect(Guard::Plugin.new(options).options).to eq options end - context "with a group in the options" do - it "assigns the given group" do + context 'with a group in the options' do + it 'assigns the given group' do expect(Guard::Plugin.new(group: :test).group).to eq test end end - context "without a group in the options" do - it "assigns a default group" do + context 'without a group in the options' do + it 'assigns a default group' do allow(groups).to receive(:add).with(:default).and_return(default) expect(Guard::Plugin.new.group).to eq default end end - context "with a callback" do - it "adds the callback" do + context 'with a callback' do + it 'adds the callback' do block = instance_double(Proc) events = [:start_begin, :start_end] callbacks = [{ events: events, listener: block }] @@ -62,7 +62,7 @@ end end - context "with a plugin instance" do + context 'with a plugin instance' do subject do module Guard class DuMmy < Guard::Plugin @@ -75,47 +75,47 @@ class DuMmy < Guard::Plugin Guard.send(:remove_const, :DuMmy) end - describe ".non_namespaced_classname" do - it "remove the Guard:: namespace" do - expect(subject.non_namespaced_classname).to eq "DuMmy" + describe '.non_namespaced_classname' do + it 'remove the Guard:: namespace' do + expect(subject.non_namespaced_classname).to eq 'DuMmy' end end - describe ".non_namespaced_name" do - it "remove the Guard:: namespace and downcase" do - expect(subject.non_namespaced_name).to eq "dummy" + describe '.non_namespaced_name' do + it 'remove the Guard:: namespace and downcase' do + expect(subject.non_namespaced_name).to eq 'dummy' end end - describe ".template" do + describe '.template' do before do allow(File).to receive(:read) end - it "reads the default template" do + it 'reads the default template' do expect(File).to receive(:read). - with("/guard-dummy/lib/guard/dummy/templates/Guardfile") { true } + with('/guard-dummy/lib/guard/dummy/templates/Guardfile') { true } - subject.template("/guard-dummy") + subject.template('/guard-dummy') end end - describe "#name" do - it "outputs the short plugin name" do - expect(subject.new.name).to eq "dummy" + describe '#name' do + it 'outputs the short plugin name' do + expect(subject.new.name).to eq 'dummy' end end - describe "#title" do - it "outputs the plugin title" do - expect(subject.new.title).to eq "DuMmy" + describe '#title' do + it 'outputs the plugin title' do + expect(subject.new.title).to eq 'DuMmy' end end - describe "#to_s" do - let(:default) { instance_double("Guard::Group", name: :default) } + describe '#to_s' do + let(:default) { instance_double('Guard::Group', name: :default) } - it "output the short plugin name" do + it 'output the short plugin name' do expect(subject.new.to_s). to match(/#/) end @@ -124,10 +124,10 @@ class DuMmy < Guard::Plugin let(:listener) { instance_double(Proc, call: nil) } - describe ".add_callback" do - let(:foo) { double("foo plugin") } + describe '.add_callback' do + let(:foo) { double('foo plugin') } - it "can add a run_on_modifications callback" do + it 'can add a run_on_modifications callback' do described_class.add_callback( listener, foo, @@ -138,7 +138,7 @@ class DuMmy < Guard::Plugin expect(result).to include(listener) end - it "can add multiple callbacks" do + it 'can add multiple callbacks' do described_class.add_callback(listener, foo, [:event1, :event2]) result = described_class.callbacks[[foo, :event1]] @@ -149,46 +149,46 @@ class DuMmy < Guard::Plugin end end - describe ".notify" do - let(:foo) { double("foo plugin") } - let(:bar) { double("bar plugin") } + describe '.notify' do + let(:foo) { double('foo plugin') } + let(:bar) { double('bar plugin') } before do described_class.add_callback(listener, foo, :start_begin) end it "sends :call to the given Guard class's start_begin callback" do - expect(listener).to receive(:call).with(foo, :start_begin, "args") - described_class.notify(foo, :start_begin, "args") + expect(listener).to receive(:call).with(foo, :start_begin, 'args') + described_class.notify(foo, :start_begin, 'args') end it "sends :call to the given Guard class's start_begin callback" do - expect(listener).to receive(:call).with(foo, :start_begin, "args") - described_class.notify(foo, :start_begin, "args") + expect(listener).to receive(:call).with(foo, :start_begin, 'args') + described_class.notify(foo, :start_begin, 'args') end - it "runs only the given callbacks" do - listener2 = double("listener2") + it 'runs only the given callbacks' do + listener2 = double('listener2') described_class.add_callback(listener2, foo, :start_end) expect(listener2).to_not receive(:call).with(foo, :start_end) described_class.notify(foo, :start_begin) end - it "runs callbacks only for the guard given" do + it 'runs callbacks only for the guard given' do described_class.add_callback(listener, bar, :start_begin) expect(listener).to_not receive(:call).with(bar, :start_begin) described_class.notify(foo, :start_begin) end end - describe "#hook" do - let(:foo) { double("foo plugin") } + describe '#hook' do + let(:foo) { double('foo plugin') } before do described_class.add_callback(listener, foo, :start_begin) end - it "notifies the hooks" do + it 'notifies the hooks' do class Foo < described_class def run_all hook :begin @@ -202,10 +202,10 @@ def run_all foo.run_all end - it "passes the hooks name" do + it 'passes the hooks name' do class Foo < described_class def start - hook "my_hook" + hook 'my_hook' end end @@ -214,20 +214,20 @@ def start foo.start end - it "accepts extra arguments" do + it 'accepts extra arguments' do class Foo < described_class def stop - hook :begin, "args" - hook "special_sauce", "first_arg", "second_arg" + hook :begin, 'args' + hook 'special_sauce', 'first_arg', 'second_arg' end end foo = Foo.new expect(described_class).to receive(:notify). - with(foo, :stop_begin, "args") + with(foo, :stop_begin, 'args') expect(described_class).to receive(:notify). - with(foo, :special_sauce, "first_arg", "second_arg") + 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..1a19cca32 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -1,13 +1,13 @@ -require "guard/plugin_util" +require 'guard/plugin_util' -require "guard/guardfile/evaluator" +require 'guard/guardfile/evaluator' RSpec.describe Guard::PluginUtil do - let(:guard_rspec_class) { class_double("Guard::Plugin") } - let(:guard_rspec) { instance_double("Guard::Plugin") } - let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } - let(:session) { instance_double("Guard::Internals::Session") } - let(:state) { instance_double("Guard::Internals::State") } + let(:guard_rspec_class) { class_double('Guard::Plugin') } + let(:guard_rspec) { instance_double('Guard::Plugin') } + let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } + let(:session) { instance_double('Guard::Internals::Session') } + let(:state) { instance_double('Guard::Internals::State') } before do allow(session).to receive(:evaluator_options).and_return({}) @@ -16,52 +16,52 @@ allow(Guard::Guardfile::Evaluator).to receive(:new).and_return(evaluator) end - describe ".plugin_names" do + describe '.plugin_names' do before do spec = Gem::Specification gems = [ - 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-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'), ] allow(File).to receive(:exist?). - with("/gem1/lib/guard/gem1.rb") { false } + with('/gem1/lib/guard/gem1.rb') { false } allow(File).to receive(:exist?). - with("/gem2/lib/guard/gem2.rb") { true } + with('/gem2/lib/guard/gem2.rb') { true } gem = class_double(Gem::Specification) - stub_const("Gem::Specification", gem) + stub_const('Gem::Specification', gem) expect(Gem::Specification).to receive(:find_all) { gems } allow(Gem::Specification).to receive(:unresolved_deps) { [] } end - it "returns the list of guard gems" do - expect(described_class.plugin_names).to include("myplugin") + it 'returns the list of guard gems' do + expect(described_class.plugin_names).to include('myplugin') end - it "returns the list of embedded guard gems" do - expect(described_class.plugin_names).to include("gem2") + it 'returns the list of embedded guard gems' do + expect(described_class.plugin_names).to include('gem2') end - it "ignores guard-compat" do - expect(described_class.plugin_names).to_not include("compat") + it 'ignores guard-compat' do + expect(described_class.plugin_names).to_not include('compat') end end - describe "#initialize" do - it "accepts a name without guard-" do - expect(described_class.new("rspec").name).to eq "rspec" + describe '#initialize' do + it 'accepts a name without guard-' do + expect(described_class.new('rspec').name).to eq 'rspec' end - it "accepts a name with guard-" do - expect(described_class.new("guard-rspec").name).to eq "rspec" + it 'accepts a name with guard-' do + expect(described_class.new('guard-rspec').name).to eq 'rspec' end end - describe "#initialize_plugin" do - let(:plugin_util) { described_class.new("rspec") } + describe '#initialize_plugin' do + let(:plugin_util) { described_class.new('rspec') } before do allow_any_instance_of(described_class). @@ -69,13 +69,13 @@ and_return(guard_rspec_class) end - context "with a plugin inheriting from Guard::Plugin" do + context 'with a plugin inheriting from Guard::Plugin' do before do expect(guard_rspec_class).to receive(:ancestors) { [::Guard::Plugin] } end - it "instantiate the plugin using the new API" do - options = { watchers: ["watcher"], group: "foo" } + it 'instantiate the plugin using the new API' do + options = { watchers: ['watcher'], group: 'foo' } expect(guard_rspec_class).to receive(:new).with(options) { guard_rspec } expect(plugin_util.initialize_plugin(options)).to eq guard_rspec @@ -83,17 +83,17 @@ end end - describe "#plugin_location" do - subject { described_class.new("rspec") } + describe '#plugin_location' do + subject { described_class.new('rspec') } - it "returns the path of a Guard gem" do + 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(subject.plugin_location).to eq "gems/guard-rspec" + with('guard-rspec') { double(full_gem_path: 'gems/guard-rspec') } + expect(subject.plugin_location).to eq 'gems/guard-rspec' end end - describe "#plugin_class" do + describe '#plugin_class' do after do # TODO: use RSpec's stub const consts = [:Classname, @@ -110,23 +110,23 @@ end end - it "reports an error if the class is not found" do + it 'reports an error if the class is not found' do expect(::Guard::UI).to receive(:error).with(/Could not load/) expect(::Guard::UI).to receive(:error).with(/Error is: cannot load/) 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 --") + plugin = described_class.new('notAGuardClass') + allow(plugin).to receive(:require).with('guard/notaguardclass'). + and_raise(LoadError, 'cannot load such file --') plugin.plugin_class end - context "with a nested Guard class" do - it "resolves the Guard class from string" do - plugin = described_class.new("classname") + context 'with a nested Guard class' do + it 'resolves the Guard class from string' do + plugin = described_class.new('classname') expect(plugin).to receive(:require) do |classname| - expect(classname).to eq "guard/classname" + expect(classname).to eq 'guard/classname' module Guard class Classname end @@ -135,10 +135,10 @@ class Classname expect(plugin.plugin_class).to eq Guard::Classname end - it "resolves the Guard class from symbol" do + it 'resolves the Guard class from symbol' do plugin = described_class.new(:classname) expect(plugin).to receive(:require) do |classname| - expect(classname).to eq "guard/classname" + expect(classname).to eq 'guard/classname' module Guard class Classname end @@ -148,11 +148,11 @@ class Classname end end - context "with a name with dashes" do - it "returns the Guard class" do - plugin = described_class.new("dashed-class-name") + context 'with a name with dashes' do + it 'returns the Guard class' do + plugin = described_class.new('dashed-class-name') expect(plugin).to receive(:require) do |classname| - expect(classname).to eq "guard/dashed-class-name" + expect(classname).to eq 'guard/dashed-class-name' module Guard class DashedClassName end @@ -162,11 +162,11 @@ class DashedClassName end end - context "with a name with underscores" do - it "returns the Guard class" do - plugin = described_class.new("underscore_class_name") + context 'with a name with underscores' do + it 'returns the Guard class' do + plugin = described_class.new('underscore_class_name') expect(plugin).to receive(:require) do |classname| - expect(classname).to eq "guard/underscore_class_name" + expect(classname).to eq 'guard/underscore_class_name' module Guard class UnderscoreClassName end @@ -176,12 +176,12 @@ class UnderscoreClassName end end - context "with a name like VSpec" do - it "returns the Guard class" do - plugin = described_class.new("vspec") + context 'with a name like VSpec' do + it 'returns the Guard class' do + plugin = described_class.new('vspec') mod = nil allow(plugin).to receive(:require) do |classname| - expect(classname).to eq "guard/vspec" + expect(classname).to eq 'guard/vspec' module Guard class VSpec end @@ -193,11 +193,11 @@ class VSpec end end - context "with an inline Guard class" do - subject { described_class.new("inline") } - let(:plugin_class) { class_double("Guard::Plugin") } + context 'with an inline Guard class' do + subject { described_class.new('inline') } + let(:plugin_class) { class_double('Guard::Plugin') } - it "returns the Guard class" do + 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) @@ -207,10 +207,10 @@ class VSpec end end - context "when set to fail gracefully" do + context 'when set to fail gracefully' do options = { fail_gracefully: true } - subject { described_class.new("notAGuardClass") } - it "does not print error messages on fail" do + subject { described_class.new('notAGuardClass') } + it 'does not print error messages on fail' do expect(::Guard::UI).to_not receive(:error) plugin = subject allow(plugin).to receive(:require).and_raise(LoadError) @@ -219,30 +219,30 @@ class VSpec end end - describe "#add_to_guardfile" do + describe '#add_to_guardfile' do before do allow(Guard::Guardfile::Evaluator).to receive(:new).and_return(evaluator) allow(evaluator).to receive(:evaluate) end - context "when the Guard is already in the Guardfile" do + context 'when the Guard is already in the Guardfile' do before do allow(evaluator).to receive(:guardfile_include?) { true } end - it "shows an info message" do + it 'shows an info message' do expect(::Guard::UI).to receive(:info). - with "Guardfile already includes myguard guard" + with 'Guardfile already includes myguard guard' - described_class.new("myguard").add_to_guardfile + described_class.new('myguard').add_to_guardfile end end - context "when Guardfile is empty" do - let(:plugin_util) { described_class.new("myguard") } - let(:plugin_class) { class_double("Guard::Plugin") } - let(:location) { "/Users/me/projects/guard-myguard" } - let(:gem_spec) { instance_double("Gem::Specification") } + context 'when Guardfile is empty' do + let(:plugin_util) { described_class.new('myguard') } + let(:plugin_class) { class_double('Guard::Plugin') } + let(:location) { '/Users/me/projects/guard-myguard' } + let(:gem_spec) { instance_double('Gem::Specification') } let(:io) { StringIO.new } before do @@ -256,26 +256,26 @@ class VSpec and_return(plugin_class) allow(Gem::Specification).to receive(:find_by_name). - with("guard-myguard").and_return(gem_spec) + with('guard-myguard').and_return(gem_spec) allow(plugin_class).to receive(:template).with(location). - and_return("Template content") + and_return('Template content') - allow(File).to receive(:read).with("Guardfile") { "Guardfile content" } - allow(File).to receive(:open).with("Guardfile", "wb").and_yield io + allow(File).to receive(:read).with('Guardfile') { 'Guardfile content' } + allow(File).to receive(:open).with('Guardfile', 'wb').and_yield io end - it "appends the template to the Guardfile" do + it 'appends the template to the Guardfile' do plugin_util.add_to_guardfile expect(io.string).to eq "Guardfile content\n\nTemplate content\n" end end - context "when the Guard is not in the Guardfile" do - let(:plugin_util) { described_class.new("myguard") } - let(:plugin_class) { class_double("Guard::Plugin") } - let(:location) { "/Users/me/projects/guard-myguard" } - let(:gem_spec) { instance_double("Gem::Specification") } + context 'when the Guard is not in the Guardfile' do + let(:plugin_util) { described_class.new('myguard') } + let(:plugin_class) { class_double('Guard::Plugin') } + let(:location) { '/Users/me/projects/guard-myguard' } + let(:gem_spec) { instance_double('Gem::Specification') } let(:io) { StringIO.new } before do @@ -286,16 +286,16 @@ class VSpec and_return(plugin_class) allow(Gem::Specification).to receive(:find_by_name). - with("guard-myguard").and_return(gem_spec) + with('guard-myguard').and_return(gem_spec) allow(plugin_class).to receive(:template).with(location). - and_return("Template content") + and_return('Template content') - allow(File).to receive(:read).with("Guardfile") { "Guardfile content" } - allow(File).to receive(:open).with("Guardfile", "wb").and_yield io + allow(File).to receive(:read).with('Guardfile') { 'Guardfile content' } + allow(File).to receive(:open).with('Guardfile', 'wb').and_yield io end - it "appends the template to the Guardfile" do + it 'appends the template to the Guardfile' do plugin_util.add_to_guardfile expect(io.string).to eq "Guardfile content\n\nTemplate content\n" end diff --git a/spec/lib/guard/runner_spec.rb b/spec/lib/guard/runner_spec.rb index 10a9486c2..958badd23 100644 --- a/spec/lib/guard/runner_spec.rb +++ b/spec/lib/guard/runner_spec.rb @@ -1,25 +1,25 @@ -require "guard/runner" +require 'guard/runner' -require "guard/plugin" +require 'guard/plugin' RSpec.describe Guard::Runner do - let(:ui_config) { instance_double("Guard::UI::Config") } + let(:ui_config) { instance_double('Guard::UI::Config') } let(:backend_group) do - instance_double("Guard::Group", options: {}, name: :backend) + instance_double('Guard::Group', options: {}, name: :backend) end let(:frontend_group) do - instance_double("Guard::Group", options: {}, name: :frontend) + instance_double('Guard::Group', options: {}, name: :frontend) end - let(:foo_plugin) { double("foo", group: backend_group, hook: nil) } - let(:bar_plugin) { double("bar", group: frontend_group, hook: nil) } - let(:baz_plugin) { double("baz", group: frontend_group, hook: nil) } + let(:foo_plugin) { double('foo', group: backend_group, hook: nil) } + let(:bar_plugin) { double('bar', group: frontend_group, hook: nil) } + let(:baz_plugin) { double('baz', group: frontend_group, hook: nil) } - let(:scope) { instance_double("Guard::Internals::Scope") } - let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:state) { instance_double("Guard::Internals::State") } - let(:session) { instance_double("Guard::Internals::Session") } + let(:scope) { instance_double('Guard::Internals::Scope') } + let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double('Guard::Internals::Session') } before do allow(session).to receive(:plugins).and_return(plugins) @@ -39,7 +39,7 @@ Guard::UI.options = nil end - describe "#run" do + describe '#run' do before do allow(scope).to receive(:grouped_plugins).with({}). and_return([[nil, [foo_plugin, bar_plugin, baz_plugin]]]) @@ -47,7 +47,7 @@ allow(ui_config).to receive(:with_progname).and_yield end - it "executes supervised task on all registered plugins implementing it" do + it 'executes supervised task on all registered plugins implementing it' do [foo_plugin, bar_plugin].each do |plugin| expect(plugin).to receive(:my_hard_task) end @@ -55,26 +55,26 @@ subject.run(:my_hard_task) end - it "marks an action as unit of work" do + it 'marks an action as unit of work' do expect(Lumberjack).to receive(:unit_of_work) subject.run(:my_task) end - context "with interrupted task" do + context 'with interrupted task' do before do allow(foo_plugin).to receive(:failing).and_raise(Interrupt) # allow(Guard).to receive(:plugins).and_return([foo_plugin]) end - it "catches the thrown symbol" do + it 'catches the thrown symbol' do expect { subject.run(:failing) }.to_not throw_symbol(:task_has_failed) end end - context "with a scope" do + context 'with a scope' do let(:scope_hash) { { plugin: :bar } } - it "executes the supervised task on the specified plugin only" do + 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]]]) @@ -86,10 +86,10 @@ end end - context "with no scope" do + context 'with no scope' do let(:scope_hash) { nil } - it "executes the supervised task using current scope" do + it 'executes the supervised task using current scope' do expect(bar_plugin).to receive(:my_task) expect(foo_plugin).to receive(:my_task) expect(baz_plugin).to receive(:my_task) @@ -99,7 +99,7 @@ end end - describe "#run_on_changes" do + describe '#run_on_changes' do let(:changes) { [[], [], []] } let(:watcher_module) { Guard::Watcher } @@ -107,22 +107,22 @@ allow(watcher_module).to receive(:match_files) { [] } allow(Guard::UI).to receive(:clear) - allow(foo_plugin).to receive(:regular_without_arg) { fail "not stubbed" } - allow(foo_plugin).to receive(:regular_with_arg) { fail "not stubbed" } - allow(foo_plugin).to receive(:failing) { fail "not stubbed" } + allow(foo_plugin).to receive(:regular_without_arg) { fail 'not stubbed' } + allow(foo_plugin).to receive(:regular_with_arg) { fail 'not stubbed' } + allow(foo_plugin).to receive(:failing) { fail 'not stubbed' } # TODO: runner shouldn't have to know about these - allow(foo_plugin).to receive(:run_on_modifications) { fail "not stubbed" } - allow(foo_plugin).to receive(:run_on_change) { fail "not stubbed" } - allow(foo_plugin).to receive(:run_on_additions) { fail "not stubbed" } - allow(foo_plugin).to receive(:run_on_removals) { fail "not stubbed" } - allow(foo_plugin).to receive(:run_on_deletion) { fail "not stubbed" } + allow(foo_plugin).to receive(:run_on_modifications) { fail 'not stubbed' } + allow(foo_plugin).to receive(:run_on_change) { fail 'not stubbed' } + allow(foo_plugin).to receive(:run_on_additions) { fail 'not stubbed' } + allow(foo_plugin).to receive(:run_on_removals) { fail 'not stubbed' } + allow(foo_plugin).to receive(:run_on_deletion) { fail 'not stubbed' } allow(foo_plugin).to receive(:my_task) allow(bar_plugin).to receive(:my_task) allow(baz_plugin).to receive(:my_task) - allow(foo_plugin).to receive(:name).and_return("Foo") + allow(foo_plugin).to receive(:name).and_return('Foo') allow(scope).to receive(:grouped_plugins) do |args| fail "stub me (#{args.inspect})!" @@ -142,7 +142,7 @@ allow(ui_config).to receive(:with_progname).and_yield end - it "always calls UI.clearable" do + 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]]]) @@ -150,8 +150,8 @@ subject.run_on_changes(*changes) end - context "when clearable" do - it "clear UI" do + 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]]]) @@ -159,8 +159,8 @@ end end - context "with no changes" do - it "does not run any task" do + context 'with no changes' do + it 'does not run any task' do %w( run_on_modifications run_on_change @@ -174,7 +174,7 @@ end end - context "with modified files but modified paths is empty" do + context 'with modified files but modified paths is empty' do let(:modified) { %w(file.txt image.png) } before do @@ -185,13 +185,13 @@ # stub so respond_to? works end - it "does not call run anything" do + it 'does not call run anything' do expect(foo_plugin).to_not receive(:run_on_modifications) subject.run_on_changes(*changes) end end - context "with modified paths" do + context 'with modified paths' do let(:modified) { %w(file.txt image.png) } before do @@ -200,13 +200,13 @@ with(foo_plugin, modified).and_return(modified) end - it "executes the :run_first_task_found task" do + it 'executes the :run_first_task_found task' do expect(foo_plugin).to receive(:run_on_modifications).with(modified) {} subject.run_on_changes(*changes) end end - context "with added files but added paths is empty" do + context 'with added files but added paths is empty' do let(:added) { %w(file.txt image.png) } before do @@ -215,13 +215,13 @@ with(foo_plugin, added).and_return([]) end - it "does not call run anything" do + it 'does not call run anything' do expect(foo_plugin).to_not receive(:run_on_additions) subject.run_on_changes(*changes) end end - context "with added paths" do + context 'with added paths' do let(:added) { %w(file.txt image.png) } before do @@ -230,13 +230,13 @@ with(foo_plugin, added).and_return(added) end - it "executes the :run_on_additions task" do + it 'executes the :run_on_additions task' do expect(foo_plugin).to receive(:run_on_additions).with(added) {} subject.run_on_changes(*changes) end end - context "with non-matching removed paths" do + context 'with non-matching removed paths' do let(:removed) { %w(file.txt image.png) } before do @@ -248,13 +248,13 @@ allow(foo_plugin).to receive(:run_on_removals) end - it "does not call tasks" do + it 'does not call tasks' do expect(foo_plugin).to_not receive(:run_on_removals) subject.run_on_changes(*changes) end end - context "with matching removed paths" do + context 'with matching removed paths' do let(:removed) { %w(file.txt image.png) } before do @@ -263,82 +263,82 @@ with(foo_plugin, removed) { removed } end - it "executes the :run_on_removals task" do + it 'executes the :run_on_removals task' do expect(foo_plugin).to receive(:run_on_removals).with(removed) {} subject.run_on_changes(*changes) end end end - describe "#_supervise" do + describe '#_supervise' do before do allow(ui_config).to receive(:with_progname).and_yield end - it "executes the task on the passed guard" do + it 'executes the task on the passed guard' do expect(foo_plugin).to receive(:my_task) subject.send(:_supervise, foo_plugin, :my_task) end - context "with a task that succeeds" do - context "without any arguments" do + context 'with a task that succeeds' do + context 'without any arguments' do before do allow(foo_plugin).to receive(:regular_without_arg) { true } end - it "does not remove the Guard" do + it 'does not remove the Guard' do expect(plugins).to_not receive(:remove) subject.send(:_supervise, foo_plugin, :regular_without_arg) end - it "returns the result of the task" do + it 'returns the result of the task' do result = subject.send(:_supervise, foo_plugin, :regular_without_arg) expect(result).to be_truthy end - it "calls :begin and :end hooks" do + it 'calls :begin and :end hooks' do expect(foo_plugin).to receive(:hook). - with("regular_without_arg_begin") + with('regular_without_arg_begin') expect(foo_plugin).to receive(:hook). - with("regular_without_arg_end", true) + 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 + it 'passes the result of the supervised method to the :end hook' do expect(foo_plugin).to receive(:hook). - with("regular_without_arg_begin") + with('regular_without_arg_begin') expect(foo_plugin).to receive(:hook). - with("regular_without_arg_end", true) + with('regular_without_arg_end', true) subject.send(:_supervise, foo_plugin, :regular_without_arg) end end - context "with arguments" do + context 'with arguments' do before do allow(foo_plugin).to receive(:regular_with_arg). - with("given_path") { "I'm a success" } + with('given_path') { "I'm a success" } end - it "does not remove the Guard" do + it 'does not remove the Guard' do expect(plugins).to_not receive(:remove) subject.send( :_supervise, foo_plugin, :regular_with_arg, - "given_path" + 'given_path' ) end - it "returns the result of the task" do + it 'returns the result of the task' do result = subject.send( :_supervise, foo_plugin, :regular_with_arg, - "given_path" + 'given_path' ) expect(result).to eq "I'm a success" @@ -346,26 +346,26 @@ end end - context "with a task that throws :task_has_failed" do + context 'with a task that throws :task_has_failed' do before do allow(foo_plugin).to receive(:failing) { throw :task_has_failed } end - context "in a group" do - context "with halt_on_fail: true" do + context 'in a group' do + context 'with halt_on_fail: true' do before { backend_group.options[:halt_on_fail] = true } - it "throws :task_has_failed" do + it 'throws :task_has_failed' do expect do subject.send(:_supervise, foo_plugin, :failing) end.to throw_symbol(:task_has_failed) end end - context "with halt_on_fail: false" do + context 'with halt_on_fail: false' do before { backend_group.options[:halt_on_fail] = false } - it "catches :task_has_failed" do + it 'catches :task_has_failed' do expect do subject.send(:_supervise, foo_plugin, :failing) end.to_not throw_symbol(:task_has_failed) @@ -374,63 +374,63 @@ end end - context "with a task that raises an exception" do + context 'with a task that raises an exception' do before do - allow(foo_plugin).to receive(:failing) { fail "I break your system" } + allow(foo_plugin).to receive(:failing) { fail 'I break your system' } allow(plugins).to receive(:remove).with(foo_plugin) end - it "removes the Guard" do + it 'removes the Guard' do expect(plugins).to receive(:remove).with(foo_plugin) {} subject.send(:_supervise, foo_plugin, :failing) end - it "display an error to the user" do + it 'display an error to the user' do expect(::Guard::UI).to receive :error expect(::Guard::UI).to receive :info subject.send(:_supervise, foo_plugin, :failing) end - it "returns the exception" do + it 'returns the exception' do failing_result = subject.send(:_supervise, foo_plugin, :failing) expect(failing_result).to be_kind_of(Exception) - expect(failing_result.message).to eq "I break your system" + expect(failing_result.message).to eq 'I break your system' end - it "calls the default begin hook but not the default end hook" do - expect(foo_plugin).to receive(:hook).with("failing_begin") - expect(foo_plugin).to_not receive(:hook).with("failing_end") + it 'calls the default begin hook but not the default end hook' do + expect(foo_plugin).to receive(:hook).with('failing_begin') + expect(foo_plugin).to_not receive(:hook).with('failing_end') subject.send(:_supervise, foo_plugin, :failing) end end end - describe ".stopping_symbol_for" do - let(:guard_plugin) { instance_double("Guard::Plugin") } - let(:group) { instance_double("Guard::Group", title: "Foo") } + describe '.stopping_symbol_for' do + let(:guard_plugin) { instance_double('Guard::Plugin') } + let(:group) { instance_double('Guard::Group', title: 'Foo') } before do allow(guard_plugin).to receive(:group).and_return(group) end - context "for a group with :halt_on_fail" do + context 'for a group with :halt_on_fail' do before do allow(group).to receive(:options).and_return(halt_on_fail: true) end - it "returns :no_catch" do + it 'returns :no_catch' do symbol = described_class.stopping_symbol_for(guard_plugin) expect(symbol).to eq :no_catch end end - context "for a group without :halt_on_fail" do + context 'for a group without :halt_on_fail' do before do allow(group).to receive(:options).and_return(halt_on_fail: false) end - it "returns :task_has_failed" do + it 'returns :task_has_failed' do symbol = described_class.stopping_symbol_for(guard_plugin) expect(symbol).to eq :task_has_failed end diff --git a/spec/lib/guard/terminal_spec.rb b/spec/lib/guard/terminal_spec.rb index 871896e74..608af9117 100644 --- a/spec/lib/guard/terminal_spec.rb +++ b/spec/lib/guard/terminal_spec.rb @@ -1,21 +1,21 @@ -require "guard/terminal" +require 'guard/terminal' RSpec.describe Guard::Terminal do subject { described_class } it { is_expected.to respond_to(:clear) } - let(:sheller) { class_double("Shellany::Sheller") } + let(:sheller) { class_double('Shellany::Sheller') } before do - stub_const("Shellany::Sheller", sheller) + stub_const('Shellany::Sheller', sheller) end - describe ".clear" do - context "when on UNIX" do + describe '.clear' do + context 'when on UNIX' do before { allow(Gem).to receive(:win_platform?).and_return(false) } - context "when the clear command exists" do - let(:result) { [0, "\e[H\e[2J", ""] } + context 'when the clear command exists' do + let(:result) { [0, "\e[H\e[2J", ''] } it "clears the screen using 'clear'" do expect(sheller).to receive(:system).with("printf '\33c\e[3J';"). @@ -24,38 +24,38 @@ end end - context "when the clear command fails" do - let(:result) { [nil, nil, "Guard failed to run \"clear;\""] } + context 'when the clear command fails' do + let(:result) { [nil, nil, 'Guard failed to run "clear;"'] } before do allow(sheller).to receive(:system).with("printf '\33c\e[3J';"). and_return(result) end - it "fails" do + it 'fails' do expect { ::Guard::Terminal.clear }. to raise_error(Errno::ENOENT, /Guard failed to run "clear;"/) end end end - context "when on Windows" do + context 'when on Windows' do before { allow(Gem).to receive(:win_platform?).and_return(true) } - it "clears the screen" do - result = [0, "\f", ""] - expect(sheller).to receive(:system).with("cls").and_return(result) + it 'clears the screen' do + result = [0, "\f", ''] + expect(sheller).to receive(:system).with('cls').and_return(result) ::Guard::Terminal.clear end - context "when the clear command fails" do - let(:result) { [nil, nil, "Guard failed to run \"cls\""] } + context 'when the clear command fails' do + let(:result) { [nil, nil, 'Guard failed to run "cls"'] } before do - allow(sheller).to receive(:system).with("cls").and_return(result) + allow(sheller).to receive(:system).with('cls').and_return(result) end - it "fails" do + it 'fails' do expect { ::Guard::Terminal.clear }. to raise_error(Errno::ENOENT, /Guard failed to run "cls"/) end diff --git a/spec/lib/guard/ui/config_spec.rb b/spec/lib/guard/ui/config_spec.rb index 37c48a9d2..4e8e44af4 100644 --- a/spec/lib/guard/ui/config_spec.rb +++ b/spec/lib/guard/ui/config_spec.rb @@ -1,70 +1,70 @@ -require "guard/ui/config" +require 'guard/ui/config' RSpec.describe Guard::UI::Config do - describe "#device" do - context "when not set" do - context "when accessed as a method" do - it "returns $stderr" do + describe '#device' do + context 'when not set' do + context 'when accessed as a method' do + it 'returns $stderr' do expect(subject.device).to be($stderr) end end - context "when accessed as a string" do - it "returns $stderr" do - expect(subject["device"]).to be($stderr) + context 'when accessed as a string' do + it 'returns $stderr' do + expect(subject['device']).to be($stderr) end end - context "when accessed as a symbol" do - it "returns $stderr" do + context 'when accessed as a symbol' do + it 'returns $stderr' do expect(subject[:device]).to be($stderr) end end end end - describe "#logger_config" do + describe '#logger_config' do let(:options) { {} } subject { described_class.new(options) } - let(:logger_config) { instance_double("Guard::UI::Logger::Config") } + let(:logger_config) { instance_double('Guard::UI::Logger::Config') } before do allow(Guard::UI::Logger::Config).to receive(:new). and_return(logger_config) end - context "with defaults" do - it "provides a logger config" do + context 'with defaults' do + it 'provides a logger config' do expect(subject.logger_config).to be(logger_config) end end - context "with deprecated options set" do - context "when set using a string" do - subject { described_class.new('time_format': "foo") } + context 'with deprecated options set' do + context 'when set using a string' do + subject { described_class.new('time_format': 'foo') } - it "passes deprecated options to logger" do + it 'passes deprecated options to logger' do expect(Guard::UI::Logger::Config).to receive(:new). - with(time_format: "foo") + with(time_format: 'foo') subject end - it "provides a logger config" do + it 'provides a logger config' do expect(subject.logger_config).to be(logger_config) end end - context "when set using a symbol" do - let(:options) { { time_format: "foo" } } + context 'when set using a symbol' do + let(:options) { { time_format: 'foo' } } - it "passes deprecated options to logger" do + it 'passes deprecated options to logger' do expect(Guard::UI::Logger::Config).to receive(:new). - with(time_format: "foo") + with(time_format: 'foo') subject end - it "provides a logger config" do + it 'provides a logger config' do expect(subject.logger_config).to be(logger_config) end end diff --git a/spec/lib/guard/ui/logger_spec.rb b/spec/lib/guard/ui/logger_spec.rb index 987881aab..3cc5569f3 100644 --- a/spec/lib/guard/ui/logger_spec.rb +++ b/spec/lib/guard/ui/logger_spec.rb @@ -1,21 +1,21 @@ -require "guard/ui/logger" +require 'guard/ui/logger' RSpec.describe Guard::UI::Logger::Config do - describe "defaults" do - it "flushes device by default" do + describe 'defaults' do + it 'flushes device by default' do expect(subject[:flush_seconds]).to eq(0) end end - describe "#level=" do - context "with a valid value" do + describe '#level=' do + context 'with a valid value' do before do subject.level = Logger::WARN end - it "stores the level" do + it 'stores the level' do expect(subject[:level]).to eq(Logger::WARN) - expect(subject["level"]).to eq(Logger::WARN) + expect(subject['level']).to eq(Logger::WARN) end end end diff --git a/spec/lib/guard/ui_spec.rb b/spec/lib/guard/ui_spec.rb index 657a8f9e1..f1a4c472e 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -1,4 +1,4 @@ -require "guard/notifier" +require 'guard/notifier' # NOTE: this is here so that no UI does not require anything, # since it could be activated by guard plugins during development @@ -6,28 +6,28 @@ # # TODO: regardless, the dependency on Guard.state should be removed # -require "guard/ui" +require 'guard/ui' -require "guard/internals/session" +require 'guard/internals/session' RSpec.describe Guard::UI do - let(:interactor) { instance_double("Guard::Interactor") } - let(:logger) { instance_double("Lumberjack::Logger") } - let(:config) { instance_double("Guard::UI::Config") } - let(:logger_config) { instance_double("Guard::UI::Logger::Config") } + let(:interactor) { instance_double('Guard::Interactor') } + let(:logger) { instance_double('Lumberjack::Logger') } + let(:config) { instance_double('Guard::UI::Config') } + let(:logger_config) { instance_double('Guard::UI::Logger::Config') } - let(:terminal) { class_double("Guard::Terminal") } + let(:terminal) { class_double('Guard::Terminal') } - let(:session) { instance_double("Guard::Internals::Session") } - let(:state) { instance_double("Guard::Internals::State") } - let(:scope) { instance_double("Guard::Internals::Scope") } + let(:session) { instance_double('Guard::Internals::Session') } + let(:state) { instance_double('Guard::Internals::State') } + let(:scope) { instance_double('Guard::Internals::Scope') } before do allow(state).to receive(:scope).and_return(scope) allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) - stub_const("Guard::Terminal", terminal) + stub_const('Guard::Terminal', terminal) allow(Guard::Notifier).to receive(:turn_on) {} @@ -67,19 +67,19 @@ Guard::UI.options = nil end - describe ".logger" do + describe '.logger' do before do allow(config).to receive(:device).and_return(device) end - context "with no logger set yet" do - let(:device) { "foo.log" } + context 'with no logger set yet' do + let(:device) { 'foo.log' } - it "returns the logger instance" do + it 'returns the logger instance' do expect(Guard::UI.logger).to be(logger) end - it "sets the logger device" do + it 'sets the logger device' do expect(Lumberjack::Logger).to receive(:new). with(device, logger_config) @@ -88,13 +88,13 @@ end end - describe ".level=" do + describe '.level=' do before do allow(logger).to receive(:level=) allow(logger_config).to receive(:level=) end - context "when logger is set up" do + context 'when logger is set up' do before { Guard::UI.logger } it "sets the logger's level" do @@ -110,7 +110,7 @@ end end - context "when logger is not set up yet" do + context 'when logger is not set up yet' do before { Guard::UI.reset_logger } it "sets the logger's config level" do @@ -119,7 +119,7 @@ Guard::UI.level = level end - it "does not autocreate the logger" do + it 'does not autocreate the logger' do level = Logger::WARN expect(logger).to_not receive(:level=).with(level) Guard::UI.level = level @@ -127,8 +127,8 @@ end end - describe ".options=" do - let(:new_config) { instance_double("Guard::UI::Config") } + describe '.options=' do + let(:new_config) { instance_double('Guard::UI::Config') } before do allow(Guard::UI::Config).to receive(:new).with(hi: :ho). @@ -137,101 +137,101 @@ allow(new_config).to receive(:[]).with(:hi).and_return(:ho) end - it "sets the logger options" do + it 'sets the logger options' do Guard::UI.options = { hi: :ho } expect(Guard::UI.options[:hi]).to eq :ho end end - shared_examples_for "a logger method" do - it "resets the line with the :reset option" do + shared_examples_for 'a logger method' do + it 'resets the line with the :reset option' do expect(Guard::UI).to receive :reset_line Guard::UI.send(ui_method, input, reset: true) end - it "logs the message with the given severity" do + it 'logs the message with the given severity' do expect(logger).to receive(severity).with(output) Guard::UI.send(ui_method, input) end - context "with the :only option" do + context 'with the :only option' do before { allow(config).to receive(:only).and_return(/A/) } - it "allows logging matching messages" do + it 'allows logging matching messages' do expect(logger).to receive(severity).with(output) - Guard::UI.send(ui_method, input, plugin: "A") + Guard::UI.send(ui_method, input, plugin: 'A') end - it "prevents logging other messages" do + it 'prevents logging other messages' do expect(logger).to_not receive(severity) - Guard::UI.send(ui_method, input, plugin: "B") + Guard::UI.send(ui_method, input, plugin: 'B') end end - context "with the :except option" do + context 'with the :except option' do before { allow(config).to receive(:except).and_return(/A/) } - it "prevents logging matching messages" do + it 'prevents logging matching messages' do expect(logger).to_not receive(severity) - Guard::UI.send(ui_method, input, plugin: "A") + Guard::UI.send(ui_method, input, plugin: 'A') end - it "allows logging other messages" do + it 'allows logging other messages' do expect(logger).to receive(severity).with(output) - Guard::UI.send(ui_method, input, plugin: "B") + Guard::UI.send(ui_method, input, plugin: 'B') end end end - describe ".info" do - it_behaves_like "a logger method" do + describe '.info' do + it_behaves_like 'a logger method' do let(:ui_method) { :info } let(:severity) { :info } - let(:input) { "Info" } - let(:output) { "Info" } + let(:input) { 'Info' } + let(:output) { 'Info' } end end - describe ".warning" do - it_behaves_like "a logger method" do + describe '.warning' do + it_behaves_like 'a logger method' do let(:ui_method) { :warning } let(:severity) { :warn } - let(:input) { "Warning" } + let(:input) { 'Warning' } let(:output) { "\e[0;33mWarning\e[0m" } end end - describe ".error" do - it_behaves_like "a logger method" do + describe '.error' do + it_behaves_like 'a logger method' do let(:ui_method) { :error } let(:severity) { :error } - let(:input) { "Error" } + let(:input) { 'Error' } let(:output) { "\e[0;31mError\e[0m" } end end - describe ".deprecation" do + describe '.deprecation' do before do - allow(ENV).to receive(:[]).with("GUARD_GEM_SILENCE_DEPRECATIONS"). + allow(ENV).to receive(:[]).with('GUARD_GEM_SILENCE_DEPRECATIONS'). and_return(value) end - context "with GUARD_GEM_SILENCE_DEPRECATIONS set to 1" do - let(:value) { "1" } + context 'with GUARD_GEM_SILENCE_DEPRECATIONS set to 1' do + let(:value) { '1' } - it "silences deprecations" do + it 'silences deprecations' do expect(Guard::UI.logger).to_not receive(:warn) - Guard::UI.deprecation "Deprecator message" + Guard::UI.deprecation 'Deprecator message' end end - context "with GUARD_GEM_SILENCE_DEPRECATIONS unset" do + context 'with GUARD_GEM_SILENCE_DEPRECATIONS unset' do let(:value) { nil } - it_behaves_like "a logger method" do + it_behaves_like 'a logger method' do let(:ui_method) { :deprecation } let(:severity) { :warn } - let(:input) { "Deprecated" } + let(:input) { 'Deprecated' } let(:output) do /^\e\[0;33mDeprecated\nDeprecation backtrace: .*\e\[0m$/m end @@ -239,55 +239,55 @@ end end - describe ".debug" do - it_behaves_like "a logger method" do + describe '.debug' do + it_behaves_like 'a logger method' do let(:ui_method) { :debug } let(:severity) { :debug } - let(:input) { "Debug" } + let(:input) { 'Debug' } let(:output) { "\e[0;33mDebug\e[0m" } end end - describe ".clear" do - context "with UI set up and ready" do + describe '.clear' do + context 'with UI set up and ready' do before do allow(session).to receive(:clear?).and_return(false) Guard::UI.reset_and_clear end - context "when clear option is disabled" do - it "does not clear the output" do + context 'when clear option is disabled' do + it 'does not clear the output' do expect(terminal).to_not receive(:clear) Guard::UI.clear end end - context "when clear option is enabled" do + context 'when clear option is enabled' do before do allow(session).to receive(:clear?).and_return(true) end - context "when the screen is marked as needing clearing" do + context 'when the screen is marked as needing clearing' do before { Guard::UI.clearable } - it "clears the output" do + it 'clears the output' do expect(terminal).to receive(:clear) Guard::UI.clear end - it "clears the output only once" do + it 'clears the output only once' do expect(terminal).to receive(:clear).once Guard::UI.clear Guard::UI.clear end - context "when the command fails" do + context 'when the command fails' do before do allow(terminal).to receive(:clear). - and_raise(Errno::ENOENT, "failed to run command") + and_raise(Errno::ENOENT, 'failed to run command') end - it "shows a warning" do + it 'shows a warning' do expect(logger).to receive(:warn) do |arg| expect(arg).to match(/failed to run command/) end @@ -296,18 +296,18 @@ end end - context "when the screen has just been cleared" do + context 'when the screen has just been cleared' do before { Guard::UI.clear } - it "does not clear" do + it 'does not clear' do expect(terminal).to_not receive(:clear) Guard::UI.clear end - context "when forced" do + context 'when forced' do let(:opts) { { force: true } } - it "clears the outputs if forced" do + it 'clears the outputs if forced' do expect(terminal).to receive(:clear) Guard::UI.clear(opts) end @@ -317,45 +317,45 @@ end end - describe ".action_with_scopes" do - let(:rspec) { double("Rspec", title: "Rspec") } - let(:jasmine) { double("Jasmine", title: "Jasmine") } - let(:group) { instance_double("Guard::Group", title: "Frontend") } + describe '.action_with_scopes' do + let(:rspec) { double('Rspec', title: 'Rspec') } + let(:jasmine) { double('Jasmine', title: 'Jasmine') } + let(:group) { instance_double('Guard::Group', title: 'Frontend') } - context "with a plugins scope" do - it "shows the plugin scoped action" do + 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)) - expect(Guard::UI).to receive(:info).with("Reload Rspec, Jasmine") - Guard::UI.action_with_scopes("Reload", plugins: [rspec, jasmine]) + expect(Guard::UI).to receive(:info).with('Reload Rspec, Jasmine') + Guard::UI.action_with_scopes('Reload', plugins: [rspec, jasmine]) end end - context "with a groups scope" do - it "shows the group scoped action" do + 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)) - expect(Guard::UI).to receive(:info).with("Reload Frontend") - Guard::UI.action_with_scopes("Reload", groups: [group]) + expect(Guard::UI).to receive(:info).with('Reload Frontend') + Guard::UI.action_with_scopes('Reload', groups: [group]) end end - context "without a scope" do - context "with a global plugin scope" do - it "shows the global plugin scoped action" do + 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)) - expect(Guard::UI).to receive(:info).with("Reload Rspec, Jasmine") - Guard::UI.action_with_scopes("Reload", {}) + expect(Guard::UI).to receive(:info).with('Reload Rspec, Jasmine') + Guard::UI.action_with_scopes('Reload', {}) end end - context "with a global group scope" do - it "shows the global group scoped action" do + context 'with a global group scope' do + it 'shows the global group scoped action' do allow(scope).to receive(:titles).and_return(%w(Frontend)) - expect(Guard::UI).to receive(:info).with("Reload Frontend") - Guard::UI.action_with_scopes("Reload", {}) + expect(Guard::UI).to receive(:info).with('Reload Frontend') + Guard::UI.action_with_scopes('Reload', {}) end end 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..390791004 100644 --- a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb +++ b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb @@ -1,21 +1,21 @@ -require "guard/watcher/pattern/deprecated_regexp" +require 'guard/watcher/pattern/deprecated_regexp' RSpec.describe Guard::Watcher::Pattern::DeprecatedRegexp do - describe ".deprecated?" do - specify { expect(described_class.new("^spec_helper.rb")).to be_deprecated } - specify { expect(described_class.new("spec_helper.rb$")).to be_deprecated } + describe '.deprecated?' do + specify { expect(described_class.new('^spec_helper.rb')).to be_deprecated } + specify { expect(described_class.new('spec_helper.rb$')).to be_deprecated } end - describe "Matcher returned by .convert" do + describe 'Matcher returned by .convert' do let(:matcher) { Guard::Watcher::Pattern::Matcher } before { allow(matcher).to receive(:new) } { - "^foo.rb" => /^foo.rb/, - "foo.rb$" => /foo.rb$/, + '^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..0b4000789 100644 --- a/spec/lib/guard/watcher/pattern/match_result_spec.rb +++ b/spec/lib/guard/watcher/pattern/match_result_spec.rb @@ -1,44 +1,44 @@ -require "guard/watcher/pattern/match_result" +require 'guard/watcher/pattern/match_result' RSpec.describe Guard::Watcher::Pattern::MatchResult do - let(:match_result) { double("match_data") } - let(:original_value) { "foo/bar.rb" } + let(:match_result) { double('match_data') } + let(:original_value) { 'foo/bar.rb' } subject { described_class.new(match_result, original_value) } - describe "#initialize" do - context "with valid arguments" do - it "does not fail" do + describe '#initialize' do + context 'with valid arguments' do + it 'does not fail' do expect { subject }.to_not raise_error end end end - describe "#[]" do - context "with a valid match" do - let(:match_result) { double("match_data", to_a: %w(foo bar baz)) } + describe '#[]' do + context 'with a valid match' do + let(:match_result) { double('match_data', to_a: %w(foo bar baz)) } - context "when asked for the non-first item" do + context 'when asked for the non-first item' do let(:index) { 1 } - it "returns the value at given index" do - expect(subject[index]).to eq("bar") + it 'returns the value at given index' do + expect(subject[index]).to eq('bar') end end - context "when asked for the first item" do + context 'when asked for the first item' do let(:index) { 0 } - it "returns the full original value" do - expect(subject[index]).to eq("foo/bar.rb") + it 'returns the full original value' do + expect(subject[index]).to eq('foo/bar.rb') end end - context "when asked for a name match via a symbol" do + context 'when asked for a name match via a symbol' do let(:index) { :foo } before do - allow(match_result).to receive(:[]).with(:foo).and_return("baz") + allow(match_result).to receive(:[]).with(:foo).and_return('baz') end - it "returns the value by name" do - expect(subject[index]).to eq("baz") + it 'returns the value by name' do + expect(subject[index]).to eq('baz') end end end diff --git a/spec/lib/guard/watcher/pattern/matcher_spec.rb b/spec/lib/guard/watcher/pattern/matcher_spec.rb index 1f31e80f2..a997eb5c5 100644 --- a/spec/lib/guard/watcher/pattern/matcher_spec.rb +++ b/spec/lib/guard/watcher/pattern/matcher_spec.rb @@ -1,40 +1,40 @@ -require "guard/watcher/pattern/matcher" +require 'guard/watcher/pattern/matcher' RSpec.describe Guard::Watcher::Pattern::Matcher do subject { described_class.new(obj) } - describe "#match" do - let(:expected) { double("match_result") } + describe '#match' do + let(:expected) { double('match_result') } - context "when constructed with valid matcher object" do - let(:obj) { double("matcher") } + context 'when constructed with valid matcher object' do + let(:obj) { double('matcher') } - context "when matched against a Pathname" do + context 'when matched against a Pathname' do before do allow(obj).to receive(:match).and_return(expected) end - let(:filename) { Pathname("foo.rb") } + let(:filename) { Pathname('foo.rb') } - it "returns the match result" do + it 'returns the match result' do expect(subject.match(filename)).to be(expected) end - it "passes the Pathname to the matcher" do + it 'passes the Pathname to the matcher' do allow(obj).to receive(:match).with(filename) subject.match(filename) end end - context "when matched against a String" do + context 'when matched against a String' do before do allow(obj).to receive(:match).and_return(expected) end - let(:filename) { "foo.rb" } + let(:filename) { 'foo.rb' } - it "returns the match result" do + it 'returns the match result' do expect(subject.match(filename)).to be(expected) end - it "passes a Pathname to the matcher" do + it 'passes a Pathname to the matcher' do allow(obj).to receive(:match).with(Pathname(filename)) subject.match(filename) end @@ -42,51 +42,51 @@ end end - describe "#==" do - it "returns true for equal matchers" do + describe '#==' do + it 'returns true for equal matchers' do expect(described_class.new(/spec_helper\.rb/)). to eq(described_class.new(/spec_helper\.rb/)) end - it "returns false for unequal matchers" do + it 'returns false for unequal matchers' do expect(described_class.new(/spec_helper\.rb/)). not_to eq(described_class.new(/spec_helper\.r/)) end end - describe "integration" do - describe "#match result" do + describe 'integration' do + describe '#match result' do subject { described_class.new(obj).match(filename) } - context "when constructed with valid regexp" do + context 'when constructed with valid regexp' do let(:obj) { /foo.rb$/ } - context "when matched file is a string" do - context "when filename matches" do - let(:filename) { "foo.rb" } - specify { expect(subject.to_a).to eq(["foo.rb"]) } + context 'when matched file is a string' do + context 'when filename matches' do + let(:filename) { 'foo.rb' } + specify { expect(subject.to_a).to eq(['foo.rb']) } end - context "when filename does not match" do - let(:filename) { "bar.rb" } + context 'when filename does not match' do + let(:filename) { 'bar.rb' } specify { expect(subject).to be_nil } end end - context "when matched file is an unclean Pathname" do - context "when filename matches" do - let(:filename) { Pathname("./foo.rb") } - specify { expect(subject.to_a).to eq(["foo.rb"]) } + context 'when matched file is an unclean Pathname' do + context 'when filename matches' do + let(:filename) { Pathname('./foo.rb') } + specify { expect(subject.to_a).to eq(['foo.rb']) } end - context "when filename does not match" do - let(:filename) { Pathname("./bar.rb") } + context 'when filename does not match' do + let(:filename) { Pathname('./bar.rb') } specify { expect(subject).to be_nil } end end - context "when matched file contains a $" do - let(:filename) { Pathname("lib$/foo.rb") } - specify { expect(subject.to_a).to eq(["foo.rb"]) } + context 'when matched file contains a $' do + let(:filename) { Pathname('lib$/foo.rb') } + specify { expect(subject.to_a).to eq(['foo.rb']) } end 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..27cf91677 100644 --- a/spec/lib/guard/watcher/pattern/pathname_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/pathname_path_spec.rb @@ -1,32 +1,32 @@ -require "guard/watcher/pattern/pathname_path" +require 'guard/watcher/pattern/pathname_path' RSpec.describe Guard::Watcher::Pattern::PathnamePath do subject { described_class.new(path) } - describe "#match result" do + describe '#match result' do subject { described_class.new(path).match(filename) } - context "when constructed with an unclean Pathname" do - let(:path) { Pathname("./foo.rb") } + context 'when constructed with an unclean Pathname' do + let(:path) { Pathname('./foo.rb') } - context "when matched file is a string" do - context "when filename matches" do - let(:filename) { "foo.rb" } - specify { expect(subject).to eq([Pathname("foo.rb")]) } + context 'when matched file is a string' do + context 'when filename matches' do + let(:filename) { 'foo.rb' } + specify { expect(subject).to eq([Pathname('foo.rb')]) } end - context "when filename does not match" do - let(:filename) { "bar.rb" } + context 'when filename does not match' do + let(:filename) { 'bar.rb' } specify { expect(subject).to be_nil } end end - context "when matched file is an unclean Pathname" do - context "when filename matches" do - let(:filename) { Pathname("./foo.rb") } - specify { expect(subject).to eq([Pathname("foo.rb")]) } + context 'when matched file is an unclean Pathname' do + context 'when filename matches' do + let(:filename) { Pathname('./foo.rb') } + specify { expect(subject).to eq([Pathname('foo.rb')]) } end - context "when filename does not match" do - let(:filename) { Pathname("./bar.rb") } + context 'when filename does not match' do + let(:filename) { Pathname('./bar.rb') } specify { expect(subject).to be_nil } end end diff --git a/spec/lib/guard/watcher/pattern/simple_path_spec.rb b/spec/lib/guard/watcher/pattern/simple_path_spec.rb index 54a44c0d7..954149c02 100644 --- a/spec/lib/guard/watcher/pattern/simple_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/simple_path_spec.rb @@ -1,32 +1,32 @@ -require "guard/watcher/pattern/simple_path" +require 'guard/watcher/pattern/simple_path' RSpec.describe Guard::Watcher::Pattern::SimplePath do subject { described_class.new(path) } - describe "#match result" do - context "when constructed with filename string" do - let(:path) { "foo.rb" } + describe '#match result' do + context 'when constructed with filename string' do + let(:path) { 'foo.rb' } - context "when matched file is a string" do - context "when filename matches" do - let(:filename) { "foo.rb" } - specify { expect(subject.match(filename)).to eq(["foo.rb"]) } + context 'when matched file is a string' do + context 'when filename matches' do + let(:filename) { 'foo.rb' } + specify { expect(subject.match(filename)).to eq(['foo.rb']) } end - context "when filename does not match" do - let(:filename) { "bar.rb" } + context 'when filename does not match' do + let(:filename) { 'bar.rb' } specify { expect(subject.match(filename)).to be_nil } end end - context "when matched file is an unclean Pathname" do - context "when filename matches" do - let(:filename) { Pathname("./foo.rb") } - specify { expect(subject.match(filename)).to eq(["foo.rb"]) } + context 'when matched file is an unclean Pathname' do + context 'when filename matches' do + let(:filename) { Pathname('./foo.rb') } + specify { expect(subject.match(filename)).to eq(['foo.rb']) } end - context "when filename does not match" do - let(:filename) { Pathname("./bar.rb") } + context 'when filename does not match' do + let(:filename) { Pathname('./bar.rb') } specify { expect(subject.match(filename)).to be_nil } end end diff --git a/spec/lib/guard/watcher/pattern_spec.rb b/spec/lib/guard/watcher/pattern_spec.rb index 3db7d5f9f..b8987ba0f 100644 --- a/spec/lib/guard/watcher/pattern_spec.rb +++ b/spec/lib/guard/watcher/pattern_spec.rb @@ -1,35 +1,35 @@ -require "guard/watcher/pattern" +require 'guard/watcher/pattern' RSpec.describe Guard::Watcher::Pattern do - describe ".create" do + describe '.create' do subject { described_class.create(pattern) } - context "when a string is given" do - let(:pattern) { "foo.rb" } + context 'when a string is given' do + let(:pattern) { 'foo.rb' } it { is_expected.to be_a(described_class::SimplePath) } end - context "when a Pathname is given" do - let(:pattern) { Pathname("foo.rb") } + context 'when a Pathname is given' do + let(:pattern) { Pathname('foo.rb') } it { is_expected.to be_a(described_class::PathnamePath) } end - context "when an regexp string is given" do - let(:pattern) { "^foo.*$" } + context 'when an regexp string is given' do + let(:pattern) { '^foo.*$' } it { is_expected.to be_a(described_class::Matcher) } - it "shows a warning" do + it 'shows a warning' do expect(described_class::DeprecatedRegexp). to receive(:show_deprecation).with(pattern) subject end end - context "when a regexp is given" do + context 'when a regexp is given' do let(:pattern) { /foo\.rb/ } it { is_expected.to be_a(described_class::Matcher) } end - context "when a custom matcher" do + context 'when a custom matcher' do let(:pattern) { Class.new { def match; end } } it { is_expected.to be_a(described_class::Matcher) } end diff --git a/spec/lib/guard/watcher_spec.rb b/spec/lib/guard/watcher_spec.rb index e870d7bc8..3567bf1a0 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -1,211 +1,211 @@ -require "guard/watcher" +require 'guard/watcher' # TODO: shouldn't be needed -require "guard/guardfile/evaluator" +require 'guard/guardfile/evaluator' RSpec.describe Guard::Watcher do let(:args) { [] } subject { described_class.new(*args) } - describe "#initialize" do - context "with no arguments" do + describe '#initialize' do + context 'with no arguments' do let(:args) { [] } - it "raises an error" do + it 'raises an error' do expect { subject }.to raise_error(ArgumentError) end end - context "with a pattern parameter" do - let(:pattern) { ["spec_helper.rb"] } + context 'with a pattern parameter' do + let(:pattern) { ['spec_helper.rb'] } let(:args) { [pattern] } - it "creates a matcher" do + it 'creates a matcher' do expect(described_class::Pattern).to receive(:create).with(pattern) subject end end end - describe "#action" do - it "sets the action to nothing by default" do + describe '#action' do + it 'sets the action to nothing by default' do expect(described_class.new(/spec_helper\.rb/).action).to be_nil end - it "sets the action to the supplied block" do + it 'sets the action to the supplied block' do action = ->(m) { "spec/#{m[1]}_spec.rb" } expect(described_class.new(%r{^lib/(.*).rb}, action).action).to eq action end end - describe "#==" do - it "returns true for equal watchers" do + describe '#==' do + it 'returns true for equal watchers' do expect(described_class.new(/spec_helper\.rb/)). to eq(described_class.new(/spec_helper\.rb/)) end - it "returns false for unequal watchers" do + it 'returns false for unequal watchers' do expect(described_class.new(/spec_helper\.rb/)). not_to eq(described_class.new(/spec_helper\.r/)) end end - describe ".match_files" do - let(:plugin) { instance_double("Guard::Plugin", options: {}) } + describe '.match_files' do + let(:plugin) { instance_double('Guard::Plugin', options: {}) } def matched(files) described_class.match_files(plugin, files) end - context "without a watcher action" do + context 'without a watcher action' do before do allow(plugin).to receive(:watchers). and_return([described_class.new(pattern)]) end - context "with a regex pattern" do + context 'with a regex pattern' do let(:pattern) { /.*_spec\.rb/ } - it "returns the paths that matches the regex" do + it 'returns the paths that matches the regex' do 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"] + 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'] end end end - context "with a watcher action without parameter" do - context "for a watcher that matches file strings" do + context 'with a watcher action without parameter' do + context 'for a watcher that matches file strings' do before do klass = described_class allow(plugin).to receive(:watchers).and_return( [ - 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("blank.rb", -> { "" }), - klass.new(/^uptime\.rb/, -> { "" }) + 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('blank.rb', -> { '' }), + klass.new(/^uptime\.rb/, -> { '' }) ] ) end - it "returns a single file specified within the action" do - expect(matched(%w(spec_helper.rb))).to eq ["spec"] + it 'returns a single file specified within the action' do + expect(matched(%w(spec_helper.rb))).to eq ['spec'] end - it "returns multiple files specified within the action" do + it 'returns multiple files specified within the action' do expect(matched(%w(hash.rb))).to eq %w(foo bar) end - it "combines files from results of different actions" do + it 'combines files from results of different actions' do 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 + context 'when action returns non-string or array of non-strings' do + it 'returns nothing' do expect(matched(%w(addition.rb))).to eq [] end end - it "returns nothing if the action response is empty" do + it 'returns nothing if the action response is empty' do expect(matched(%w(blank.rb))).to eq [] end - it "returns nothing if the action returns nothing" do + it 'returns nothing if the action returns nothing' do expect(matched(%w(uptime.rb))).to eq [] end end - context "for a watcher that matches information objects" do + context 'for a watcher that matches information objects' do before do allow(plugin).to receive(:options).and_return(any_return: true) klass = described_class allow(plugin).to receive(:watchers).and_return( [ - 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("blank.rb", -> { "" }), - klass.new(/^uptime\.rb/, -> { "" }) + 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('blank.rb', -> { '' }), + klass.new(/^uptime\.rb/, -> { '' }) ] ) end - it "returns a single file specified within the action" do + 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 end - it "returns multiple files specified within the action" do - expect(matched(%w(hash.rb))).to eq [{ foo: "bar" }] + it 'returns multiple files specified within the action' do + expect(matched(%w(hash.rb))).to eq [{ foo: 'bar' }] end - it "combines the results of different actions" do + it 'combines the results of different actions' do expect(matched(%w(spec_helper.rb array.rb))). - to eq ["spec", %w(foo bar)] + to eq ['spec', %w(foo bar)] end - it "returns the evaluated addition argument in an array" do + 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 end - it "returns nothing if the action response is empty string" do - expect(matched(%w(blank.rb))).to eq [""] + it 'returns nothing if the action response is empty string' do + 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 [""] + it 'returns nothing if the action returns empty string' do + expect(matched(%w(uptime.rb))).to eq [''] end end end - context "with a watcher action that takes a parameter" do - context "for a watcher that matches file strings" do + context 'with a watcher action that takes a parameter' do + context 'for a watcher that matches file strings' do before do klass = described_class allow(plugin).to receive(:watchers).and_return [ 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('hash.rb', ->(_m) { Hash[:foo, 'bar'] }), klass.new(/array(.*)\.rb/, ->(_m) { %w(foo bar) }), - klass.new(/blank(.*)\.rb/, ->(_m) { "" }), - klass.new(/^uptime\.rb/, -> { "" }) + 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"] + it 'returns a substituted single file specified within the action' do + expect(matched(%w(lib/foo.rb))).to eq ['spec/foo_spec.rb'] end - it "returns multiple files specified within the action" do + it 'returns multiple files specified within the action' do expect(matched(%w(hash.rb))).to eq %w(foo bar) end - it "combines results of different actions" do + it 'combines results of different actions' do 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 + it 'returns nothing if action returns non-string or non-string array' do expect(matched(%w(addition.rb))).to eq [] end - it "returns nothing if the action response is empty" do + it 'returns nothing if the action response is empty' do expect(matched(%w(blank.rb))).to eq [] end - it "returns nothing if the action returns nothing" do + it 'returns nothing if the action returns nothing' do expect(matched(%w(uptime.rb))).to eq [] end end - context "for a watcher that matches information objects" do + context 'for a watcher that matches information objects' do before do allow(plugin).to receive(:options).and_return(any_return: true) @@ -214,96 +214,96 @@ def matched(files) [ kl.new(%r{lib/(.*)\.rb}, ->(m) { "spec/#{m[1]}_spec.rb" }), kl.new(/addition(.*)\.rb/, ->(m) { (1 + 1).to_s + m[0] }), - kl.new("hash.rb", ->(m) { { foo: "bar", file_name: m[0] } }), - kl.new(/array(.*)\.rb/, ->(m) { ["foo", "bar", m[0]] }), - kl.new(/blank(.*)\.rb/, ->(_m) { "" }), - kl.new(/^uptime\.rb/, -> { "" }) + kl.new('hash.rb', ->(m) { { foo: 'bar', file_name: m[0] } }), + kl.new(/array(.*)\.rb/, ->(m) { ['foo', 'bar', m[0]] }), + kl.new(/blank(.*)\.rb/, ->(_m) { '' }), + kl.new(/^uptime\.rb/, -> { '' }) ] ) end - it "returns a substituted single file specified within the action" do + it 'returns a substituted single file specified within the action' do expect(matched(%w(lib/foo.rb))).to eq %w(spec/foo_spec.rb) end - it "returns a hash specified within the action" do + it 'returns a hash specified within the action' do expect(matched(%w(hash.rb))).to eq [ - { foo: "bar", file_name: "hash.rb" } + { foo: 'bar', file_name: 'hash.rb' } ] end - it "combinines results of different actions" do + 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)] + 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"] + it 'returns the evaluated addition argument + the path' do + 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 [""] + it 'returns nothing if the action response is empty string' do + 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 [""] + it 'returns nothing if the action returns is IO::NULL' do + expect(matched(%w(uptime.rb))).to eq [''] end end end - context "with an exception that is raised" do + context 'with an exception that is raised' do before do allow(plugin).to receive(:watchers).and_return( - [described_class.new("evil.rb", -> { fail "EVIL" })] + [described_class.new('evil.rb', -> { fail 'EVIL' })] ) end - it "displays the error and backtrace" do + it 'displays the error and backtrace' do expect(Guard::UI).to receive(:error) do |msg| - expect(msg).to include("Problem with watch action!") - expect(msg).to include("EVIL") + expect(msg).to include('Problem with watch action!') + expect(msg).to include('EVIL') end - described_class.match_files(plugin, ["evil.rb"]) + described_class.match_files(plugin, ['evil.rb']) end end - context "for ambiguous watchers" do + context 'for ambiguous watchers' do before do 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('awesome_helper.rb', -> {}), + described_class.new(/.+some_helper.rb/, -> { 'foo.rb' }), + described_class.new(/.+_helper.rb/, -> { 'bar.rb' }), ] end - context "when the :first_match option is turned off" do + context 'when the :first_match option is turned off' do before do allow(plugin).to receive(:options).and_return(first_match: false) end - it "returns multiple files by combining the results of the watchers" do + it 'returns multiple files by combining the results of the watchers' do expect(described_class.match_files( - plugin, ["awesome_helper.rb"] - )).to eq(["foo.rb", "bar.rb"]) + plugin, ['awesome_helper.rb'] + )).to eq(['foo.rb', 'bar.rb']) end end - context "when the :first_match option is turned on" do + context 'when the :first_match option is turned on' do before do plugin.options[:first_match] = true end - it "returns only the files from the first watcher" do + it 'returns only the files from the first watcher' do expect(described_class.match_files( - plugin, ["awesome_helper.rb"] - )).to eq(["foo.rb"]) + plugin, ['awesome_helper.rb'] + )).to eq(['foo.rb']) end end end end - describe "#match" do + describe '#match' do subject { described_class.new(pattern).match(file) } let(:matcher) { instance_double(described_class::Pattern::Matcher) } @@ -320,20 +320,20 @@ def matched(files) with(match_data, file).and_return(match) end - context "with a valid pattern" do - let(:pattern) { "foo.rb" } - context "with a valid file name to match" do - let(:file) { "foo.rb" } - context "when matching is successful" do - let(:match_data) { double("match data", to_a: ["foo"]) } - it "returns the match result" do + context 'with a valid pattern' do + let(:pattern) { 'foo.rb' } + context 'with a valid file name to match' do + let(:file) { 'foo.rb' } + context 'when matching is successful' do + let(:match_data) { double('match data', to_a: ['foo']) } + it 'returns the match result' do expect(subject).to be(match) end end - context "when matching is not successful" do + context 'when matching is not successful' do let(:match_data) { nil } - it "returns nil" do + it 'returns nil' do expect(subject).to be_nil end end @@ -341,20 +341,20 @@ def matched(files) end end - describe "integration" do - describe "#match" do + describe 'integration' do + describe '#match' do subject { described_class.new(pattern) } - context "with a named regexp pattern" do + context 'with a named regexp pattern' do let(:pattern) { /(?.*)_spec\.rb/ } - context "with a watcher that matches a file" do + context 'with a watcher that matches a file' do specify do - expect(subject.match("bar_spec.rb")[0]).to eq("bar_spec.rb") - expect(subject.match("bar_spec.rb")[1]).to eq("bar") + expect(subject.match('bar_spec.rb')[0]).to eq('bar_spec.rb') + expect(subject.match('bar_spec.rb')[1]).to eq('bar') end - it "provides the match by name" do - expect(subject.match("bar_spec.rb")[:foo]).to eq("bar") + it 'provides the match by name' do + expect(subject.match('bar_spec.rb')[:foo]).to eq('bar') end end end diff --git a/spec/lib/guard_spec.rb b/spec/lib/guard_spec.rb index e3f31bccb..fe3ca657a 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -1,19 +1,19 @@ -require "guard" +require 'guard' RSpec.describe Guard do # Initialize before Guard::Interactor const is stubbed - let!(:interactor) { instance_double("Guard::Interactor") } + let!(:interactor) { instance_double('Guard::Interactor') } - let(:guardfile) { File.expand_path("Guardfile") } + let(:guardfile) { File.expand_path('Guardfile') } let(:traps) { Guard::Internals::Traps } - let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } + let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } - let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:scope) { instance_double("Guard::Internals::Scope") } - let(:session) { instance_double("Guard::Internals::Session") } - let(:state) { instance_double("Guard::Internals::State") } - let(:queue) { instance_double("Guard::Internals::Queue") } + let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:scope) { instance_double('Guard::Internals::Scope') } + let(:session) { instance_double('Guard::Internals::Session') } + let(:state) { instance_double('Guard::Internals::State') } + let(:queue) { instance_double('Guard::Internals::Queue') } before do allow(Guard::Interactor).to receive(:new).and_return(interactor) @@ -28,21 +28,21 @@ end # TODO: setup has too many responsibilities - describe ".setup" do + describe '.setup' do subject { Guard.setup(options) } let(:options) { { my_opts: true, guardfile: guardfile } } - let(:listener) { instance_double("Listen::Listener") } + let(:listener) { instance_double('Listen::Listener') } before do allow(Listen).to receive(:to).with(Dir.pwd, {}) { listener } - stub_guardfile(" ") + stub_guardfile(' ') stub_user_guard_rb - g1 = instance_double("Guard::Group", name: :common, options: {}) - g2 = instance_double("Guard::Group", name: :default, options: {}) + g1 = instance_double('Guard::Group', name: :common, options: {}) + g2 = instance_double('Guard::Group', name: :default, options: {}) allow(Guard::Group).to receive(:new).with(:common).and_return(g1) allow(Guard::Group).to receive(:new).with(:default).and_return(g2) @@ -71,59 +71,59 @@ allow(Guard::Internals::State).to receive(:new).and_return(state) end - it "returns itself for chaining" do + it 'returns itself for chaining' do expect(subject).to be Guard end - it "initializes the listener" do + it 'initializes the listener' do allow(Listen).to receive(:to). - with("/foo", latency: 2, wait_for_delay: 1).and_return(listener) + 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 }] + [:to, '/foo', { latency: 2, wait_for_delay: 1 }] ) subject end - it "initializes the interactor" do + it 'initializes the interactor' do expect(Guard::Interactor).to receive(:new).with(false) subject end - context "trapping signals" do + context 'trapping signals' do before do allow(traps).to receive(:handle) end - it "sets up USR1 trap for pausing" do - expect(traps).to receive(:handle).with("USR1") { |_, &b| b.call } + 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]) subject end - it "sets up USR2 trap for unpausing" do - expect(traps).to receive(:handle).with("USR2") { |_, &b| b.call } + 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]) subject end - it "sets up INT trap for cancelling or quitting interactor" do - expect(traps).to receive(:handle).with("INT") { |_, &b| b.call } + it 'sets up INT trap for cancelling or quitting interactor' do + expect(traps).to receive(:handle).with('INT') { |_, &b| b.call } expect(interactor).to receive(:handle_interrupt) subject end end - it "evaluates the Guardfile" do + it 'evaluates the Guardfile' do expect(evaluator).to receive(:evaluate) allow(Guard::Guardfile::Evaluator).to receive(:new).and_return(evaluator) subject end - describe "listener" do + describe 'listener' do subject { listener } context "with ignores 'ignore(/foo/)' and 'ignore!(/bar/)'" do @@ -140,42 +140,42 @@ it { is_expected.to have_received(:ignore!).with([/bar/]) } end - context "without ignores" do + context 'without ignores' do before { Guard.setup(options) } it { is_expected.to_not have_received(:ignore) } it { is_expected.to_not have_received(:ignore!) } end end - it "displays an error message when no guard are defined in Guardfile" do + 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.") + with('No plugins found in Guardfile, please add at least one.') subject end - it "connects to the notifier" do + it 'connects to the notifier' do expect(Guard::Notifier).to receive(:connect).with(notify: true) subject end - context "with the group option" do + context 'with the group option' do let(:options) { { group: %w(frontend backend) } } - it "passes options to session" do + it 'passes options to session' do expect(Guard::Internals::State).to receive(:new).with(options) subject end end - context "with the plugin option" do + context 'with the plugin option' do let(:options) { { plugin: %w(cucumber jasmine) } } - it "passes options to session" do + it 'passes options to session' do expect(Guard::Internals::State).to receive(:new).with(options) subject end end - describe ".interactor" do + describe '.interactor' do subject { Guard::Interactor } before do @@ -183,53 +183,53 @@ Guard.setup(options) end - context "with interactions enabled" do + context 'with interactions enabled' do let(:type) { :pry_wrapper } let(:options) { { no_interactions: false } } it { is_expected.to have_received(:new).with(false) } end - context "with interactions disabled" do + context 'with interactions disabled' do let(:type) { :sleep } let(:options) { { no_interactions: true } } it { is_expected.to have_received(:new).with(true) } end end - describe "UI" do + describe 'UI' do subject { Guard::UI } - context "when clearing is configured" do + context 'when clearing is configured' do before { Guard.setup(options) } it { is_expected.to have_received(:reset_and_clear) } end end end - describe "._relative_pathname" do + describe '._relative_pathname' do subject { Guard.send(:_relative_pathname, raw_path) } - let(:pwd) { Pathname("/project") } + let(:pwd) { Pathname('/project') } before { allow(Pathname).to receive(:pwd).and_return(pwd) } - context "with file in project directory" do - let(:raw_path) { "/project/foo" } - it { is_expected.to eq(Pathname("foo")) } + context 'with file in project directory' do + let(:raw_path) { '/project/foo' } + it { is_expected.to eq(Pathname('foo')) } end - context "with file within project" do - let(:raw_path) { "/project/spec/models/foo_spec.rb" } - it { is_expected.to eq(Pathname("spec/models/foo_spec.rb")) } + context 'with file within project' do + let(:raw_path) { '/project/spec/models/foo_spec.rb' } + it { is_expected.to eq(Pathname('spec/models/foo_spec.rb')) } end - context "with file in parent directory" do - let(:raw_path) { "/foo" } - it { is_expected.to eq(Pathname("../foo")) } + context 'with file in parent directory' do + let(:raw_path) { '/foo' } + it { is_expected.to eq(Pathname('../foo')) } end - context "with file on another drive (e.g. Windows)" do - let(:raw_path) { "d:/project/foo" } + context 'with file on another drive (e.g. Windows)' do + let(:raw_path) { 'd:/project/foo' } let(:pathname) { instance_double(Pathname) } before do @@ -237,11 +237,11 @@ with(pwd).and_raise(ArgumentError) end - it { is_expected.to eq(Pathname.new("d:/project/foo")) } + it { is_expected.to eq(Pathname.new('d:/project/foo')) } end end - describe "#relevant_changes?" do + describe '#relevant_changes?' do pending end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2c0bf7818..fafd6a5b5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,12 +16,12 @@ # users commonly want. # -require "fileutils" +require 'fileutils' -require "simplecov" +require 'simplecov' SimpleCov.start -ENV["GUARD_SPECS_RUNNING"] = "1" +ENV['GUARD_SPECS_RUNNING'] = '1' path = "#{File.expand_path('..', __FILE__)}/support/**/*.rb" Dir[path].each { |f| require f } @@ -29,19 +29,19 @@ # TODO: these shouldn't be necessary with proper specs def stub_guardfile(contents = nil, &block) - stub_file(File.expand_path("Guardfile"), contents, &block) + stub_file(File.expand_path('Guardfile'), contents, &block) end def stub_user_guardfile(contents = nil, &block) - stub_file(File.expand_path("~/.Guardfile"), contents, &block) + stub_file(File.expand_path('~/.Guardfile'), contents, &block) end def stub_user_guard_rb(contents = nil, &block) - stub_file(File.expand_path("~/.guard.rb"), contents, &block) + stub_file(File.expand_path('~/.guard.rb'), contents, &block) end def stub_user_project_guardfile(contents = nil, &block) - stub_file(File.expand_path(".Guardfile"), contents, &block) + stub_file(File.expand_path('.Guardfile'), contents, &block) end def stub_mod(mod, excluded) @@ -114,7 +114,7 @@ def stub_file(path, contents = nil, &block) # `:focus` metadata. When nothing is tagged with `:focus`, all examples # get run. # config.filter_run :focus - config.filter_run focus: ENV["CI"] != "true" + config.filter_run focus: ENV['CI'] != 'true' config.run_all_when_everything_filtered = true @@ -168,7 +168,7 @@ def stub_file(path, contents = nil, &block) end config.before(:each) do |example| - stub_const("FileUtils", class_double(FileUtils)) + stub_const('FileUtils', class_double(FileUtils)) excluded = [] excluded += Array(example.metadata[:exclude_stubs]) @@ -211,25 +211,25 @@ def stub_file(path, contents = nil, &block) end # NOTE: call original, so we can run tests depending on this variable - allow(ENV).to receive(:[]).with("GUARD_STRICT").and_call_original + allow(ENV).to receive(:[]).with('GUARD_STRICT').and_call_original # FIXME: instead, properly stub PluginUtil in the evaluator specs! # and remove this! - allow(ENV).to receive(:[]).with("SPEC_OPTS").and_call_original + allow(ENV).to receive(:[]).with('SPEC_OPTS').and_call_original # FIXME: properly stub out Pry instead of this! - allow(ENV).to receive(:[]).with("ANSICON").and_call_original - allow(ENV).to receive(:[]).with("TERM").and_call_original + allow(ENV).to receive(:[]).with('ANSICON').and_call_original + allow(ENV).to receive(:[]).with('TERM').and_call_original # Needed for debugging - allow(ENV).to receive(:[]).with("DISABLE_PRY").and_call_original - allow(ENV).to receive(:[]).with("PRYRC").and_call_original - allow(ENV).to receive(:[]).with("PAGER").and_call_original + allow(ENV).to receive(:[]).with('DISABLE_PRY').and_call_original + allow(ENV).to receive(:[]).with('PRYRC').and_call_original + allow(ENV).to receive(:[]).with('PAGER').and_call_original # Workarounds for Cli inheriting from Thor - allow(ENV).to receive(:[]).with("ANSICON").and_call_original - allow(ENV).to receive(:[]).with("THOR_SHELL").and_call_original - allow(ENV).to receive(:[]).with("GEM_SKIP").and_call_original + allow(ENV).to receive(:[]).with('ANSICON').and_call_original + 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| allow(File).to receive(meth.to_sym).with(anything) do |*args, &_block| @@ -247,7 +247,7 @@ def stub_file(path, contents = nil, &block) allow_any_instance_of(Pathname). to receive(meth.to_sym) do |*args, &_block| obj = args.first - formatted_args = args[1..-1].map(&:inspect).join(", ") + formatted_args = args[1..-1].map(&:inspect).join(', ') abort "stub me! (#{obj.inspect}##{meth}(#{formatted_args}))" end end @@ -256,7 +256,7 @@ def stub_file(path, contents = nil, &block) abort "stub me! (Dir#exist?(#{args.map(&:inspect) * ', '}))" end - if Guard.const_defined?("UI") && Guard::UI.respond_to?(:info) + if Guard.const_defined?('UI') && Guard::UI.respond_to?(:info) # Stub all UI methods, so no visible output appears for the UI class allow(Guard::UI).to receive(:info) allow(Guard::UI).to receive(:warning) @@ -270,7 +270,7 @@ def stub_file(path, contents = nil, &block) end # TODO: use metadata to stub out all used classes - if Guard.const_defined?("Sheller") + if Guard.const_defined?('Sheller') unless example.metadata[:sheller_specs] allow(Guard::Sheller).to receive(:run) do |*args| fail "stub for Sheller.run() called with: #{args.inspect}" diff --git a/spec/support/gems_helper.rb b/spec/support/gems_helper.rb index ee0d6a250..0cdc51df7 100644 --- a/spec/support/gems_helper.rb +++ b/spec/support/gems_helper.rb @@ -1,19 +1,19 @@ def growl_installed? - require "growl" + require 'growl' true rescue LoadError false end def libnotify_installed? - require "libnotify" + require 'libnotify' true rescue LoadError false end def rbnotifu_installed? - require "rb-notifu" + require 'rb-notifu' true rescue LoadError false diff --git a/spec/support/platform_helper.rb b/spec/support/platform_helper.rb index 9a63849fd..a63d7218c 100644 --- a/spec/support/platform_helper.rb +++ b/spec/support/platform_helper.rb @@ -1,11 +1,11 @@ def mac? - RbConfig::CONFIG["target_os"] =~ /darwin/i + RbConfig::CONFIG['target_os'] =~ /darwin/i end def linux? - RbConfig::CONFIG["target_os"] =~ /linux/i + RbConfig::CONFIG['target_os'] =~ /linux/i end def windows? - RbConfig::CONFIG["target_os"] =~ /mswin|mingw/i + RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i end From b680c6ceac4dcebf2306b0edf3897c9e6f0cfe46 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 08:57:48 +0200 Subject: [PATCH 03/30] Auto correct: Style/FrozenStringLiteralComment --- spec/lib/guard/bin_spec.rb | 1 + spec/lib/guard/cli/environments/bundler_spec.rb | 1 + spec/lib/guard/cli/environments/evaluate_only_spec.rb | 1 + spec/lib/guard/cli/environments/valid_spec.rb | 1 + spec/lib/guard/cli_spec.rb | 1 + spec/lib/guard/commander_spec.rb | 1 + spec/lib/guard/commands/all_spec.rb | 1 + spec/lib/guard/commands/change_spec.rb | 1 + spec/lib/guard/commands/notification_spec.rb | 1 + spec/lib/guard/commands/pause_spec.rb | 1 + spec/lib/guard/commands/reload_spec.rb | 1 + spec/lib/guard/commands/scope_spec.rb | 1 + spec/lib/guard/commands/show_spec.rb | 1 + spec/lib/guard/config_spec.rb | 1 + spec/lib/guard/deprecated/dsl_spec.rb | 1 + spec/lib/guard/deprecated/evaluator_spec.rb | 1 + spec/lib/guard/deprecated/guard_spec.rb | 1 + spec/lib/guard/deprecated/guardfile_spec.rb | 1 + spec/lib/guard/deprecated/watcher_spec.rb | 1 + spec/lib/guard/dsl_describer_spec.rb | 1 + spec/lib/guard/dsl_reader_spec.rb | 1 + spec/lib/guard/dsl_spec.rb | 1 + spec/lib/guard/group_spec.rb | 1 + spec/lib/guard/guardfile/evaluator_spec.rb | 1 + spec/lib/guard/guardfile/generator_spec.rb | 1 + spec/lib/guard/interactor_spec.rb | 1 + spec/lib/guard/internals/debugging_spec.rb | 1 + spec/lib/guard/internals/groups_spec.rb | 1 + spec/lib/guard/internals/plugins_spec.rb | 1 + spec/lib/guard/internals/scope_spec.rb | 1 + spec/lib/guard/internals/session_spec.rb | 1 + spec/lib/guard/internals/state_spec.rb | 1 + spec/lib/guard/internals/tracing_spec.rb | 1 + spec/lib/guard/internals/traps_spec.rb | 1 + spec/lib/guard/jobs/pry_wrapper_spec.rb | 1 + spec/lib/guard/jobs/sleep_spec.rb | 1 + spec/lib/guard/notifier_spec.rb | 1 + spec/lib/guard/options_spec.rb | 1 + spec/lib/guard/plugin_spec.rb | 1 + spec/lib/guard/plugin_util_spec.rb | 1 + spec/lib/guard/runner_spec.rb | 1 + spec/lib/guard/terminal_spec.rb | 1 + spec/lib/guard/ui/config_spec.rb | 1 + spec/lib/guard/ui/logger_spec.rb | 1 + spec/lib/guard/ui_spec.rb | 1 + spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb | 1 + spec/lib/guard/watcher/pattern/match_result_spec.rb | 1 + spec/lib/guard/watcher/pattern/matcher_spec.rb | 1 + spec/lib/guard/watcher/pattern/pathname_path_spec.rb | 1 + spec/lib/guard/watcher/pattern/simple_path_spec.rb | 1 + spec/lib/guard/watcher/pattern_spec.rb | 1 + spec/lib/guard/watcher_spec.rb | 1 + spec/lib/guard_spec.rb | 1 + spec/spec_helper.rb | 1 + spec/support/gems_helper.rb | 1 + spec/support/platform_helper.rb | 1 + 56 files changed, 56 insertions(+) diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index 26b5a5fcb..f1e7a003c 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true path = File.expand_path('../../../../bin/guard', __FILE__) load path diff --git a/spec/lib/guard/cli/environments/bundler_spec.rb b/spec/lib/guard/cli/environments/bundler_spec.rb index 81aff1c9f..19a3aa500 100644 --- a/spec/lib/guard/cli/environments/bundler_spec.rb +++ b/spec/lib/guard/cli/environments/bundler_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/cli/environments/bundler' # TODO: instead of shared examples, use have_received if possible diff --git a/spec/lib/guard/cli/environments/evaluate_only_spec.rb b/spec/lib/guard/cli/environments/evaluate_only_spec.rb index cc8f7acbe..e8dedbd8d 100644 --- a/spec/lib/guard/cli/environments/evaluate_only_spec.rb +++ b/spec/lib/guard/cli/environments/evaluate_only_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/cli/environments/evaluate_only' RSpec.describe Guard::Cli::Environments::EvaluateOnly do diff --git a/spec/lib/guard/cli/environments/valid_spec.rb b/spec/lib/guard/cli/environments/valid_spec.rb index 34a09309e..42b3a81d7 100644 --- a/spec/lib/guard/cli/environments/valid_spec.rb +++ b/spec/lib/guard/cli/environments/valid_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/cli/environments/valid' require 'guard/cli/environments/bundler' diff --git a/spec/lib/guard/cli_spec.rb b/spec/lib/guard/cli_spec.rb index 02520cd61..f1c943dcd 100644 --- a/spec/lib/guard/cli_spec.rb +++ b/spec/lib/guard/cli_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/cli' RSpec.describe Guard::CLI do diff --git a/spec/lib/guard/commander_spec.rb b/spec/lib/guard/commander_spec.rb index bc5b86e54..f1c175525 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/commander' RSpec.describe Guard::Commander do diff --git a/spec/lib/guard/commands/all_spec.rb b/spec/lib/guard/commands/all_spec.rb index f6b4868a6..478ec357c 100644 --- a/spec/lib/guard/commands/all_spec.rb +++ b/spec/lib/guard/commands/all_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/plugin' require 'guard/commands/all' diff --git a/spec/lib/guard/commands/change_spec.rb b/spec/lib/guard/commands/change_spec.rb index ef508217b..672dde193 100644 --- a/spec/lib/guard/commands/change_spec.rb +++ b/spec/lib/guard/commands/change_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/commands/change' RSpec.describe Guard::Commands::Change do diff --git a/spec/lib/guard/commands/notification_spec.rb b/spec/lib/guard/commands/notification_spec.rb index b9ac0b700..cbc3e0994 100644 --- a/spec/lib/guard/commands/notification_spec.rb +++ b/spec/lib/guard/commands/notification_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/commands/notification' RSpec.describe Guard::Commands::Notification do diff --git a/spec/lib/guard/commands/pause_spec.rb b/spec/lib/guard/commands/pause_spec.rb index fabdd235d..6d2d8730e 100644 --- a/spec/lib/guard/commands/pause_spec.rb +++ b/spec/lib/guard/commands/pause_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/commands/pause' RSpec.describe Guard::Commands::Pause do diff --git a/spec/lib/guard/commands/reload_spec.rb b/spec/lib/guard/commands/reload_spec.rb index c23ee7f75..cfe6d13be 100644 --- a/spec/lib/guard/commands/reload_spec.rb +++ b/spec/lib/guard/commands/reload_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/commands/reload' require 'guard/internals/session' diff --git a/spec/lib/guard/commands/scope_spec.rb b/spec/lib/guard/commands/scope_spec.rb index 684a2d818..f7e8cc51a 100644 --- a/spec/lib/guard/commands/scope_spec.rb +++ b/spec/lib/guard/commands/scope_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/commands/scope' require 'guard/internals/session' diff --git a/spec/lib/guard/commands/show_spec.rb b/spec/lib/guard/commands/show_spec.rb index d191529ef..0a6808f7a 100644 --- a/spec/lib/guard/commands/show_spec.rb +++ b/spec/lib/guard/commands/show_spec.rb @@ -1,3 +1,4 @@ +# 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 6faed2c5b..8600cc2a3 100644 --- a/spec/lib/guard/config_spec.rb +++ b/spec/lib/guard/config_spec.rb @@ -1,3 +1,4 @@ +# 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 71f934fa6..85d5bcd4a 100644 --- a/spec/lib/guard/deprecated/dsl_spec.rb +++ b/spec/lib/guard/deprecated/dsl_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/deprecated/evaluator_spec.rb b/spec/lib/guard/deprecated/evaluator_spec.rb index e9d4d4e2d..ab1b0f420 100644 --- a/spec/lib/guard/deprecated/evaluator_spec.rb +++ b/spec/lib/guard/deprecated/evaluator_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/deprecated/guard_spec.rb b/spec/lib/guard/deprecated/guard_spec.rb index 19a7d8647..53f535d7c 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/deprecated/guardfile_spec.rb b/spec/lib/guard/deprecated/guardfile_spec.rb index cdb7ccec4..4ef07a522 100644 --- a/spec/lib/guard/deprecated/guardfile_spec.rb +++ b/spec/lib/guard/deprecated/guardfile_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/deprecated/watcher_spec.rb b/spec/lib/guard/deprecated/watcher_spec.rb index d6fc8e023..6981ac64a 100644 --- a/spec/lib/guard/deprecated/watcher_spec.rb +++ b/spec/lib/guard/deprecated/watcher_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index 036dd505b..e5df445a0 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' diff --git a/spec/lib/guard/dsl_reader_spec.rb b/spec/lib/guard/dsl_reader_spec.rb index 165036583..dcec2b599 100644 --- a/spec/lib/guard/dsl_reader_spec.rb +++ b/spec/lib/guard/dsl_reader_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/dsl_reader' RSpec.describe Guard::DslReader, exclude_stubs: [Guard::Dsl] do diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index c57c32293..8f43617ba 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/plugin' require 'guard/dsl' diff --git a/spec/lib/guard/group_spec.rb b/spec/lib/guard/group_spec.rb index 2577736c3..5f13e3828 100644 --- a/spec/lib/guard/group_spec.rb +++ b/spec/lib/guard/group_spec.rb @@ -1,3 +1,4 @@ +# 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 c67a32ac8..ebbbeb186 100644 --- a/spec/lib/guard/guardfile/evaluator_spec.rb +++ b/spec/lib/guard/guardfile/evaluator_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/guardfile/evaluator' # TODO: shouldn't be necessary diff --git a/spec/lib/guard/guardfile/generator_spec.rb b/spec/lib/guard/guardfile/generator_spec.rb index 280aca844..8b6f3494e 100644 --- a/spec/lib/guard/guardfile/generator_spec.rb +++ b/spec/lib/guard/guardfile/generator_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/guardfile/generator' RSpec.describe Guard::Guardfile::Generator do diff --git a/spec/lib/guard/interactor_spec.rb b/spec/lib/guard/interactor_spec.rb index 66dcc9750..d8e94f463 100644 --- a/spec/lib/guard/interactor_spec.rb +++ b/spec/lib/guard/interactor_spec.rb @@ -1,3 +1,4 @@ +# 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 f71f3ab79..882ec5dcf 100644 --- a/spec/lib/guard/internals/debugging_spec.rb +++ b/spec/lib/guard/internals/debugging_spec.rb @@ -1,3 +1,4 @@ +# 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 73c4f3296..d78a9786e 100644 --- a/spec/lib/guard/internals/groups_spec.rb +++ b/spec/lib/guard/internals/groups_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/internals/groups' RSpec.describe Guard::Internals::Groups do diff --git a/spec/lib/guard/internals/plugins_spec.rb b/spec/lib/guard/internals/plugins_spec.rb index 8faac0269..d66d95afa 100644 --- a/spec/lib/guard/internals/plugins_spec.rb +++ b/spec/lib/guard/internals/plugins_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/internals/plugins' RSpec.describe Guard::Internals::Plugins do diff --git a/spec/lib/guard/internals/scope_spec.rb b/spec/lib/guard/internals/scope_spec.rb index d46b2b082..f9a6951d7 100644 --- a/spec/lib/guard/internals/scope_spec.rb +++ b/spec/lib/guard/internals/scope_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/internals/scope' RSpec.describe Guard::Internals::Scope do diff --git a/spec/lib/guard/internals/session_spec.rb b/spec/lib/guard/internals/session_spec.rb index 807648ef0..f478617da 100644 --- a/spec/lib/guard/internals/session_spec.rb +++ b/spec/lib/guard/internals/session_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/internals/session' RSpec.describe Guard::Internals::Session do diff --git a/spec/lib/guard/internals/state_spec.rb b/spec/lib/guard/internals/state_spec.rb index f6d50a154..c2cdb316b 100644 --- a/spec/lib/guard/internals/state_spec.rb +++ b/spec/lib/guard/internals/state_spec.rb @@ -1,3 +1,4 @@ +# 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 3b537973b..ac5d17131 100644 --- a/spec/lib/guard/internals/tracing_spec.rb +++ b/spec/lib/guard/internals/tracing_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/internals/tracing' RSpec.describe Guard::Internals::Tracing do diff --git a/spec/lib/guard/internals/traps_spec.rb b/spec/lib/guard/internals/traps_spec.rb index 09b9222d8..ee512a3a6 100644 --- a/spec/lib/guard/internals/traps_spec.rb +++ b/spec/lib/guard/internals/traps_spec.rb @@ -1,3 +1,4 @@ +# 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 47ed6d5ad..4577d3310 100644 --- a/spec/lib/guard/jobs/pry_wrapper_spec.rb +++ b/spec/lib/guard/jobs/pry_wrapper_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/jobs/pry_wrapper' RSpec.describe Guard::Jobs::PryWrapper do diff --git a/spec/lib/guard/jobs/sleep_spec.rb b/spec/lib/guard/jobs/sleep_spec.rb index 070d313a2..c6025033e 100644 --- a/spec/lib/guard/jobs/sleep_spec.rb +++ b/spec/lib/guard/jobs/sleep_spec.rb @@ -1,3 +1,4 @@ +# 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 4e80f57b2..98970e86f 100644 --- a/spec/lib/guard/notifier_spec.rb +++ b/spec/lib/guard/notifier_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/notifier' RSpec.describe Guard::Notifier do diff --git a/spec/lib/guard/options_spec.rb b/spec/lib/guard/options_spec.rb index f6ea02fbc..309778abf 100644 --- a/spec/lib/guard/options_spec.rb +++ b/spec/lib/guard/options_spec.rb @@ -1,3 +1,4 @@ +# 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 bae4a7cbd..eb8a691ce 100644 --- a/spec/lib/guard/plugin_spec.rb +++ b/spec/lib/guard/plugin_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/plugin' require 'guard/watcher' diff --git a/spec/lib/guard/plugin_util_spec.rb b/spec/lib/guard/plugin_util_spec.rb index 1a19cca32..c6c93fcf0 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/plugin_util' require 'guard/guardfile/evaluator' diff --git a/spec/lib/guard/runner_spec.rb b/spec/lib/guard/runner_spec.rb index 958badd23..ee0402450 100644 --- a/spec/lib/guard/runner_spec.rb +++ b/spec/lib/guard/runner_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/runner' require 'guard/plugin' diff --git a/spec/lib/guard/terminal_spec.rb b/spec/lib/guard/terminal_spec.rb index 608af9117..9c3a4815d 100644 --- a/spec/lib/guard/terminal_spec.rb +++ b/spec/lib/guard/terminal_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/terminal' RSpec.describe Guard::Terminal do diff --git a/spec/lib/guard/ui/config_spec.rb b/spec/lib/guard/ui/config_spec.rb index 4e8e44af4..515ca7bfe 100644 --- a/spec/lib/guard/ui/config_spec.rb +++ b/spec/lib/guard/ui/config_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/ui/config' RSpec.describe Guard::UI::Config do diff --git a/spec/lib/guard/ui/logger_spec.rb b/spec/lib/guard/ui/logger_spec.rb index 3cc5569f3..003a89ddf 100644 --- a/spec/lib/guard/ui/logger_spec.rb +++ b/spec/lib/guard/ui/logger_spec.rb @@ -1,3 +1,4 @@ +# 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 f1a4c472e..d3c3397f3 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/notifier' # NOTE: this is here so that no UI does not require anything, diff --git a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb index 390791004..15a686a6b 100644 --- a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb +++ b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/watcher/pattern/deprecated_regexp' RSpec.describe Guard::Watcher::Pattern::DeprecatedRegexp do diff --git a/spec/lib/guard/watcher/pattern/match_result_spec.rb b/spec/lib/guard/watcher/pattern/match_result_spec.rb index 0b4000789..3347784ca 100644 --- a/spec/lib/guard/watcher/pattern/match_result_spec.rb +++ b/spec/lib/guard/watcher/pattern/match_result_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/watcher/pattern/match_result' RSpec.describe Guard::Watcher::Pattern::MatchResult do diff --git a/spec/lib/guard/watcher/pattern/matcher_spec.rb b/spec/lib/guard/watcher/pattern/matcher_spec.rb index a997eb5c5..27338f431 100644 --- a/spec/lib/guard/watcher/pattern/matcher_spec.rb +++ b/spec/lib/guard/watcher/pattern/matcher_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/watcher/pattern/matcher' RSpec.describe Guard::Watcher::Pattern::Matcher do diff --git a/spec/lib/guard/watcher/pattern/pathname_path_spec.rb b/spec/lib/guard/watcher/pattern/pathname_path_spec.rb index 27cf91677..4d59245f3 100644 --- a/spec/lib/guard/watcher/pattern/pathname_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/pathname_path_spec.rb @@ -1,3 +1,4 @@ +# 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 954149c02..d0e8b2905 100644 --- a/spec/lib/guard/watcher/pattern/simple_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/simple_path_spec.rb @@ -1,3 +1,4 @@ +# 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 b8987ba0f..608589946 100644 --- a/spec/lib/guard/watcher/pattern_spec.rb +++ b/spec/lib/guard/watcher/pattern_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/watcher/pattern' RSpec.describe Guard::Watcher::Pattern do diff --git a/spec/lib/guard/watcher_spec.rb b/spec/lib/guard/watcher_spec.rb index 3567bf1a0..3f7cbfac2 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard/watcher' # TODO: shouldn't be needed diff --git a/spec/lib/guard_spec.rb b/spec/lib/guard_spec.rb index fe3ca657a..255cec9bf 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'guard' RSpec.describe Guard do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fafd6a5b5..58f597043 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ +# 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 diff --git a/spec/support/gems_helper.rb b/spec/support/gems_helper.rb index 0cdc51df7..c4d28d006 100644 --- a/spec/support/gems_helper.rb +++ b/spec/support/gems_helper.rb @@ -1,3 +1,4 @@ +# 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 a63d7218c..4eaa29b8f 100644 --- a/spec/support/platform_helper.rb +++ b/spec/support/platform_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true def mac? RbConfig::CONFIG['target_os'] =~ /darwin/i end From 87a677a7d14d5c959d791166379b038878cb0cd8 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 08:59:13 +0200 Subject: [PATCH 04/30] Correct: Violations in gemfile --- Gemfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 2c6014e03..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" @@ -19,9 +21,9 @@ group :development do 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 From cf644284c0a3ecc504c45e3a5fa1c7f2b0fe475f Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:10:42 +0200 Subject: [PATCH 05/30] Fix: Unfreeze string literal in failing test --- spec/lib/guard/dsl_describer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index e5df445a0..a2e2bc334 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -29,7 +29,7 @@ stub_const 'Guard::Test', class_double('Guard::Plugin') stub_const 'Guard::Another', class_double('Guard::Plugin') - @output = '' + @output = +'' # Strip escape sequences allow(STDOUT).to receive(:tty?).and_return(false) From 6f3ef4b4c112b6e451c2ce78ac868ac330110227 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:11:08 +0200 Subject: [PATCH 06/30] Auto correct: Layout/DotPosition --- spec/lib/guard/bin_spec.rb | 28 ++--- .../guard/cli/environments/bundler_spec.rb | 4 +- .../cli/environments/evaluate_only_spec.rb | 12 +- spec/lib/guard/cli/environments/valid_spec.rb | 32 +++--- spec/lib/guard/cli_spec.rb | 24 ++-- spec/lib/guard/commander_spec.rb | 16 +-- spec/lib/guard/commands/all_spec.rb | 16 +-- spec/lib/guard/commands/change_spec.rb | 8 +- spec/lib/guard/commands/notification_spec.rb | 4 +- spec/lib/guard/commands/reload_spec.rb | 16 +-- spec/lib/guard/commands/scope_spec.rb | 12 +- spec/lib/guard/deprecated/dsl_spec.rb | 16 +-- spec/lib/guard/deprecated/evaluator_spec.rb | 8 +- spec/lib/guard/deprecated/guard_spec.rb | 100 ++++++++-------- spec/lib/guard/deprecated/guardfile_spec.rb | 20 ++-- spec/lib/guard/deprecated/watcher_spec.rb | 12 +- spec/lib/guard/dsl_describer_spec.rb | 4 +- spec/lib/guard/dsl_spec.rb | 108 +++++++++--------- spec/lib/guard/guardfile/evaluator_spec.rb | 28 ++--- spec/lib/guard/guardfile/generator_spec.rb | 24 ++-- spec/lib/guard/internals/groups_spec.rb | 12 +- spec/lib/guard/internals/plugins_spec.rb | 52 ++++----- spec/lib/guard/internals/scope_spec.rb | 8 +- spec/lib/guard/internals/session_spec.rb | 8 +- spec/lib/guard/jobs/pry_wrapper_spec.rb | 16 +-- spec/lib/guard/notifier_spec.rb | 8 +- spec/lib/guard/plugin_spec.rb | 16 +-- spec/lib/guard/plugin_util_spec.rb | 58 +++++----- spec/lib/guard/runner_spec.rb | 72 ++++++------ spec/lib/guard/terminal_spec.rb | 16 +-- spec/lib/guard/ui/config_spec.rb | 12 +- spec/lib/guard/ui_spec.rb | 24 ++-- .../lib/guard/watcher/pattern/matcher_spec.rb | 8 +- spec/lib/guard/watcher/pattern_spec.rb | 4 +- spec/lib/guard/watcher_spec.rb | 36 +++--- spec/lib/guard_spec.rb | 24 ++-- spec/spec_helper.rb | 8 +- 37 files changed, 437 insertions(+), 437 deletions(-) diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index f1e7a003c..60adb6b69 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -12,8 +12,8 @@ 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) @@ -55,8 +55,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) @@ -68,19 +68,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 @@ -111,8 +111,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 @@ -123,8 +123,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 19a3aa500..25e94aaed 100644 --- a/spec/lib/guard/cli/environments/bundler_spec.rb +++ b/spec/lib/guard/cli/environments/bundler_spec.rb @@ -23,8 +23,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 e8dedbd8d..da2ba14c9 100644 --- a/spec/lib/guard/cli/environments/evaluate_only_spec.rb +++ b/spec/lib/guard/cli/environments/evaluate_only_spec.rb @@ -36,11 +36,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 @@ -53,8 +53,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 42b3a81d7..239dcee1f 100644 --- a/spec/lib/guard/cli/environments/valid_spec.rb +++ b/spec/lib/guard/cli/environments/valid_spec.rb @@ -15,8 +15,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 @@ -25,8 +25,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 @@ -53,8 +53,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 @@ -151,8 +151,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) @@ -179,12 +179,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 @@ -210,8 +210,8 @@ 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 @@ -237,8 +237,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 diff --git a/spec/lib/guard/cli_spec.rb b/spec/lib/guard/cli_spec.rb index f1c943dcd..f430c1cb8 100644 --- a/spec/lib/guard/cli_spec.rb +++ b/spec/lib/guard/cli_spec.rb @@ -12,14 +12,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 @@ -50,8 +50,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 @@ -100,8 +100,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 @@ -120,8 +120,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 f1c175525..b9ed16137 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -50,8 +50,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 @@ -206,8 +206,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 @@ -250,8 +250,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 @@ -261,8 +261,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 478ec357c..e1e5cf113 100644 --- a/spec/lib/guard/commands/all_spec.rb +++ b/spec/lib/guard/commands/all_spec.rb @@ -20,8 +20,8 @@ def self.output 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) @@ -39,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 @@ -51,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 @@ -63,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 672dde193..ddebe5e7d 100644 --- a/spec/lib/guard/commands/change_spec.rb +++ b/spec/lib/guard/commands/change_spec.rb @@ -20,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 @@ -29,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 cbc3e0994..675774e35 100644 --- a/spec/lib/guard/commands/notification_spec.rb +++ b/spec/lib/guard/commands/notification_spec.rb @@ -10,8 +10,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/reload_spec.rb b/spec/lib/guard/commands/reload_spec.rb index cfe6d13be..77eb957b8 100644 --- a/spec/lib/guard/commands/reload_spec.rb +++ b/spec/lib/guard/commands/reload_spec.rb @@ -18,8 +18,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) @@ -37,8 +37,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 @@ -48,8 +48,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 @@ -59,8 +59,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 f7e8cc51a..e7090ab91 100644 --- a/spec/lib/guard/commands/scope_spec.rb +++ b/spec/lib/guard/commands/scope_spec.rb @@ -19,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) @@ -52,8 +52,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 @@ -63,8 +63,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/deprecated/dsl_spec.rb b/spec/lib/guard/deprecated/dsl_spec.rb index 85d5bcd4a..bc32beb93 100644 --- a/spec/lib/guard/deprecated/dsl_spec.rb +++ b/spec/lib/guard/deprecated/dsl_spec.rb @@ -25,13 +25,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) @@ -39,15 +39,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 ab1b0f420..99d42c5ca 100644 --- a/spec/lib/guard/deprecated/evaluator_spec.rb +++ b/spec/lib/guard/deprecated/evaluator_spec.rb @@ -29,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 @@ -42,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 53f535d7c..bb4e801fe 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -45,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 @@ -60,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 @@ -79,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 @@ -114,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 @@ -132,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 @@ -147,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 @@ -156,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 @@ -165,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 @@ -178,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 @@ -200,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 @@ -227,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 @@ -278,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 @@ -296,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 @@ -317,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 @@ -339,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 @@ -357,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 @@ -375,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 @@ -393,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 @@ -409,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 4ef07a522..628e8c854 100644 --- a/spec/lib/guard/deprecated/guardfile_spec.rb +++ b/spec/lib/guard/deprecated/guardfile_spec.rb @@ -22,22 +22,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) @@ -55,8 +55,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 @@ -78,8 +78,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 6981ac64a..4c55aa82e 100644 --- a/spec/lib/guard/deprecated/watcher_spec.rb +++ b/spec/lib/guard/deprecated/watcher_spec.rb @@ -23,19 +23,19 @@ 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) subject.match_guardfile?(files) diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index a2e2bc334..80e806123 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -140,8 +140,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_spec.rb b/spec/lib/guard/dsl_spec.rb index 8f43617ba..f9f477e2a 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -69,8 +69,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 @@ -80,11 +80,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 @@ -147,8 +147,8 @@ def method_for(klass, meth) context 'with interactor options' do 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 @@ -160,8 +160,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) @@ -172,8 +172,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!/ ) @@ -184,8 +184,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!/ ) @@ -200,17 +200,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) @@ -233,8 +233,8 @@ def method_for(klass, meth) 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 @@ -244,8 +244,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 @@ -255,8 +255,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 @@ -266,8 +266,8 @@ 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 @@ -295,8 +295,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 @@ -311,11 +311,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 @@ -348,8 +348,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 @@ -357,11 +357,11 @@ 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 @@ -380,15 +380,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 @@ -491,8 +491,8 @@ def self.call(_plugin, _event, _args) context 'with logger template' do 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 @@ -533,8 +533,8 @@ def self.call(_plugin, _event, _args) context 'with logger except filter from array of symbols and string' do 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 @@ -544,8 +544,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) @@ -561,8 +561,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 diff --git a/spec/lib/guard/guardfile/evaluator_spec.rb b/spec/lib/guard/guardfile/evaluator_spec.rb index ebbbeb186..c09b2663d 100644 --- a/spec/lib/guard/guardfile/evaluator_spec.rb +++ b/spec/lib/guard/guardfile/evaluator_spec.rb @@ -34,8 +34,8 @@ it 'displays an error message and raises original exception' do stub_user_guard_rb - allow(dsl).to receive(:evaluate). - and_raise(Guard::Dsl::Error, + allow(dsl).to receive(:evaluate) + .and_raise(Guard::Dsl::Error, 'Invalid Guardfile, original error is:') expect { subject.evaluate }.to raise_error(Guard::Dsl::Error) @@ -48,8 +48,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 @@ -77,8 +77,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 @@ -111,8 +111,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 @@ -152,8 +152,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 @@ -198,8 +198,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') @@ -210,8 +210,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 8b6f3494e..2a884c539 100644 --- a/spec/lib/guard/guardfile/generator_spec.rb +++ b/spec/lib/guard/guardfile/generator_spec.rb @@ -6,8 +6,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 @@ -36,8 +36,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 @@ -90,18 +90,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 @@ -118,8 +118,8 @@ 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 diff --git a/spec/lib/guard/internals/groups_spec.rb b/spec/lib/guard/internals/groups_spec.rb index d78a9786e..80aff523c 100644 --- a/spec/lib/guard/internals/groups_spec.rb +++ b/spec/lib/guard/internals/groups_spec.rb @@ -22,11 +22,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) @@ -86,8 +86,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 d66d95afa..c6cd631ab 100644 --- a/spec/lib/guard/internals/plugins_spec.rb +++ b/spec/lib/guard/internals/plugins_spec.rb @@ -19,23 +19,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 @@ -60,15 +60,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 @@ -78,8 +78,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 @@ -89,15 +89,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 @@ -107,13 +107,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 f9a6951d7..62f952295 100644 --- a/spec/lib/guard/internals/scope_spec.rb +++ b/spec/lib/guard/internals/scope_spec.rb @@ -62,8 +62,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 @@ -74,8 +74,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 f478617da..89c0b387a 100644 --- a/spec/lib/guard/internals/session_spec.rb +++ b/spec/lib/guard/internals/session_spec.rb @@ -61,11 +61,11 @@ 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)) end diff --git a/spec/lib/guard/jobs/pry_wrapper_spec.rb b/spec/lib/guard/jobs/pry_wrapper_spec.rb index 4577d3310..f9cff660e 100644 --- a/spec/lib/guard/jobs/pry_wrapper_spec.rb +++ b/spec/lib/guard/jobs/pry_wrapper_spec.rb @@ -52,8 +52,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) @@ -143,8 +143,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 @@ -154,8 +154,8 @@ 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 @@ -165,8 +165,8 @@ 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 diff --git a/spec/lib/guard/notifier_spec.rb b/spec/lib/guard/notifier_spec.rb index 98970e86f..11b8ef0b6 100644 --- a/spec/lib/guard/notifier_spec.rb +++ b/spec/lib/guard/notifier_spec.rb @@ -60,8 +60,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 @@ -72,8 +72,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/plugin_spec.rb b/spec/lib/guard/plugin_spec.rb index eb8a691ce..06eba97e5 100644 --- a/spec/lib/guard/plugin_spec.rb +++ b/spec/lib/guard/plugin_spec.rb @@ -94,8 +94,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 @@ -117,8 +117,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 @@ -224,11 +224,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 c6c93fcf0..7f08e63e1 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -26,11 +26,11 @@ instance_double(spec, name: 'gem2', full_gem_path: '/gem2'), 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) @@ -65,9 +65,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 @@ -88,8 +88,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 @@ -117,8 +117,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 @@ -200,8 +200,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 @@ -232,8 +232,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 @@ -247,20 +247,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 @@ -283,14 +283,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 ee0402450..6876b3e69 100644 --- a/spec/lib/guard/runner_spec.rb +++ b/spec/lib/guard/runner_spec.rb @@ -42,8 +42,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 @@ -76,8 +76,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) @@ -130,23 +130,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 @@ -154,8 +154,8 @@ 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 @@ -180,8 +180,8 @@ 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 @@ -197,8 +197,8 @@ 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 @@ -212,8 +212,8 @@ 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 @@ -227,8 +227,8 @@ 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 @@ -242,8 +242,8 @@ 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) @@ -260,8 +260,8 @@ 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 @@ -298,21 +298,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 @@ -320,8 +320,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 9c3a4815d..597a1258a 100644 --- a/spec/lib/guard/terminal_spec.rb +++ b/spec/lib/guard/terminal_spec.rb @@ -19,8 +19,8 @@ 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 @@ -29,13 +29,13 @@ 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 @@ -57,8 +57,8 @@ 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 515ca7bfe..1042eea3f 100644 --- a/spec/lib/guard/ui/config_spec.rb +++ b/spec/lib/guard/ui/config_spec.rb @@ -31,8 +31,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 @@ -46,8 +46,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 @@ -60,8 +60,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_spec.rb b/spec/lib/guard/ui_spec.rb index d3c3397f3..1bf687827 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -81,8 +81,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 @@ -132,8 +132,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 @@ -213,8 +213,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 @@ -284,8 +284,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 @@ -325,8 +325,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]) @@ -335,8 +335,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]) diff --git a/spec/lib/guard/watcher/pattern/matcher_spec.rb b/spec/lib/guard/watcher/pattern/matcher_spec.rb index 27338f431..21503a6ae 100644 --- a/spec/lib/guard/watcher/pattern/matcher_spec.rb +++ b/spec/lib/guard/watcher/pattern/matcher_spec.rb @@ -45,13 +45,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_spec.rb b/spec/lib/guard/watcher/pattern_spec.rb index 608589946..2d75c65a7 100644 --- a/spec/lib/guard/watcher/pattern_spec.rb +++ b/spec/lib/guard/watcher/pattern_spec.rb @@ -19,8 +19,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 3f7cbfac2..c2bcaa8c0 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -39,13 +39,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 @@ -58,8 +58,8 @@ 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 @@ -147,8 +147,8 @@ def matched(files) 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 @@ -189,8 +189,8 @@ def matched(files) 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 @@ -234,8 +234,8 @@ def matched(files) 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 @@ -311,14 +311,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 255cec9bf..248240781 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -77,8 +77,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 }] @@ -98,15 +98,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([: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([:guard_pause, :unpaused]) subject end @@ -131,8 +131,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 @@ -149,8 +149,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 @@ -234,8 +234,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 58f597043..1a7180dc1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -54,8 +54,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) @@ -245,8 +245,8 @@ def stub_file(path, contents = nil, &block) end %w(exist?).each do |meth| - allow_any_instance_of(Pathname). - to receive(meth.to_sym) do |*args, &_block| + 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}))" From e417c40fca840f985e65b9cf587a606aa89ac098 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:13:41 +0200 Subject: [PATCH 07/30] Auto correct: Style/PercentLiteralDelimiters in spec --- spec/lib/guard/bin_spec.rb | 2 +- spec/lib/guard/cli/environments/valid_spec.rb | 10 +-- spec/lib/guard/commander_spec.rb | 2 +- spec/lib/guard/commands/change_spec.rb | 2 +- spec/lib/guard/deprecated/watcher_spec.rb | 6 +- spec/lib/guard/dsl_describer_spec.rb | 2 +- spec/lib/guard/dsl_reader_spec.rb | 10 +-- spec/lib/guard/dsl_spec.rb | 2 +- spec/lib/guard/guardfile/generator_spec.rb | 2 +- spec/lib/guard/internals/scope_spec.rb | 4 +- spec/lib/guard/internals/session_spec.rb | 26 +++---- spec/lib/guard/internals/tracing_spec.rb | 4 +- spec/lib/guard/jobs/pry_wrapper_spec.rb | 8 +-- spec/lib/guard/runner_spec.rb | 16 ++--- spec/lib/guard/ui_spec.rb | 8 +-- .../watcher/pattern/match_result_spec.rb | 2 +- spec/lib/guard/watcher_spec.rb | 68 +++++++++---------- spec/lib/guard_spec.rb | 4 +- spec/spec_helper.rb | 6 +- 19 files changed, 92 insertions(+), 92 deletions(-) diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index 60adb6b69..48219a232 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -18,7 +18,7 @@ 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 diff --git a/spec/lib/guard/cli/environments/valid_spec.rb b/spec/lib/guard/cli/environments/valid_spec.rb index 239dcee1f..c22b3e11f 100644 --- a/spec/lib/guard/cli/environments/valid_spec.rb +++ b/spec/lib/guard/cli/environments/valid_spec.rb @@ -204,7 +204,7 @@ 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 @@ -216,18 +216,18 @@ 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 @@ -246,7 +246,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/commander_spec.rb b/spec/lib/guard/commander_spec.rb index b9ed16137..f34ee3d14 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -34,7 +34,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 diff --git a/spec/lib/guard/commands/change_spec.rb b/spec/lib/guard/commands/change_spec.rb index ddebe5e7d..70a99b328 100644 --- a/spec/lib/guard/commands/change_spec.rb +++ b/spec/lib/guard/commands/change_spec.rb @@ -30,7 +30,7 @@ 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: []) + .with(modified: %w[foo bar baz], added: [], removed: []) FakePry.process('foo', 'bar', 'baz') end diff --git a/spec/lib/guard/deprecated/watcher_spec.rb b/spec/lib/guard/deprecated/watcher_spec.rb index 4c55aa82e..21089fa03 100644 --- a/spec/lib/guard/deprecated/watcher_spec.rb +++ b/spec/lib/guard/deprecated/watcher_spec.rb @@ -37,13 +37,13 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } 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 80e806123..836bfe998 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -65,7 +65,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 diff --git a/spec/lib/guard/dsl_reader_spec.rb b/spec/lib/guard/dsl_reader_spec.rb index dcec2b599..e8fcf0fd8 100644 --- a/spec/lib/guard/dsl_reader_spec.rb +++ b/spec/lib/guard/dsl_reader_spec.rb @@ -2,10 +2,10 @@ 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 @@ -25,7 +25,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 @@ -37,7 +37,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 @@ -47,7 +47,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 f9f477e2a..14a7e2637 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -595,7 +595,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/guardfile/generator_spec.rb b/spec/lib/guard/guardfile/generator_spec.rb index 2a884c539..907e5c711 100644 --- a/spec/lib/guard/guardfile/generator_spec.rb +++ b/spec/lib/guard/guardfile/generator_spec.rb @@ -125,7 +125,7 @@ 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/internals/scope_spec.rb b/spec/lib/guard/internals/scope_spec.rb index 62f952295..6f814aece 100644 --- a/spec/lib/guard/internals/scope_spec.rb +++ b/spec/lib/guard/internals/scope_spec.rb @@ -63,7 +63,7 @@ context 'when set in commandline' do before do allow(session).to receive(:"cmdline_#{scope}s") - .and_return(%w(baz)) + .and_return(%w[baz]) end it 'uses commandline scope' do @@ -75,7 +75,7 @@ context 'when set in Guardfile' do before do allow(session).to receive(:"guardfile_#{scope}_scope") - .and_return(%w(baz)) + .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 89c0b387a..ca0ee4874 100644 --- a/spec/lib/guard/internals/session_spec.rb +++ b/spec/lib/guard/internals/session_spec.rb @@ -44,7 +44,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' } @@ -67,14 +67,14 @@ 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' } @@ -88,7 +88,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 @@ -206,38 +206,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/tracing_spec.rb b/spec/lib/guard/internals/tracing_spec.rb index ac5d17131..650e29aa0 100644 --- a/spec/lib/guard/internals/tracing_spec.rb +++ b/spec/lib/guard/internals/tracing_spec.rb @@ -55,7 +55,7 @@ end context 'with command arguments' do - let(:args) { %w(true 123) } + let(:args) { %w[true 123] } context 'when #system' do let(:meth) { 'system' } @@ -97,7 +97,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/jobs/pry_wrapper_spec.rb b/spec/lib/guard/jobs/pry_wrapper_spec.rb index f9cff660e..ecd8d4ea9 100644 --- a/spec/lib/guard/jobs/pry_wrapper_spec.rb +++ b/spec/lib/guard/jobs/pry_wrapper_spec.rb @@ -33,7 +33,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(*%w[hash stty]) { false } allow(groups).to receive(:all).and_return([]) allow(session).to receive(:groups).and_return(groups) @@ -131,7 +131,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(*%w[hash stty]) { false } allow(scope).to receive(:titles).and_return(['all']) allow(listener).to receive(:paused?).and_return(false) @@ -161,7 +161,7 @@ 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 @@ -172,7 +172,7 @@ 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/runner_spec.rb b/spec/lib/guard/runner_spec.rb index 6876b3e69..d73b8836c 100644 --- a/spec/lib/guard/runner_spec.rb +++ b/spec/lib/guard/runner_spec.rb @@ -162,13 +162,13 @@ 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) @@ -176,7 +176,7 @@ 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 @@ -193,7 +193,7 @@ 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 @@ -208,7 +208,7 @@ 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 @@ -223,7 +223,7 @@ 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 @@ -238,7 +238,7 @@ 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 @@ -256,7 +256,7 @@ 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 diff --git a/spec/lib/guard/ui_spec.rb b/spec/lib/guard/ui_spec.rb index 1bf687827..f83e5dab5 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -326,7 +326,7 @@ 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)) + .and_return(%w[Rspec Jasmine]) expect(Guard::UI).to receive(:info).with('Reload Rspec, Jasmine') Guard::UI.action_with_scopes('Reload', plugins: [rspec, jasmine]) @@ -336,7 +336,7 @@ 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)) + .and_return(%w[Frontend]) expect(Guard::UI).to receive(:info).with('Reload Frontend') Guard::UI.action_with_scopes('Reload', groups: [group]) @@ -346,7 +346,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 @@ -354,7 +354,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/match_result_spec.rb b/spec/lib/guard/watcher/pattern/match_result_spec.rb index 3347784ca..38dc2024f 100644 --- a/spec/lib/guard/watcher/pattern/match_result_spec.rb +++ b/spec/lib/guard/watcher/pattern/match_result_spec.rb @@ -16,7 +16,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_spec.rb b/spec/lib/guard/watcher_spec.rb index c2bcaa8c0..e0ac119ba 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -65,14 +65,14 @@ def matched(files) 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 @@ -86,7 +86,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/, -> { '' }) ] @@ -94,29 +94,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 @@ -130,7 +130,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/, -> { '' }) ] @@ -138,30 +138,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 @@ -174,35 +174,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 @@ -224,30 +224,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 diff --git a/spec/lib/guard_spec.rb b/spec/lib/guard_spec.rb index 248240781..856f69dfa 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -161,7 +161,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 @@ -169,7 +169,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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1a7180dc1..7dd9a43fd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -232,19 +232,19 @@ 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| + %w[exist?].each do |meth| allow_any_instance_of(Pathname) .to receive(meth.to_sym) do |*args, &_block| obj = args.first From fe4e7aa79cf3b7e2fc35a3a3193f67db189ac86d Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:14:32 +0200 Subject: [PATCH 08/30] Auto correct: Layout/EmptyLineAfterMagicComment in spec --- spec/lib/guard/bin_spec.rb | 1 + spec/lib/guard/cli/environments/bundler_spec.rb | 1 + spec/lib/guard/cli/environments/evaluate_only_spec.rb | 1 + spec/lib/guard/cli/environments/valid_spec.rb | 1 + spec/lib/guard/cli_spec.rb | 1 + spec/lib/guard/commander_spec.rb | 1 + spec/lib/guard/commands/all_spec.rb | 1 + spec/lib/guard/commands/change_spec.rb | 1 + spec/lib/guard/commands/notification_spec.rb | 1 + spec/lib/guard/commands/pause_spec.rb | 1 + spec/lib/guard/commands/reload_spec.rb | 1 + spec/lib/guard/commands/scope_spec.rb | 1 + spec/lib/guard/commands/show_spec.rb | 1 + spec/lib/guard/config_spec.rb | 1 + spec/lib/guard/deprecated/dsl_spec.rb | 1 + spec/lib/guard/deprecated/evaluator_spec.rb | 1 + spec/lib/guard/deprecated/guard_spec.rb | 1 + spec/lib/guard/deprecated/guardfile_spec.rb | 1 + spec/lib/guard/deprecated/watcher_spec.rb | 1 + spec/lib/guard/dsl_describer_spec.rb | 1 + spec/lib/guard/dsl_reader_spec.rb | 1 + spec/lib/guard/dsl_spec.rb | 1 + spec/lib/guard/group_spec.rb | 1 + spec/lib/guard/guardfile/evaluator_spec.rb | 1 + spec/lib/guard/guardfile/generator_spec.rb | 1 + spec/lib/guard/interactor_spec.rb | 1 + spec/lib/guard/internals/debugging_spec.rb | 1 + spec/lib/guard/internals/groups_spec.rb | 1 + spec/lib/guard/internals/plugins_spec.rb | 1 + spec/lib/guard/internals/scope_spec.rb | 1 + spec/lib/guard/internals/session_spec.rb | 1 + spec/lib/guard/internals/state_spec.rb | 1 + spec/lib/guard/internals/tracing_spec.rb | 1 + spec/lib/guard/internals/traps_spec.rb | 1 + spec/lib/guard/jobs/pry_wrapper_spec.rb | 1 + spec/lib/guard/jobs/sleep_spec.rb | 1 + spec/lib/guard/notifier_spec.rb | 1 + spec/lib/guard/options_spec.rb | 1 + spec/lib/guard/plugin_spec.rb | 1 + spec/lib/guard/plugin_util_spec.rb | 1 + spec/lib/guard/runner_spec.rb | 1 + spec/lib/guard/terminal_spec.rb | 1 + spec/lib/guard/ui/config_spec.rb | 1 + spec/lib/guard/ui/logger_spec.rb | 1 + spec/lib/guard/ui_spec.rb | 1 + spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb | 1 + spec/lib/guard/watcher/pattern/match_result_spec.rb | 1 + spec/lib/guard/watcher/pattern/matcher_spec.rb | 1 + spec/lib/guard/watcher/pattern/pathname_path_spec.rb | 1 + spec/lib/guard/watcher/pattern/simple_path_spec.rb | 1 + spec/lib/guard/watcher/pattern_spec.rb | 1 + spec/lib/guard/watcher_spec.rb | 1 + spec/lib/guard_spec.rb | 1 + spec/spec_helper.rb | 1 + spec/support/gems_helper.rb | 1 + spec/support/platform_helper.rb | 1 + 56 files changed, 56 insertions(+) diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index 48219a232..9c9f8ac1f 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + path = File.expand_path('../../../../bin/guard', __FILE__) load path diff --git a/spec/lib/guard/cli/environments/bundler_spec.rb b/spec/lib/guard/cli/environments/bundler_spec.rb index 25e94aaed..7f573f7b3 100644 --- a/spec/lib/guard/cli/environments/bundler_spec.rb +++ b/spec/lib/guard/cli/environments/bundler_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/cli/environments/bundler' # TODO: instead of shared examples, use have_received if possible diff --git a/spec/lib/guard/cli/environments/evaluate_only_spec.rb b/spec/lib/guard/cli/environments/evaluate_only_spec.rb index da2ba14c9..d5cb6e6c9 100644 --- a/spec/lib/guard/cli/environments/evaluate_only_spec.rb +++ b/spec/lib/guard/cli/environments/evaluate_only_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/cli/environments/evaluate_only' RSpec.describe Guard::Cli::Environments::EvaluateOnly do diff --git a/spec/lib/guard/cli/environments/valid_spec.rb b/spec/lib/guard/cli/environments/valid_spec.rb index c22b3e11f..5bda9e486 100644 --- a/spec/lib/guard/cli/environments/valid_spec.rb +++ b/spec/lib/guard/cli/environments/valid_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/cli/environments/valid' require 'guard/cli/environments/bundler' diff --git a/spec/lib/guard/cli_spec.rb b/spec/lib/guard/cli_spec.rb index f430c1cb8..5fc1f1663 100644 --- a/spec/lib/guard/cli_spec.rb +++ b/spec/lib/guard/cli_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/cli' RSpec.describe Guard::CLI do diff --git a/spec/lib/guard/commander_spec.rb b/spec/lib/guard/commander_spec.rb index f34ee3d14..bc540a31c 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/commander' RSpec.describe Guard::Commander do diff --git a/spec/lib/guard/commands/all_spec.rb b/spec/lib/guard/commands/all_spec.rb index e1e5cf113..710b38cbe 100644 --- a/spec/lib/guard/commands/all_spec.rb +++ b/spec/lib/guard/commands/all_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/plugin' require 'guard/commands/all' diff --git a/spec/lib/guard/commands/change_spec.rb b/spec/lib/guard/commands/change_spec.rb index 70a99b328..2f6d85944 100644 --- a/spec/lib/guard/commands/change_spec.rb +++ b/spec/lib/guard/commands/change_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/commands/change' RSpec.describe Guard::Commands::Change do diff --git a/spec/lib/guard/commands/notification_spec.rb b/spec/lib/guard/commands/notification_spec.rb index 675774e35..1ee175736 100644 --- a/spec/lib/guard/commands/notification_spec.rb +++ b/spec/lib/guard/commands/notification_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/commands/notification' RSpec.describe Guard::Commands::Notification do diff --git a/spec/lib/guard/commands/pause_spec.rb b/spec/lib/guard/commands/pause_spec.rb index 6d2d8730e..7f2e12c17 100644 --- a/spec/lib/guard/commands/pause_spec.rb +++ b/spec/lib/guard/commands/pause_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/commands/pause' RSpec.describe Guard::Commands::Pause do diff --git a/spec/lib/guard/commands/reload_spec.rb b/spec/lib/guard/commands/reload_spec.rb index 77eb957b8..150153279 100644 --- a/spec/lib/guard/commands/reload_spec.rb +++ b/spec/lib/guard/commands/reload_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/commands/reload' require 'guard/internals/session' diff --git a/spec/lib/guard/commands/scope_spec.rb b/spec/lib/guard/commands/scope_spec.rb index e7090ab91..2a5f5e2b3 100644 --- a/spec/lib/guard/commands/scope_spec.rb +++ b/spec/lib/guard/commands/scope_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/commands/scope' require 'guard/internals/session' diff --git a/spec/lib/guard/commands/show_spec.rb b/spec/lib/guard/commands/show_spec.rb index 0a6808f7a..21108021a 100644 --- a/spec/lib/guard/commands/show_spec.rb +++ b/spec/lib/guard/commands/show_spec.rb @@ -1,4 +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 8600cc2a3..e1bcbf043 100644 --- a/spec/lib/guard/config_spec.rb +++ b/spec/lib/guard/config_spec.rb @@ -1,4 +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 bc32beb93..0ed69c1e9 100644 --- a/spec/lib/guard/deprecated/dsl_spec.rb +++ b/spec/lib/guard/deprecated/dsl_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/deprecated/evaluator_spec.rb b/spec/lib/guard/deprecated/evaluator_spec.rb index 99d42c5ca..18c53b744 100644 --- a/spec/lib/guard/deprecated/evaluator_spec.rb +++ b/spec/lib/guard/deprecated/evaluator_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/deprecated/guard_spec.rb b/spec/lib/guard/deprecated/guard_spec.rb index bb4e801fe..7ba18e7c3 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/deprecated/guardfile_spec.rb b/spec/lib/guard/deprecated/guardfile_spec.rb index 628e8c854..ef3f79b3d 100644 --- a/spec/lib/guard/deprecated/guardfile_spec.rb +++ b/spec/lib/guard/deprecated/guardfile_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/deprecated/watcher_spec.rb b/spec/lib/guard/deprecated/watcher_spec.rb index 21089fa03..01ac6edf4 100644 --- a/spec/lib/guard/deprecated/watcher_spec.rb +++ b/spec/lib/guard/deprecated/watcher_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/config' unless Guard::Config.new.strict? diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index 836bfe998..c5b0a4a46 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -1,5 +1,6 @@ # encoding: utf-8 # frozen_string_literal: true + require 'guard/plugin' require 'guard/dsl_describer' require 'formatador' diff --git a/spec/lib/guard/dsl_reader_spec.rb b/spec/lib/guard/dsl_reader_spec.rb index e8fcf0fd8..d8925b4d7 100644 --- a/spec/lib/guard/dsl_reader_spec.rb +++ b/spec/lib/guard/dsl_reader_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/dsl_reader' RSpec.describe Guard::DslReader, exclude_stubs: [Guard::Dsl] do diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index 14a7e2637..a7e991be6 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/plugin' require 'guard/dsl' diff --git a/spec/lib/guard/group_spec.rb b/spec/lib/guard/group_spec.rb index 5f13e3828..1f0713d5d 100644 --- a/spec/lib/guard/group_spec.rb +++ b/spec/lib/guard/group_spec.rb @@ -1,4 +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 c09b2663d..2fadd02f0 100644 --- a/spec/lib/guard/guardfile/evaluator_spec.rb +++ b/spec/lib/guard/guardfile/evaluator_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/guardfile/evaluator' # TODO: shouldn't be necessary diff --git a/spec/lib/guard/guardfile/generator_spec.rb b/spec/lib/guard/guardfile/generator_spec.rb index 907e5c711..0801d223c 100644 --- a/spec/lib/guard/guardfile/generator_spec.rb +++ b/spec/lib/guard/guardfile/generator_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/guardfile/generator' RSpec.describe Guard::Guardfile::Generator do diff --git a/spec/lib/guard/interactor_spec.rb b/spec/lib/guard/interactor_spec.rb index d8e94f463..17ab806e2 100644 --- a/spec/lib/guard/interactor_spec.rb +++ b/spec/lib/guard/interactor_spec.rb @@ -1,4 +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 882ec5dcf..71210b5b5 100644 --- a/spec/lib/guard/internals/debugging_spec.rb +++ b/spec/lib/guard/internals/debugging_spec.rb @@ -1,4 +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 80aff523c..1b3f8e7ec 100644 --- a/spec/lib/guard/internals/groups_spec.rb +++ b/spec/lib/guard/internals/groups_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/internals/groups' RSpec.describe Guard::Internals::Groups do diff --git a/spec/lib/guard/internals/plugins_spec.rb b/spec/lib/guard/internals/plugins_spec.rb index c6cd631ab..e12ed1995 100644 --- a/spec/lib/guard/internals/plugins_spec.rb +++ b/spec/lib/guard/internals/plugins_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/internals/plugins' RSpec.describe Guard::Internals::Plugins do diff --git a/spec/lib/guard/internals/scope_spec.rb b/spec/lib/guard/internals/scope_spec.rb index 6f814aece..7c6904d08 100644 --- a/spec/lib/guard/internals/scope_spec.rb +++ b/spec/lib/guard/internals/scope_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/internals/scope' RSpec.describe Guard::Internals::Scope do diff --git a/spec/lib/guard/internals/session_spec.rb b/spec/lib/guard/internals/session_spec.rb index ca0ee4874..5081c0a18 100644 --- a/spec/lib/guard/internals/session_spec.rb +++ b/spec/lib/guard/internals/session_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/internals/session' RSpec.describe Guard::Internals::Session do diff --git a/spec/lib/guard/internals/state_spec.rb b/spec/lib/guard/internals/state_spec.rb index c2cdb316b..b870d146e 100644 --- a/spec/lib/guard/internals/state_spec.rb +++ b/spec/lib/guard/internals/state_spec.rb @@ -1,4 +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 650e29aa0..2e7208f8c 100644 --- a/spec/lib/guard/internals/tracing_spec.rb +++ b/spec/lib/guard/internals/tracing_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/internals/tracing' RSpec.describe Guard::Internals::Tracing do diff --git a/spec/lib/guard/internals/traps_spec.rb b/spec/lib/guard/internals/traps_spec.rb index ee512a3a6..077eb197b 100644 --- a/spec/lib/guard/internals/traps_spec.rb +++ b/spec/lib/guard/internals/traps_spec.rb @@ -1,4 +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 ecd8d4ea9..ecc49eece 100644 --- a/spec/lib/guard/jobs/pry_wrapper_spec.rb +++ b/spec/lib/guard/jobs/pry_wrapper_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/jobs/pry_wrapper' RSpec.describe Guard::Jobs::PryWrapper do diff --git a/spec/lib/guard/jobs/sleep_spec.rb b/spec/lib/guard/jobs/sleep_spec.rb index c6025033e..6067b6840 100644 --- a/spec/lib/guard/jobs/sleep_spec.rb +++ b/spec/lib/guard/jobs/sleep_spec.rb @@ -1,4 +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 11b8ef0b6..e1bc91f55 100644 --- a/spec/lib/guard/notifier_spec.rb +++ b/spec/lib/guard/notifier_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/notifier' RSpec.describe Guard::Notifier do diff --git a/spec/lib/guard/options_spec.rb b/spec/lib/guard/options_spec.rb index 309778abf..58f65fa41 100644 --- a/spec/lib/guard/options_spec.rb +++ b/spec/lib/guard/options_spec.rb @@ -1,4 +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 06eba97e5..c52e161d7 100644 --- a/spec/lib/guard/plugin_spec.rb +++ b/spec/lib/guard/plugin_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/plugin' require 'guard/watcher' diff --git a/spec/lib/guard/plugin_util_spec.rb b/spec/lib/guard/plugin_util_spec.rb index 7f08e63e1..b44394646 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/plugin_util' require 'guard/guardfile/evaluator' diff --git a/spec/lib/guard/runner_spec.rb b/spec/lib/guard/runner_spec.rb index d73b8836c..105ec94c7 100644 --- a/spec/lib/guard/runner_spec.rb +++ b/spec/lib/guard/runner_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/runner' require 'guard/plugin' diff --git a/spec/lib/guard/terminal_spec.rb b/spec/lib/guard/terminal_spec.rb index 597a1258a..9546100e0 100644 --- a/spec/lib/guard/terminal_spec.rb +++ b/spec/lib/guard/terminal_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/terminal' RSpec.describe Guard::Terminal do diff --git a/spec/lib/guard/ui/config_spec.rb b/spec/lib/guard/ui/config_spec.rb index 1042eea3f..4bd282d31 100644 --- a/spec/lib/guard/ui/config_spec.rb +++ b/spec/lib/guard/ui/config_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/ui/config' RSpec.describe Guard::UI::Config do diff --git a/spec/lib/guard/ui/logger_spec.rb b/spec/lib/guard/ui/logger_spec.rb index 003a89ddf..add017ac4 100644 --- a/spec/lib/guard/ui/logger_spec.rb +++ b/spec/lib/guard/ui/logger_spec.rb @@ -1,4 +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 f83e5dab5..1fe460790 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/notifier' # NOTE: this is here so that no UI does not require anything, diff --git a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb index 15a686a6b..9b7a11a04 100644 --- a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb +++ b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/watcher/pattern/deprecated_regexp' RSpec.describe Guard::Watcher::Pattern::DeprecatedRegexp do diff --git a/spec/lib/guard/watcher/pattern/match_result_spec.rb b/spec/lib/guard/watcher/pattern/match_result_spec.rb index 38dc2024f..fd72f8543 100644 --- a/spec/lib/guard/watcher/pattern/match_result_spec.rb +++ b/spec/lib/guard/watcher/pattern/match_result_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/watcher/pattern/match_result' RSpec.describe Guard::Watcher::Pattern::MatchResult do diff --git a/spec/lib/guard/watcher/pattern/matcher_spec.rb b/spec/lib/guard/watcher/pattern/matcher_spec.rb index 21503a6ae..46d233d4b 100644 --- a/spec/lib/guard/watcher/pattern/matcher_spec.rb +++ b/spec/lib/guard/watcher/pattern/matcher_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/watcher/pattern/matcher' RSpec.describe Guard::Watcher::Pattern::Matcher do diff --git a/spec/lib/guard/watcher/pattern/pathname_path_spec.rb b/spec/lib/guard/watcher/pattern/pathname_path_spec.rb index 4d59245f3..578ed45af 100644 --- a/spec/lib/guard/watcher/pattern/pathname_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/pathname_path_spec.rb @@ -1,4 +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 d0e8b2905..7d35c65ea 100644 --- a/spec/lib/guard/watcher/pattern/simple_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/simple_path_spec.rb @@ -1,4 +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 2d75c65a7..03cd5f38e 100644 --- a/spec/lib/guard/watcher/pattern_spec.rb +++ b/spec/lib/guard/watcher/pattern_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/watcher/pattern' RSpec.describe Guard::Watcher::Pattern do diff --git a/spec/lib/guard/watcher_spec.rb b/spec/lib/guard/watcher_spec.rb index e0ac119ba..30b643eae 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard/watcher' # TODO: shouldn't be needed diff --git a/spec/lib/guard_spec.rb b/spec/lib/guard_spec.rb index 856f69dfa..bed27b1d0 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'guard' RSpec.describe Guard do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7dd9a43fd..ae18d4805 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +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 diff --git a/spec/support/gems_helper.rb b/spec/support/gems_helper.rb index c4d28d006..09560a1f0 100644 --- a/spec/support/gems_helper.rb +++ b/spec/support/gems_helper.rb @@ -1,4 +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 4eaa29b8f..ce5f53778 100644 --- a/spec/support/platform_helper.rb +++ b/spec/support/platform_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + def mac? RbConfig::CONFIG['target_os'] =~ /darwin/i end From b80411abdd418dc607fabf6f9f853150bb282695 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:16:45 +0200 Subject: [PATCH 09/30] Auto correct: Style/SymbolArray in spec --- spec/lib/guard/dsl_spec.rb | 4 ++-- spec/lib/guard/internals/groups_spec.rb | 2 +- spec/lib/guard/internals/scope_spec.rb | 2 +- spec/lib/guard/plugin_spec.rb | 4 ++-- spec/lib/guard/plugin_util_spec.rb | 10 +++++----- spec/lib/guard_spec.rb | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index a7e991be6..1e04c9724 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -440,7 +440,7 @@ def self.call(_plugin, _event, _args) ' with foo!' callback_1 = opt[:callbacks][1] - expect(callback_1[:events]).to eq [:start_begin, :run_all_begin] + expect(callback_1[:events]).to eq %i[start_begin run_all_begin] expect(callback_1[:listener]).to eq MyCustomCallback end @@ -581,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 diff --git a/spec/lib/guard/internals/groups_spec.rb b/spec/lib/guard/internals/groups_spec.rb index 1b3f8e7ec..d2e368250 100644 --- a/spec/lib/guard/internals/groups_spec.rb +++ b/spec/lib/guard/internals/groups_spec.rb @@ -14,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 diff --git a/spec/lib/guard/internals/scope_spec.rb b/spec/lib/guard/internals/scope_spec.rb index 7c6904d08..a4387765d 100644 --- a/spec/lib/guard/internals/scope_spec.rb +++ b/spec/lib/guard/internals/scope_spec.rb @@ -42,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) diff --git a/spec/lib/guard/plugin_spec.rb b/spec/lib/guard/plugin_spec.rb index c52e161d7..98d318d90 100644 --- a/spec/lib/guard/plugin_spec.rb +++ b/spec/lib/guard/plugin_spec.rb @@ -56,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) @@ -141,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) diff --git a/spec/lib/guard/plugin_util_spec.rb b/spec/lib/guard/plugin_util_spec.rb index b44394646..2a958b042 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -98,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 diff --git a/spec/lib/guard_spec.rb b/spec/lib/guard_spec.rb index bed27b1d0..004874b2c 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -100,14 +100,14 @@ 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]) + .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]) + .with(%i[guard_pause unpaused]) subject end From fb32fe9111e24d3c276a876d8e9c283ae2203226 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:17:28 +0200 Subject: [PATCH 10/30] Auto correct: Layout/MultilineMethodCallIndentation in spec --- spec/lib/guard/bin_spec.rb | 6 +++--- spec/lib/guard/cli/environments/bundler_spec.rb | 2 +- spec/lib/guard/cli/environments/valid_spec.rb | 4 ++-- spec/lib/guard/cli_spec.rb | 6 +++--- spec/lib/guard/commander_spec.rb | 2 +- spec/lib/guard/commands/all_spec.rb | 2 +- spec/lib/guard/commands/reload_spec.rb | 2 +- spec/lib/guard/commands/scope_spec.rb | 2 +- spec/lib/guard/deprecated/guard_spec.rb | 2 +- spec/lib/guard/deprecated/watcher_spec.rb | 2 +- spec/lib/guard/dsl_spec.rb | 6 +++--- spec/lib/guard/guardfile/generator_spec.rb | 2 +- spec/lib/guard/internals/groups_spec.rb | 6 +++--- spec/lib/guard/internals/plugins_spec.rb | 12 ++++++------ spec/lib/guard/internals/session_spec.rb | 4 ++-- spec/lib/guard/plugin_util_spec.rb | 12 ++++++------ spec/lib/guard/runner_spec.rb | 16 ++++++++-------- spec/lib/guard/terminal_spec.rb | 4 ++-- spec/lib/guard/ui_spec.rb | 8 ++++---- spec/lib/guard/watcher_spec.rb | 4 ++-- 20 files changed, 52 insertions(+), 52 deletions(-) diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index 9c9f8ac1f..d3cee33fc 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -81,7 +81,7 @@ .with(Pathname('/my/project/Gemfile')).and_return(false) allow(config).to receive(:exist?).with(Pathname('Gemfile')) - .and_return(false) + .and_return(false) end it 'does not setup bundler' do @@ -113,7 +113,7 @@ context 'when Gemfile exists' do before do allow(config).to receive(:exist?).with(Pathname('Gemfile')) - .and_return(true) + .and_return(true) end it 'shows a warning' do @@ -125,7 +125,7 @@ context 'when no Gemfile exists' do before do allow(config).to receive(:exist?).with(Pathname('Gemfile')) - .and_return(false) + .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 7f573f7b3..ac32e8b6f 100644 --- a/spec/lib/guard/cli/environments/bundler_spec.rb +++ b/spec/lib/guard/cli/environments/bundler_spec.rb @@ -25,7 +25,7 @@ allow(ENV).to receive(:[]).with('RUBYGEMS_GEMDEPS').and_return(gemdeps) allow(File).to receive(:exist?).with('Gemfile') - .and_return(gemfile_present) + .and_return(gemfile_present) subject.verify end diff --git a/spec/lib/guard/cli/environments/valid_spec.rb b/spec/lib/guard/cli/environments/valid_spec.rb index 5bda9e486..8133a3720 100644 --- a/spec/lib/guard/cli/environments/valid_spec.rb +++ b/spec/lib/guard/cli/environments/valid_spec.rb @@ -27,7 +27,7 @@ allow(bundler).to receive(:verify) allow(options).to receive(:[]).with(:no_bundler_warning) - .and_return(false) + .and_return(false) end it 'starts guard' do @@ -239,7 +239,7 @@ 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') + .and_raise(Guard::Guardfile::Generator::NoSuchPlugin, 'foo') end it 'returns an exit code' do diff --git a/spec/lib/guard/cli_spec.rb b/spec/lib/guard/cli_spec.rb index 5fc1f1663..3cc4ee6dc 100644 --- a/spec/lib/guard/cli_spec.rb +++ b/spec/lib/guard/cli_spec.rb @@ -14,7 +14,7 @@ @options = {} allow(subject).to receive(:options).and_return(@options) allow(::Guard::DslDescriber).to receive(:new).with(no_args) - .and_return(dsl_describer) + .and_return(dsl_describer) allow(Guard::Cli::Environments::EvaluateOnly).to receive(:new) .and_return(bare_environment) @@ -52,7 +52,7 @@ pending 'needs JRuby support first' if defined?(JRUBY_VERSION) expect(Guard::Cli::Environments::Valid).to receive(:new).with(@options) - .and_return(valid_environment) + .and_return(valid_environment) begin subject.start rescue SystemExit @@ -122,7 +122,7 @@ it 'passes options' do expect(Guard::Cli::Environments::Valid).to receive(:new).with(@options) - .and_return(valid_environment) + .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 bc540a31c..dcc12b4c7 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -263,7 +263,7 @@ before do allow(Guard::DslDescriber).to receive(:new).with(no_args) - .and_return(dsl_describer) + .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 710b38cbe..6c18661ae 100644 --- a/spec/lib/guard/commands/all_spec.rb +++ b/spec/lib/guard/commands/all_spec.rb @@ -22,7 +22,7 @@ def self.output before do allow(session).to receive(:convert_scope).with(given_scope) - .and_return(converted_scope) + .and_return(converted_scope) allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) diff --git a/spec/lib/guard/commands/reload_spec.rb b/spec/lib/guard/commands/reload_spec.rb index 150153279..a286e0eb6 100644 --- a/spec/lib/guard/commands/reload_spec.rb +++ b/spec/lib/guard/commands/reload_spec.rb @@ -20,7 +20,7 @@ def self.output; end before do allow(session).to receive(:convert_scope).with(given_scope) - .and_return(converted_scope) + .and_return(converted_scope) allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) diff --git a/spec/lib/guard/commands/scope_spec.rb b/spec/lib/guard/commands/scope_spec.rb index 2a5f5e2b3..8da0c6296 100644 --- a/spec/lib/guard/commands/scope_spec.rb +++ b/spec/lib/guard/commands/scope_spec.rb @@ -21,7 +21,7 @@ def self.output; end before do allow(session).to receive(:convert_scope).with(given_scope) - .and_return(converted_scope) + .and_return(converted_scope) allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) diff --git a/spec/lib/guard/deprecated/guard_spec.rb b/spec/lib/guard/deprecated/guard_spec.rb index 7ba18e7c3..77e7304f7 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -81,7 +81,7 @@ def self._pluginless_guardfile? before do allow(Guard::PluginUtil).to receive(:new).with('rspec') - .and_return(plugin_util) + .and_return(plugin_util) end it 'displays a deprecation warning to the user' do diff --git a/spec/lib/guard/deprecated/watcher_spec.rb b/spec/lib/guard/deprecated/watcher_spec.rb index 01ac6edf4..0f26c5c27 100644 --- a/spec/lib/guard/deprecated/watcher_spec.rb +++ b/spec/lib/guard/deprecated/watcher_spec.rb @@ -28,7 +28,7 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } .and_return(File.expand_path('foo')) allow(::Guard::Guardfile::Evaluator).to receive(:new).with(options) - .and_return(evaluator) + .and_return(evaluator) allow(Guard::UI).to receive(:deprecation) end diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index 1e04c9724..4635be981 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -359,10 +359,10 @@ def method_for(klass, meth) end allow(Guard::Watcher).to receive(:new).with('a', anything) - .and_return(watcher_a) + .and_return(watcher_a) allow(Guard::Watcher).to receive(:new).with('c', nil) - .and_return(watcher_c) + .and_return(watcher_c) evaluator.call(contents) end @@ -389,7 +389,7 @@ def method_for(klass, meth) end allow(Guard::Watcher).to receive(:new).with('a', nil) - .and_return(watcher) + .and_return(watcher) evaluator.call(contents) end diff --git a/spec/lib/guard/guardfile/generator_spec.rb b/spec/lib/guard/guardfile/generator_spec.rb index 0801d223c..7eff812b4 100644 --- a/spec/lib/guard/guardfile/generator_spec.rb +++ b/spec/lib/guard/guardfile/generator_spec.rb @@ -102,7 +102,7 @@ allow(plugin_util).to receive(:plugin_class).with(fail_gracefully: true) allow(Guard::PluginUtil).to receive(:new).with('bar') - .and_return(plugin_util) + .and_return(plugin_util) described_class.new.initialize_template('bar') end diff --git a/spec/lib/guard/internals/groups_spec.rb b/spec/lib/guard/internals/groups_spec.rb index d2e368250..c059bdeac 100644 --- a/spec/lib/guard/internals/groups_spec.rb +++ b/spec/lib/guard/internals/groups_spec.rb @@ -24,10 +24,10 @@ before do allow(Guard::Group).to receive(:new).with(:frontend, {}) - .and_return(frontend) + .and_return(frontend) allow(Guard::Group).to receive(:new).with(:backend, {}) - .and_return(backend) + .and_return(backend) subject.add(:frontend) subject.add(:backend) @@ -88,7 +88,7 @@ before do allow(Guard::Group).to receive(:new).with('frontend', {}) - .and_return(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 e12ed1995..a11b17230 100644 --- a/spec/lib/guard/internals/plugins_spec.rb +++ b/spec/lib/guard/internals/plugins_spec.rb @@ -21,22 +21,22 @@ def stub_plugin(name, group) before do allow(Guard::PluginUtil).to receive(:new).with('foobar') - .and_return(pu_foobar) + .and_return(pu_foobar) allow(Guard::PluginUtil).to receive(:new).with('foobaz') - .and_return(pu_foobaz) + .and_return(pu_foobaz) allow(pu_foobar).to receive(:initialize_plugin).with(group: 'frontend') - .and_return(foo_bar_frontend) + .and_return(foo_bar_frontend) allow(pu_foobaz).to receive(:initialize_plugin).with(group: 'frontend') - .and_return(foo_baz_frontend) + .and_return(foo_baz_frontend) allow(pu_foobar).to receive(:initialize_plugin).with(group: 'backend') - .and_return(foo_bar_backend) + .and_return(foo_bar_backend) allow(pu_foobaz).to receive(:initialize_plugin).with(group: 'backend') - .and_return(foo_baz_backend) + .and_return(foo_baz_backend) end describe '#all' do diff --git a/spec/lib/guard/internals/session_spec.rb b/spec/lib/guard/internals/session_spec.rb index 5081c0a18..454b7324d 100644 --- a/spec/lib/guard/internals/session_spec.rb +++ b/spec/lib/guard/internals/session_spec.rb @@ -63,10 +63,10 @@ it 'initializes the plugin scope' do allow(plugins).to receive(:add).with('cucumber', {}) - .and_return(cucumber) + .and_return(cucumber) allow(plugins).to receive(:add).with('jasmine', {}) - .and_return(jasmine) + .and_return(jasmine) expect(subject.cmdline_plugins).to match_array(%w[cucumber jasmine]) end diff --git a/spec/lib/guard/plugin_util_spec.rb b/spec/lib/guard/plugin_util_spec.rb index 2a958b042..ab3e877c0 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -119,7 +119,7 @@ plugin = described_class.new('notAGuardClass') allow(plugin).to receive(:require).with('guard/notaguardclass') - .and_raise(LoadError, 'cannot load such file --') + .and_raise(LoadError, 'cannot load such file --') plugin.plugin_class end @@ -202,7 +202,7 @@ 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) + .and_return(plugin_class) expect(subject).to_not receive(:require) expect(subject.plugin_class).to eq plugin_class @@ -255,13 +255,13 @@ class VSpec 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) + .and_return(plugin_class) 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') + .and_return('Template content') allow(File).to receive(:read).with('Guardfile') { 'Guardfile content' } allow(File).to receive(:open).with('Guardfile', 'wb').and_yield io @@ -285,13 +285,13 @@ class VSpec 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) + .and_return(plugin_class) 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') + .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 105ec94c7..ab4679ced 100644 --- a/spec/lib/guard/runner_spec.rb +++ b/spec/lib/guard/runner_spec.rb @@ -44,7 +44,7 @@ describe '#run' do before do allow(scope).to receive(:grouped_plugins).with({}) - .and_return([[nil, [foo_plugin, bar_plugin, baz_plugin]]]) + .and_return([[nil, [foo_plugin, bar_plugin, baz_plugin]]]) allow(ui_config).to receive(:with_progname).and_yield end @@ -78,7 +78,7 @@ 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]]]) + .and_return([[nil, [bar_plugin]]]) expect(bar_plugin).to receive(:my_task) expect(foo_plugin).to_not receive(:my_task) @@ -132,14 +132,14 @@ # disable reevaluator allow(scope).to receive(:grouped_plugins).with(group: :common) - .and_return([[nil, []]]) + .and_return([[nil, []]]) # foo in default group allow(scope).to receive(:grouped_plugins).with(group: :default) - .and_return([[nil, [foo_plugin]]]) + .and_return([[nil, [foo_plugin]]]) allow(scope).to receive(:grouped_plugins).with(no_args) - .and_return([[nil, [foo_plugin]]]) + .and_return([[nil, [foo_plugin]]]) allow(ui_config).to receive(:with_progname).and_yield end @@ -147,7 +147,7 @@ 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]]]) + .and_return([[nil, [foo_plugin]]]) subject.run_on_changes(*changes) end @@ -156,7 +156,7 @@ it 'clear UI' do expect(Guard::UI).to receive(:clear) expect(scope).to receive(:grouped_plugins).with(no_args) - .and_return([[nil, [foo_plugin]]]) + .and_return([[nil, [foo_plugin]]]) subject.run_on_changes(*changes) end end @@ -244,7 +244,7 @@ before do changes[2] = removed expect(watcher_module).to receive(:match_files).once - .with(foo_plugin, removed) { [] } + .with(foo_plugin, removed) { [] } # stub so respond_to? works allow(foo_plugin).to receive(:run_on_removals) diff --git a/spec/lib/guard/terminal_spec.rb b/spec/lib/guard/terminal_spec.rb index 9546100e0..502c2f9ad 100644 --- a/spec/lib/guard/terminal_spec.rb +++ b/spec/lib/guard/terminal_spec.rb @@ -21,7 +21,7 @@ it "clears the screen using 'clear'" do expect(sheller).to receive(:system).with("printf '\33c\e[3J';") - .and_return(result) + .and_return(result) ::Guard::Terminal.clear end end @@ -31,7 +31,7 @@ before do allow(sheller).to receive(:system).with("printf '\33c\e[3J';") - .and_return(result) + .and_return(result) end it 'fails' do diff --git a/spec/lib/guard/ui_spec.rb b/spec/lib/guard/ui_spec.rb index 1fe460790..de1b4cb5b 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -134,7 +134,7 @@ before do allow(Guard::UI::Config).to receive(:new).with(hi: :ho) - .and_return(new_config) + .and_return(new_config) allow(new_config).to receive(:[]).with(:hi).and_return(:ho) end @@ -215,7 +215,7 @@ describe '.deprecation' do before do allow(ENV).to receive(:[]).with('GUARD_GEM_SILENCE_DEPRECATIONS') - .and_return(value) + .and_return(value) end context 'with GUARD_GEM_SILENCE_DEPRECATIONS set to 1' do @@ -327,7 +327,7 @@ 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]) + .and_return(%w[Rspec Jasmine]) expect(Guard::UI).to receive(:info).with('Reload Rspec, Jasmine') Guard::UI.action_with_scopes('Reload', plugins: [rspec, jasmine]) @@ -337,7 +337,7 @@ 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]) + .and_return(%w[Frontend]) expect(Guard::UI).to receive(:info).with('Reload Frontend') Guard::UI.action_with_scopes('Reload', groups: [group]) diff --git a/spec/lib/guard/watcher_spec.rb b/spec/lib/guard/watcher_spec.rb index 30b643eae..a9b69e341 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -313,10 +313,10 @@ def matched(files) before do allow(described_class::Pattern).to receive(:create).with(pattern) - .and_return(matcher) + .and_return(matcher) allow(matcher).to receive(:match).with(pattern) - .and_return(match_data) + .and_return(match_data) allow(described_class::Pattern::MatchResult).to receive(:new) .with(match_data, file).and_return(match) From 4942fc1e243a0fb6c1e460d278c6e9cca9a4902b Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:20:01 +0200 Subject: [PATCH 11/30] Settings: Set Metrics/LineLength:Max to 125 If anyone is still using an 80 character long terminal to edit files on a regular basis, contact me. --- vendor/hound/config/style_guides/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/hound/config/style_guides/ruby.yml b/vendor/hound/config/style_guides/ruby.yml index fdb129c8e..c661a9953 100644 --- a/vendor/hound/config/style_guides/ruby.yml +++ b/vendor/hound/config/style_guides/ruby.yml @@ -161,7 +161,7 @@ Metrics/CyclomaticComplexity: Enabled: false Max: 6 Metrics/LineLength: - Max: 80 + Max: 125 Metrics/MethodLength: Description: Avoid methods longer than 10 lines of code. StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods From 8358c62af39ef8402675fa292ef2d9e2fe4521bc Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:21:31 +0200 Subject: [PATCH 12/30] Auto correct: Style/TrailingCommaIn.*Literal in spec --- spec/lib/guard/dsl_describer_spec.rb | 2 +- spec/lib/guard/plugin_util_spec.rb | 2 +- spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb | 2 +- spec/lib/guard/watcher_spec.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index c5b0a4a46..bf3224a81 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -97,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 diff --git a/spec/lib/guard/plugin_util_spec.rb b/spec/lib/guard/plugin_util_spec.rb index ab3e877c0..f0a2dacb3 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -25,7 +25,7 @@ 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 } diff --git a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb index 9b7a11a04..d26364ca0 100644 --- a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb +++ b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb @@ -17,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_spec.rb b/spec/lib/guard/watcher_spec.rb index a9b69e341..39cf3ec25 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -275,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 From f33d6c44b56622f3021d7e4cf02c123338b599fe Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:31:31 +0200 Subject: [PATCH 13/30] Settings: Adapt quote and dot settings Also exclude specs from blocklength and erroneously drop a version from CI -> fixed later Explicitly enable Metrics/LineLength cop Set dot position to leading Set Style/StringLiterals to single-quote This is the default value of the cop in newer versions of rubocop and it is an easy fix Exclude spec from Metrics/BlockLength DSLs and block length restraints usually do not work well together Drop unsupported version from CI Use single quotes in gemfile --- .travis.yml | 1 - Gemfile | 38 +++++++++++------------ vendor/hound/config/style_guides/ruby.yml | 8 +++-- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index a74d181e7..11d4ecdc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: ruby sudo: false rvm: - - 2.2.9 - 2.3.6 - 2.4.3 - 2.5.0 diff --git a/Gemfile b/Gemfile index 6fccff982..47e81be7d 100644 --- a/Gemfile +++ b/Gemfile @@ -17,18 +17,18 @@ group :development do # on HoundCI's side. # # See https://github.com/houndci/hound/issues/1250 - gem "rubocop", "0.54.0", require: false + gem 'rubocop', '0.54.0', require: false - gem "guard-rubocop", require: false + gem 'guard-rubocop', require: false - gem "guard-ronn", require: false, platform: :mri - gem "redcarpet", require: false, platform: :mri - gem "yard", 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 - gem "netrc", require: false, platform: :mri - gem "octokit", require: false, platform: :mri + gem 'gems', require: false, platform: :mri + gem 'netrc', require: false, platform: :mri + gem 'octokit', require: false, platform: :mri end # The test group will be @@ -36,22 +36,22 @@ end # group :test do # Both guard-rspec and guard-cucumber are used by cucumber features - gem "guard-cucumber", "~> 2.1", require: false - gem "guard-rspec", require: false + gem 'guard-cucumber', '~> 2.1', require: false + gem 'guard-rspec', 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 + 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 "json" - gem "psych" - gem "racc" - gem "rubinius-coverage" - gem "rubysl", "~> 2.0" + gem 'json' + gem 'psych' + gem 'racc' + gem 'rubinius-coverage' + gem 'rubysl', '~> 2.0' end diff --git a/vendor/hound/config/style_guides/ruby.yml b/vendor/hound/config/style_guides/ruby.yml index c661a9953..38c84f1d1 100644 --- a/vendor/hound/config/style_guides/ruby.yml +++ b/vendor/hound/config/style_guides/ruby.yml @@ -17,7 +17,7 @@ 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 @@ -101,7 +101,7 @@ Style/StringLiterals: Description: Checks if uses of quotes match the configured preference. StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals Enabled: true - EnforcedStyle: double_quotes + EnforcedStyle: single_quotes SupportedStyles: - single_quotes - double_quotes @@ -155,12 +155,16 @@ 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 Metrics/MethodLength: Description: Avoid methods longer than 10 lines of code. From 98933f835980cf934cb7f1627032dc5ed2b0f009 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:54:50 +0200 Subject: [PATCH 14/30] Auto correct: Style/ExpandPathArguments in spec --- spec/lib/guard/bin_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index d3cee33fc..4f1b36de5 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -path = File.expand_path('../../../../bin/guard', __FILE__) +path = File.expand_path('../../../bin/guard', __dir__) load path RSpec.describe GuardReloader do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ae18d4805..9a58caec3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,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 From 3d8571a7e22f41cc0f021bd12ab2268bacfba716 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:55:57 +0200 Subject: [PATCH 15/30] Auto correct: Layout/AlignArray in spec --- spec/lib/guard/plugin_util_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/lib/guard/plugin_util_spec.rb b/spec/lib/guard/plugin_util_spec.rb index f0a2dacb3..590f0951e 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -99,10 +99,10 @@ after do # TODO: use RSpec's stub const consts = %i[Classname - DashedClassName - UnderscoreClassName - VSpec - Inline] + DashedClassName + UnderscoreClassName + VSpec + Inline] consts.each do |const| begin From c7b3fd3d04bf7916aad8bbd94aafa7dc91bb44a9 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 09:56:48 +0200 Subject: [PATCH 16/30] Auto correct: Style/Encoding in spec --- spec/lib/guard/dsl_describer_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index bf3224a81..792d8f8fa 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true require 'guard/plugin' From 3a98cc0111924f3903cd0fbe1ca9cc0312b7ac76 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 10:00:11 +0200 Subject: [PATCH 17/30] Correct: Forgotten double-quotes in Gemfile --- Gemfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 47e81be7d..3a0ecc728 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' -gemspec unless ENV["USE_INSTALLED_GUARD"] == "1" +gemspec unless ENV['USE_INSTALLED_GUARD'] == '1' -gem "rake" +gem 'rake' # The development group will not be # installed on Travis CI. From 6b466f620701c6e656e574842b97d21c7d6747e6 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 10:00:38 +0200 Subject: [PATCH 18/30] Auto correct: Lint/UnneededSplatExpansion in spec --- spec/lib/guard/jobs/pry_wrapper_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/guard/jobs/pry_wrapper_spec.rb b/spec/lib/guard/jobs/pry_wrapper_spec.rb index ecc49eece..80a01c244 100644 --- a/spec/lib/guard/jobs/pry_wrapper_spec.rb +++ b/spec/lib/guard/jobs/pry_wrapper_spec.rb @@ -34,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) @@ -132,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) From 8c93ed9205507aaceda2b481c1f35be7927f1774 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 10:06:00 +0200 Subject: [PATCH 19/30] Fix: Explicitly set rubocop configuration file --- config/Guardfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 5069a113e6eb02dddd19ae8254a33ad0bed364e3 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 10:07:18 +0200 Subject: [PATCH 20/30] Auto correct: Style/EmptyMethod in spec --- spec/lib/guard/commands/all_spec.rb | 3 +-- spec/lib/guard/commands/change_spec.rb | 3 +-- spec/lib/guard/commands/pause_spec.rb | 3 +-- spec/lib/guard/deprecated/evaluator_spec.rb | 3 +-- spec/lib/guard/deprecated/guard_spec.rb | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/spec/lib/guard/commands/all_spec.rb b/spec/lib/guard/commands/all_spec.rb index 6c18661ae..99860d0b9 100644 --- a/spec/lib/guard/commands/all_spec.rb +++ b/spec/lib/guard/commands/all_spec.rb @@ -16,8 +16,7 @@ let(:session) { instance_double('Guard::Internals::Session') } class FakePry < Pry::Command - def self.output - end + def self.output; end end before do diff --git a/spec/lib/guard/commands/change_spec.rb b/spec/lib/guard/commands/change_spec.rb index 2f6d85944..d81210e54 100644 --- a/spec/lib/guard/commands/change_spec.rb +++ b/spec/lib/guard/commands/change_spec.rb @@ -6,8 +6,7 @@ let(:output) { instance_double(Pry::Output) } class FakePry < Pry::Command - def self.output - end + def self.output; end end before do diff --git a/spec/lib/guard/commands/pause_spec.rb b/spec/lib/guard/commands/pause_spec.rb index 7f2e12c17..04c7ecce1 100644 --- a/spec/lib/guard/commands/pause_spec.rb +++ b/spec/lib/guard/commands/pause_spec.rb @@ -4,8 +4,7 @@ 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/deprecated/evaluator_spec.rb b/spec/lib/guard/deprecated/evaluator_spec.rb index 18c53b744..0afb841d8 100644 --- a/spec/lib/guard/deprecated/evaluator_spec.rb +++ b/spec/lib/guard/deprecated/evaluator_spec.rb @@ -10,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 diff --git a/spec/lib/guard/deprecated/guard_spec.rb b/spec/lib/guard/deprecated/guard_spec.rb index 77e7304f7..7037c7ccd 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -19,8 +19,7 @@ subject do module TestModule - def self.listener - end + def self.listener; end def self._pluginless_guardfile? false From b0955976362db9f8a303965143fdd7787ddfa6a9 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 10:11:09 +0200 Subject: [PATCH 21/30] Correct: the remaining 3 violations --- spec/lib/guard/dsl_spec.rb | 12 ++++++------ spec/lib/guard/guardfile/evaluator_spec.rb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index 4635be981..5614a7744 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -429,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'\ ' with foo!' - callback_1 = opt[:callbacks][1] - expect(callback_1[:events]).to eq %i[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) diff --git a/spec/lib/guard/guardfile/evaluator_spec.rb b/spec/lib/guard/guardfile/evaluator_spec.rb index 2fadd02f0..77e2b878a 100644 --- a/spec/lib/guard/guardfile/evaluator_spec.rb +++ b/spec/lib/guard/guardfile/evaluator_spec.rb @@ -37,7 +37,7 @@ allow(dsl).to receive(:evaluate) .and_raise(Guard::Dsl::Error, - 'Invalid Guardfile, original error is:') + 'Invalid Guardfile, original error is:') expect { subject.evaluate }.to raise_error(Guard::Dsl::Error) end From 523088486eb152c3fc5ebdca8f396816d867b96b Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 10:18:07 +0200 Subject: [PATCH 22/30] Settings: Get rid of warnings. Get rid of rubocop warnings Remove superfluous config file --- spec/.rubocop.yml | 2 -- vendor/hound/config/style_guides/ruby.yml | 24 +++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 spec/.rubocop.yml diff --git a/spec/.rubocop.yml b/spec/.rubocop.yml deleted file mode 100644 index d4809fc42..000000000 --- a/spec/.rubocop.yml +++ /dev/null @@ -1,2 +0,0 @@ -Metrics/BlockLength: - Max: 50 diff --git a/vendor/hound/config/style_guides/ruby.yml b/vendor/hound/config/style_guides/ruby.yml index 38c84f1d1..be509b321 100644 --- a/vendor/hound/config/style_guides/ruby.yml +++ b/vendor/hound/config/style_guides/ruby.yml @@ -118,28 +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 + # 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 + # SupportedStyles: + # - comma + # - consistent_comma + # - no_comma Metrics/AbcSize: Description: A calculated magnitude based on number of assignments, branches, and conditions. From 49d6ffad41bf317bf0df38e36b505d59500f7d10 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 12:04:40 +0200 Subject: [PATCH 23/30] Fix: Resupport version 2.2.9 Version is actually still supported Revert "Drop unsupported version from CI" This reverts commit 93dd1e132ffcd85ce323e32bbc463583103b7ad9. Fix 2.2.9 incompatibility This creates a performance hit but as this code is only test code, I deem this acceptable --- .travis.yml | 1 + spec/lib/guard/dsl_describer_spec.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 11d4ecdc0..a74d181e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: ruby sudo: false rvm: + - 2.2.9 - 2.3.6 - 2.4.3 - 2.5.0 diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index 792d8f8fa..980e3a9cd 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -29,7 +29,10 @@ 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 + # rubocop:disable Performance/UnfreezeString - +'' is incompatible with MRI 2.2.9 + @output = String.new + # rubocop:enable Performance/UnfreezeString # Strip escape sequences allow(STDOUT).to receive(:tty?).and_return(false) From fed30f118fdcaa4385aa88c1edfd8560260a508c Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Fri, 17 Aug 2018 13:42:07 +0200 Subject: [PATCH 24/30] Fix: Increase aruba timeout for Jruby on CI --- features/support/env.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 8c2ab9e9ea9e7fd0111c8bc43f42dfa11af7a253 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Sun, 19 Aug 2018 08:05:37 +0200 Subject: [PATCH 25/30] Settings: Enrich Metrics/LineLength config --- vendor/hound/config/style_guides/ruby.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vendor/hound/config/style_guides/ruby.yml b/vendor/hound/config/style_guides/ruby.yml index be509b321..3d6cc1870 100644 --- a/vendor/hound/config/style_guides/ruby.yml +++ b/vendor/hound/config/style_guides/ruby.yml @@ -166,6 +166,20 @@ Metrics/CyclomaticComplexity: 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 From 8114666b01d84281e22ff9c240b19202da363d8e Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Sun, 19 Aug 2018 08:12:31 +0200 Subject: [PATCH 26/30] Fix: Resupport 2.2.9 in rubocop --- .rubocop.yml | 2 +- spec/lib/guard/dsl_describer_spec.rb | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6abd7d2d5..da4c54175 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,7 @@ inherit_from: # Files you want to exclude AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.2 Exclude: - vendor/**/* - db/schema.rb diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index 980e3a9cd..9920b9a61 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -30,9 +30,7 @@ stub_const 'Guard::Another', class_double('Guard::Plugin') # TODO: Reenable rubocop and refactor to +'' one 2.2 compatibility is dropped - # rubocop:disable Performance/UnfreezeString - +'' is incompatible with MRI 2.2.9 @output = String.new - # rubocop:enable Performance/UnfreezeString # Strip escape sequences allow(STDOUT).to receive(:tty?).and_return(false) From 215f8917343323191795835127cc5f247c6ed413 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Tue, 21 Aug 2018 07:56:55 +0200 Subject: [PATCH 27/30] Settings: Set Style/StringLiterals to double_quotes --- vendor/hound/config/style_guides/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/hound/config/style_guides/ruby.yml b/vendor/hound/config/style_guides/ruby.yml index 3d6cc1870..1bcc78557 100644 --- a/vendor/hound/config/style_guides/ruby.yml +++ b/vendor/hound/config/style_guides/ruby.yml @@ -101,7 +101,7 @@ Style/StringLiterals: Description: Checks if uses of quotes match the configured preference. StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals Enabled: true - EnforcedStyle: single_quotes + EnforcedStyle: double_quotes SupportedStyles: - single_quotes - double_quotes From 4a77fded2264d1979c23fa0cc315ac9392a60fab Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Tue, 21 Aug 2018 08:00:23 +0200 Subject: [PATCH 28/30] Auto correct: Style/StringLiterals --- spec/lib/guard/bin_spec.rb | 66 ++-- .../guard/cli/environments/bundler_spec.rb | 42 +-- .../cli/environments/evaluate_only_spec.rb | 26 +- spec/lib/guard/cli/environments/valid_spec.rb | 106 +++--- spec/lib/guard/cli_spec.rb | 56 +-- spec/lib/guard/commander_spec.rb | 120 +++---- spec/lib/guard/commands/all_spec.rb | 46 +-- spec/lib/guard/commands/change_spec.rb | 24 +- spec/lib/guard/commands/notification_spec.rb | 6 +- spec/lib/guard/commands/pause_spec.rb | 6 +- spec/lib/guard/commands/reload_spec.rb | 44 +-- spec/lib/guard/commands/scope_spec.rb | 48 +-- spec/lib/guard/commands/show_spec.rb | 8 +- spec/lib/guard/config_spec.rb | 4 +- spec/lib/guard/deprecated/dsl_spec.rb | 26 +- spec/lib/guard/deprecated/evaluator_spec.rb | 18 +- spec/lib/guard/deprecated/guard_spec.rb | 192 +++++----- spec/lib/guard/deprecated/guardfile_spec.rb | 38 +- spec/lib/guard/deprecated/watcher_spec.rb | 22 +- spec/lib/guard/dsl_describer_spec.rb | 66 ++-- spec/lib/guard/dsl_reader_spec.rb | 36 +- spec/lib/guard/dsl_spec.rb | 336 +++++++++--------- spec/lib/guard/group_spec.rb | 20 +- spec/lib/guard/guardfile/evaluator_spec.rb | 124 +++---- spec/lib/guard/guardfile/generator_spec.rb | 58 +-- spec/lib/guard/interactor_spec.rb | 84 ++--- spec/lib/guard/internals/debugging_spec.rb | 58 +-- spec/lib/guard/internals/groups_spec.rb | 78 ++-- spec/lib/guard/internals/plugins_spec.rb | 98 ++--- spec/lib/guard/internals/scope_spec.rb | 60 ++-- spec/lib/guard/internals/session_spec.rb | 174 ++++----- spec/lib/guard/internals/state_spec.rb | 22 +- spec/lib/guard/internals/tracing_spec.rb | 52 +-- spec/lib/guard/internals/traps_spec.rb | 22 +- spec/lib/guard/jobs/pry_wrapper_spec.rb | 70 ++-- spec/lib/guard/jobs/sleep_spec.rb | 20 +- spec/lib/guard/notifier_spec.rb | 42 +-- spec/lib/guard/options_spec.rb | 30 +- spec/lib/guard/plugin_spec.rb | 122 +++---- spec/lib/guard/plugin_util_spec.rb | 182 +++++----- spec/lib/guard/runner_spec.rb | 176 ++++----- spec/lib/guard/terminal_spec.rb | 32 +- spec/lib/guard/ui/config_spec.rb | 50 +-- spec/lib/guard/ui/logger_spec.rb | 14 +- spec/lib/guard/ui_spec.rb | 190 +++++----- .../watcher/pattern/deprecated_regexp_spec.rb | 16 +- .../watcher/pattern/match_result_spec.rb | 38 +- .../lib/guard/watcher/pattern/matcher_spec.rb | 68 ++-- .../watcher/pattern/pathname_path_spec.rb | 32 +- .../guard/watcher/pattern/simple_path_spec.rb | 32 +- spec/lib/guard/watcher/pattern_spec.rb | 22 +- spec/lib/guard/watcher_spec.rb | 240 ++++++------- spec/lib/guard_spec.rb | 112 +++--- spec/spec_helper.rb | 44 +-- spec/support/gems_helper.rb | 6 +- spec/support/platform_helper.rb | 6 +- 56 files changed, 1865 insertions(+), 1865 deletions(-) diff --git a/spec/lib/guard/bin_spec.rb b/spec/lib/guard/bin_spec.rb index 4f1b36de5..bb4b9bd1e 100644 --- a/spec/lib/guard/bin_spec.rb +++ b/spec/lib/guard/bin_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -path = File.expand_path('../../../bin/guard', __dir__) +path = File.expand_path("../../../bin/guard", __dir__) load path RSpec.describe GuardReloader do @@ -8,7 +8,7 @@ subject { described_class.new(config) } - let(:guard_core_path) { '/home/me/.rvm/gems/ruby-2.2.2/bin/_guard-core' } + let(:guard_core_path) { "/home/me/.rvm/gems/ruby-2.2.2/bin/_guard-core" } before do allow(described_class::Config).to receive(:new).and_return(config) @@ -24,111 +24,111 @@ allow(config).to receive(:program_path).and_return(program_path) end - let(:program_path) { Pathname('/home/me/.rvm/gems/ruby-2.2.2/bin/guard') } + let(:program_path) { Pathname("/home/me/.rvm/gems/ruby-2.2.2/bin/guard") } let(:rubygems_deps_env) { nil } # or any gemfile path - context 'when running with bundler' do - let(:bundle_gemfile_env) { './Gemfile' } + context "when running with bundler" do + let(:bundle_gemfile_env) { "./Gemfile" } - it 'sets up bundler' do + it "sets up bundler" do expect(config).to receive(:setup_bundler) subject.setup end end - context 'when not running with bundler' do + context "when not running with bundler" do let(:bundle_gemfile_env) { nil } - context 'when running with rubygems_gemdeps' do - let(:rubygems_deps_env) { '-' } # or any gemfile path + context "when running with rubygems_gemdeps" do + let(:rubygems_deps_env) { "-" } # or any gemfile path - it 'sets up rubygems' do + it "sets up rubygems" do expect(config).to receive(:setup_rubygems_for_deps) subject.setup end end - context 'when not running with rubygems_gemdeps' do + context "when not running with rubygems_gemdeps" do let(:rubygems_deps_env) { nil } - context 'when running as binstub' do - let(:program_path) { Pathname('/my/project/bin/guard') } + context "when running as binstub" do + let(:program_path) { Pathname("/my/project/bin/guard") } - context 'when the relative Gemfile exists' do + context "when the relative Gemfile exists" do before do allow(config).to receive(:exist?) - .with(Pathname('/my/project/Gemfile')).and_return(true) + .with(Pathname("/my/project/Gemfile")).and_return(true) allow(config).to receive(:setup_bundler) allow(config).to receive(:setup_bundler_env) end - it 'sets up bundler' do + it "sets up bundler" do expect(config).to receive(:setup_bundler) subject.setup end - it 'sets the Gemfile' do + it "sets the Gemfile" do expect(config).to receive(:setup_bundler_env) - .with('/my/project/Gemfile') + .with("/my/project/Gemfile") subject.setup end end - context 'when the relative Gemfile does not exist' do + context "when the relative Gemfile does not exist" do before do allow(config).to receive(:exist?) - .with(Pathname('/my/project/Gemfile')).and_return(false) + .with(Pathname("/my/project/Gemfile")).and_return(false) - allow(config).to receive(:exist?).with(Pathname('Gemfile')) + allow(config).to receive(:exist?).with(Pathname("Gemfile")) .and_return(false) end - it 'does not setup bundler' do + it "does not setup bundler" do subject.setup end - it 'does not setup rubygems' do + it "does not setup rubygems" do subject.setup end - it 'shows no warning' do + it "shows no warning" do expect(STDERR).to_not receive(:puts) subject.setup end end end - context 'when not run as binstub' do + context "when not run as binstub" do let(:program_path) do - Pathname('/home/me/.rvm/gems/ruby-2.2.2/bin/guard') + Pathname("/home/me/.rvm/gems/ruby-2.2.2/bin/guard") end before do allow(config).to receive(:exist?).with( - Pathname('/home/me/.rvm/gems/ruby-2.2.2/Gemfile') + Pathname("/home/me/.rvm/gems/ruby-2.2.2/Gemfile") ).and_return(false) end - context 'when Gemfile exists' do + context "when Gemfile exists" do before do - allow(config).to receive(:exist?).with(Pathname('Gemfile')) + allow(config).to receive(:exist?).with(Pathname("Gemfile")) .and_return(true) end - it 'shows a warning' do + it "shows a warning" do expect(STDERR).to receive(:puts).with(/Warning: you have a Gemfile/) subject.setup end end - context 'when no Gemfile exists' do + context "when no Gemfile exists" do before do - allow(config).to receive(:exist?).with(Pathname('Gemfile')) + allow(config).to receive(:exist?).with(Pathname("Gemfile")) .and_return(false) end - it 'shows no warning' do + it "shows no warning" do expect(STDERR).to_not receive(:puts) subject.setup end diff --git a/spec/lib/guard/cli/environments/bundler_spec.rb b/spec/lib/guard/cli/environments/bundler_spec.rb index ac32e8b6f..6a0a41572 100644 --- a/spec/lib/guard/cli/environments/bundler_spec.rb +++ b/spec/lib/guard/cli/environments/bundler_spec.rb @@ -1,60 +1,60 @@ # frozen_string_literal: true -require 'guard/cli/environments/bundler' +require "guard/cli/environments/bundler" # TODO: instead of shared examples, use have_received if possible -RSpec.shared_examples 'avoids Bundler warning' do - it 'does not show the Bundler warning' do +RSpec.shared_examples "avoids Bundler warning" do + it "does not show the Bundler warning" do expect(Guard::UI).to_not have_received(:info).with(/Guard here!/) end end -RSpec.shared_examples 'shows Bundler warning' do - it 'shows the Bundler warning' do +RSpec.shared_examples "shows Bundler warning" do + it "shows the Bundler warning" do expect(Guard::UI).to have_received(:info).with(/Guard here!/) end end RSpec.describe Guard::Cli::Environments::Bundler do - describe '#verify' do + describe "#verify" do let(:gemdeps) { nil } let(:gemfile) { nil } before do - allow(ENV).to receive(:[]).with('BUNDLE_GEMFILE').and_return(gemfile) - allow(ENV).to receive(:[]).with('RUBYGEMS_GEMDEPS').and_return(gemdeps) + 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') + allow(File).to receive(:exist?).with("Gemfile") .and_return(gemfile_present) subject.verify end - context 'without an existing Gemfile' do + context "without an existing Gemfile" do let(:gemfile_present) { false } - include_examples 'avoids Bundler warning' + include_examples "avoids Bundler warning" end - context 'with an existing Gemfile' do + context "with an existing Gemfile" do let(:gemfile_present) { true } - context 'with Bundler' do + context "with Bundler" do let(:gemdeps) { nil } - let(:gemfile) { 'Gemfile' } - include_examples 'avoids Bundler warning' + let(:gemfile) { "Gemfile" } + include_examples "avoids Bundler warning" end - context 'without Bundler' do + context "without Bundler" do let(:gemfile) { nil } - context 'with Rubygems Gemfile autodetection or custom Gemfile' do - let(:gemdeps) { '-' } - include_examples 'avoids Bundler warning' + context "with Rubygems Gemfile autodetection or custom Gemfile" do + let(:gemdeps) { "-" } + include_examples "avoids Bundler warning" end - context 'without Rubygems Gemfile handling' do + context "without Rubygems Gemfile handling" do let(:gemdeps) { nil } - include_examples 'shows Bundler warning' + include_examples "shows Bundler warning" end end end diff --git a/spec/lib/guard/cli/environments/evaluate_only_spec.rb b/spec/lib/guard/cli/environments/evaluate_only_spec.rb index d5cb6e6c9..88aab0ec6 100644 --- a/spec/lib/guard/cli/environments/evaluate_only_spec.rb +++ b/spec/lib/guard/cli/environments/evaluate_only_spec.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require 'guard/cli/environments/evaluate_only' +require "guard/cli/environments/evaluate_only" RSpec.describe Guard::Cli::Environments::EvaluateOnly do subject { described_class.new(options) } - let(:options) { double('options') } + let(:options) { double("options") } - describe '#evaluate' do - let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } - let(:state) { instance_double('Guard::Internals::State') } - let(:session) { instance_double('Guard::Internals::Session') } + describe "#evaluate" do + let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } + let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double("Guard::Internals::Session") } before do allow(Guard::Guardfile::Evaluator).to receive(:new).and_return(evaluator) @@ -20,23 +20,23 @@ allow(session).to receive(:evaluator_options) end - it 'calls Guard.init' do + it "calls Guard.init" do expect(Guard).to receive(:init) subject.evaluate end - it 'initializes Guard with options' do + it "initializes Guard with options" do expect(Guard).to receive(:init).with(options) subject.evaluate end - it 'evaluates the guardfile' do + it "evaluates the guardfile" do expect(evaluator).to receive(:evaluate) subject.evaluate end - it 'passes options to evaluator' do - evaluator_options = double('evaluator_options') + it "passes options to evaluator" do + evaluator_options = double("evaluator_options") allow(session).to receive(:evaluator_options) .and_return(evaluator_options) @@ -58,11 +58,11 @@ .and_raise(error_class, "#{error_class} error!") end - it 'aborts' do + it "aborts" do expect { subject.evaluate }.to raise_error(SystemExit) end - it 'shows error message' do + it "shows error message" do expect(Guard::UI).to receive(:error).with(/#{error_class} error!/) begin subject.evaluate diff --git a/spec/lib/guard/cli/environments/valid_spec.rb b/spec/lib/guard/cli/environments/valid_spec.rb index 8133a3720..9b65aebd5 100644 --- a/spec/lib/guard/cli/environments/valid_spec.rb +++ b/spec/lib/guard/cli/environments/valid_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'guard/cli/environments/valid' -require 'guard/cli/environments/bundler' +require "guard/cli/environments/valid" +require "guard/cli/environments/bundler" RSpec.describe Guard::Cli::Environments::Valid do subject { described_class.new(options) } - let(:options) { double('options') } + let(:options) { double("options") } before do # TODO: start should be an instance method of something allow(Guard).to receive(:start) end - describe '#start_guard' do - let(:bundler) { instance_double('Guard::Cli::Environments::Bundler') } + describe "#start_guard" do + let(:bundler) { instance_double("Guard::Cli::Environments::Bundler") } before do allow(Guard::Cli::Environments::Bundler).to receive(:new) @@ -22,7 +22,7 @@ allow(bundler).to receive(:verify) end - context 'with a valid bundler setup' do + context "with a valid bundler setup" do before do allow(bundler).to receive(:verify) @@ -30,18 +30,18 @@ .and_return(false) end - it 'starts guard' do + it "starts guard" do expect(Guard).to receive(:start) subject.start_guard end - it 'start guard with options' do + it "start guard with options" do expect(Guard).to receive(:start).with(options) subject.start_guard end - it 'returns exit code' do - exitcode = double('exitcode') + it "returns exit code" do + exitcode = double("exitcode") expect(Guard).to receive(:start).and_return(exitcode) expect(subject.start_guard).to be(exitcode) end @@ -58,11 +58,11 @@ .and_raise(error_class, "#{error_class} error!") end - it 'aborts' do + it "aborts" do expect { subject.start_guard }.to raise_error(SystemExit) end - it 'shows error message' do + it "shows error message" do expect(Guard::UI).to receive(:error).with(/#{error_class} error!/) begin subject.start_guard @@ -73,20 +73,20 @@ end end - context 'without no_bundler_warning option' do + context "without no_bundler_warning option" do subject { described_class.new(no_bundler_warning: false) } - it 'verifies bundler presence' do + it "verifies bundler presence" do expect(bundler).to receive(:verify) subject.start_guard end - context 'without a valid bundler setup' do + context "without a valid bundler setup" do before do allow(bundler).to receive(:verify).and_raise(SystemExit) end - it 'does not start guard' do + it "does not start guard" do expect(Guard).to_not receive(:start) begin @@ -97,42 +97,42 @@ end end - context 'with no_bundler_warning option' do + context "with no_bundler_warning option" do subject { described_class.new(no_bundler_warning: true) } - it 'does not verify bundler presence' do + it "does not verify bundler presence" do expect(bundler).to_not receive(:verify) subject.start_guard end - it 'starts guard' do + it "starts guard" do expect(Guard).to receive(:start) subject.start_guard end end - describe 'return value' do - let(:exitcode) { double('Fixnum') } + describe "return value" do + let(:exitcode) { double("Fixnum") } subject { described_class.new(no_bundler_warning: true) } before do allow(Guard).to receive(:start).and_return(exitcode) end - it 'matches return value of Guard.start' do + it "matches return value of Guard.start" do expect(subject.start_guard).to be(exitcode) end end end - describe '#initialize_guardfile' do - let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } - let(:generator) { instance_double('Guard::Guardfile::Generator') } - let(:state) { instance_double('Guard::Internals::State') } - let(:session) { instance_double('Guard::Internals::Session') } + describe "#initialize_guardfile" do + let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } + let(:generator) { instance_double("Guard::Guardfile::Generator") } + let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double("Guard::Internals::Session") } before do - stub_file('Gemfile') + stub_file("Gemfile") allow(evaluator).to receive(:evaluate) allow(generator).to receive(:create_guardfile) @@ -146,16 +146,16 @@ allow(Guard::Guardfile::Generator).to receive(:new).and_return(generator) end - context 'with bare option' do + context "with bare option" do before do expect(options).to receive(:[]).with(:bare).and_return(true) end - it 'Only creates the Guardfile without initializing any Guard template' do + it "Only creates the Guardfile without initializing any Guard template" do allow(evaluator).to receive(:evaluate) .and_raise(Guard::Guardfile::Evaluator::NoGuardfileError) - allow(File).to receive(:exist?).with('Gemfile').and_return(false) + allow(File).to receive(:exist?).with("Gemfile").and_return(false) expect(generator).to receive(:create_guardfile) expect(generator).to_not receive(:initialize_template) expect(generator).to_not receive(:initialize_all_templates) @@ -163,23 +163,23 @@ subject.initialize_guardfile end - it 'returns an exit code' do + it "returns an exit code" do # TODO: ideally, we'd capture known exceptions and return nonzero expect(subject.initialize_guardfile).to be_zero end end - context 'with no bare option' do + context "with no bare option" do before do expect(options).to receive(:[]).with(:bare).and_return(false) end - it 'evaluates created or existing guardfile' do + it "evaluates created or existing guardfile" do expect(evaluator).to receive(:evaluate) subject.initialize_guardfile end - it 'creates a Guardfile' do + it "creates a Guardfile" do expect(evaluator).to receive(:evaluate) .and_raise(Guard::Guardfile::Evaluator::NoGuardfileError).once expect(evaluator).to receive(:evaluate) @@ -191,58 +191,58 @@ subject.initialize_guardfile end - it 'initializes templates of all installed Guards' do - allow(File).to receive(:exist?).with('Gemfile').and_return(false) + it "initializes templates of all installed Guards" do + allow(File).to receive(:exist?).with("Gemfile").and_return(false) expect(generator).to receive(:initialize_all_templates) subject.initialize_guardfile end - it 'initializes each passed template' do - allow(File).to receive(:exist?).with('Gemfile').and_return(false) + it "initializes each passed template" do + allow(File).to receive(:exist?).with("Gemfile").and_return(false) - expect(generator).to receive(:initialize_template).with('rspec') - expect(generator).to receive(:initialize_template).with('pow') + expect(generator).to receive(:initialize_template).with("rspec") + expect(generator).to receive(:initialize_template).with("pow") subject.initialize_guardfile(%w[rspec pow]) end - context 'when passed a guard name' do - context 'when the Guardfile is empty' do + 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(generator).to receive(:initialize_template) end - it 'works without without errors' do + it "works without without errors" do expect(subject.initialize_guardfile(%w[rspec])).to be_zero end - it 'adds the template' do - expect(generator).to receive(:initialize_template).with('rspec') + it "adds the template" do + expect(generator).to receive(:initialize_template).with("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') + it "initializes the template of the passed Guard" do + expect(generator).to receive(:initialize_template).with("rspec") subject.initialize_guardfile(%w[rspec]) end end - it 'returns an exit code' do + it "returns an exit code" do expect(subject.initialize_guardfile).to be_zero end - context 'when passed an unknown guard name' do + 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 + it "returns an exit code" do expect(::Guard::UI).to receive(:error).with( "Could not load 'guard/foo' or '~/.guard/templates/foo'"\ " or find class Guard::Foo\n" diff --git a/spec/lib/guard/cli_spec.rb b/spec/lib/guard/cli_spec.rb index 3cc4ee6dc..7b35e2a54 100644 --- a/spec/lib/guard/cli_spec.rb +++ b/spec/lib/guard/cli_spec.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require 'guard/cli' +require "guard/cli" RSpec.describe Guard::CLI do - let(:valid_environment) { instance_double('Guard::Cli::Environments::Valid') } + let(:valid_environment) { instance_double("Guard::Cli::Environments::Valid") } let(:bare_environment) do - instance_double('Guard::Cli::Environments::EvaluateOnly') + instance_double("Guard::Cli::Environments::EvaluateOnly") end - let(:dsl_describer) { instance_double('Guard::DslDescriber') } + let(:dsl_describer) { instance_double("Guard::DslDescriber") } before do @options = {} @@ -23,13 +23,13 @@ .and_return(valid_environment) end - describe '#start' do + describe "#start" do before do allow(valid_environment).to receive(:start_guard).and_return(0) end - it 'delegates to Guard::Environment.start' do - pending 'needs JRuby support first' if defined?(JRUBY_VERSION) + it "delegates to Guard::Environment.start" do + pending "needs JRuby support first" if defined?(JRUBY_VERSION) expect(valid_environment).to receive(:start_guard).and_return(0) begin @@ -38,8 +38,8 @@ end end - it 'exits with given exit code' do - pending 'needs JRuby support first' if defined?(JRUBY_VERSION) + it "exits with given exit code" do + pending "needs JRuby support first" if defined?(JRUBY_VERSION) allow(valid_environment).to receive(:start_guard).and_return(4) expect { subject.start }.to raise_error(SystemExit) do |exception| @@ -48,8 +48,8 @@ end end - it 'passes options' do - pending 'needs JRuby support first' if defined?(JRUBY_VERSION) + 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) @@ -60,67 +60,67 @@ end end - describe '#list' do + describe "#list" do before do allow(bare_environment).to receive(:evaluate) allow(dsl_describer).to receive(:list) subject.list end - it 'calls the evaluation' do + it "calls the evaluation" do expect(bare_environment).to have_received(:evaluate) end - it 'outputs the Guard plugins list' do + it "outputs the Guard plugins list" do expect(dsl_describer).to have_received(:list) end end - describe '#notifiers' do + describe "#notifiers" do before do allow(bare_environment).to receive(:evaluate) allow(dsl_describer).to receive(:notifiers) subject.notifiers end - it 'calls the evaluation' do + it "calls the evaluation" do expect(bare_environment).to have_received(:evaluate) end - it 'outputs the notifiers list' do + it "outputs the notifiers list" do expect(dsl_describer).to have_received(:notifiers) end end - describe '#version' do - it 'shows the current version' do + describe "#version" do + it "shows the current version" do expect(STDOUT).to receive(:puts).with(/#{ ::Guard::VERSION }/) subject.version end end - describe '#init' do + describe "#init" do before do allow(Guard::Cli::Environments::Valid).to receive(:new) .and_return(valid_environment) allow(valid_environment).to receive(:initialize_guardfile).and_return(0) end - it 'delegates to Guard::Environment.start' do + it "delegates to Guard::Environment.start" do begin subject.init rescue SystemExit end end - it 'exits with given exit code' do + it "exits with given exit code" do allow(valid_environment).to receive(:initialize_guardfile).and_return(4) expect { subject.init }.to raise_error(SystemExit) do |exception| expect(exception.status).to eq(4) end end - it 'passes options' do + it "passes options" do expect(Guard::Cli::Environments::Valid).to receive(:new).with(@options) .and_return(valid_environment) begin @@ -129,8 +129,8 @@ end end - it 'passes plugin names' do - plugins = [double('plugin1'), double('plugin2')] + it "passes plugin names" do + plugins = [double("plugin1"), double("plugin2")] expect(valid_environment).to receive(:initialize_guardfile).with(plugins) begin subject.init(*plugins) @@ -139,18 +139,18 @@ end end - describe '#show' do + describe "#show" do before do allow(bare_environment).to receive(:evaluate) allow(dsl_describer).to receive(:show) subject.show end - it 'calls the evaluation' do + it "calls the evaluation" do expect(bare_environment).to have_received(:evaluate) end - it 'outputs the Guard::DslDescriber.list result' do + it "outputs the Guard::DslDescriber.list result" do expect(dsl_describer).to have_received(:show) end end diff --git a/spec/lib/guard/commander_spec.rb b/spec/lib/guard/commander_spec.rb index dcc12b4c7..45316f9a3 100644 --- a/spec/lib/guard/commander_spec.rb +++ b/spec/lib/guard/commander_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require 'guard/commander' +require "guard/commander" RSpec.describe Guard::Commander do subject { Guard } - let(:interactor) { instance_double('Guard::Interactor') } - let(:runner) { instance_double('Guard::Runner', run: true) } + let(:interactor) { instance_double("Guard::Interactor") } + let(:runner) { instance_double("Guard::Runner", run: true) } - let(:scope) { instance_double('Guard::Internals::Scope') } - let(:state) { instance_double('Guard::Internals::State') } - let(:session) { instance_double('Guard::Internals::Session') } + let(:scope) { instance_double("Guard::Internals::Scope") } + let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double("Guard::Internals::Session") } before do allow(state).to receive(:scope).and_return(scope) @@ -21,15 +21,15 @@ allow(Guard::Runner).to receive(:new).and_return(runner) end - describe '.start' do + describe ".start" do let(:listener) do - instance_double('Listen::Listener', start: true, stop: true) + instance_double("Listen::Listener", start: true, stop: true) end let(:watched_dir) { Dir.pwd } before do - stub_guardfile(' ') + stub_guardfile(" ") stub_user_guard_rb # from stop() @@ -45,48 +45,48 @@ allow(Guard::Notifier).to receive(:disconnect) end - it 'calls Guard setup' do - expect(Guard).to receive(:setup).with(foo: 'bar') - Guard.start(foo: 'bar') + it "calls Guard setup" do + expect(Guard).to receive(:setup).with(foo: "bar") + Guard.start(foo: "bar") end - it 'displays an info message' do + it "displays an info message" do expect(Guard::UI).to receive(:info) .with("Guard is now watching at 'dir1', 'dir2'") Guard.start end - it 'tell the runner to run the :start task' do + it "tell the runner to run the :start task" do expect(runner).to receive(:run).with(:start) allow(listener).to receive(:stop) Guard.start end - it 'start the listener' do + it "start the listener" do expect(listener).to receive(:start) Guard.start end - context 'when finished' do - it 'stops everything' do + context "when finished" do + it "stops everything" do expect(interactor).to receive(:foreground).and_return(:exit) # From stop() expect(interactor).to receive(:background) expect(listener).to receive(:stop) expect(runner).to receive(:run).with(:stop) - expect(Guard::UI).to receive(:info).with('Bye bye...', reset: true) + expect(Guard::UI).to receive(:info).with("Bye bye...", reset: true) Guard.start end end end - describe '.stop' do - let(:runner) { instance_double('Guard::Runner', run: true) } - let(:listener) { instance_double('Listen::Listener', stop: true) } + describe ".stop" do + let(:runner) { instance_double("Guard::Runner", run: true) } + let(:listener) { instance_double("Listen::Listener", stop: true) } before do allow(Guard::Notifier).to receive(:disconnect) @@ -98,52 +98,52 @@ Guard.stop end - it 'turns off the interactor' do + it "turns off the interactor" do expect(interactor).to have_received(:background) end - it 'turns the notifier off' do + it "turns the notifier off" do expect(Guard::Notifier).to have_received(:disconnect) end - it 'tell the runner to run the :stop task' do + it "tell the runner to run the :stop task" do expect(runner).to have_received(:run).with(:stop) end - it 'stops the listener' do + it "stops the listener" do expect(listener).to have_received(:stop) end end - describe '.reload' do - let(:runner) { instance_double('Guard::Runner', run: true) } - let(:group) { instance_double('Guard::Group', name: 'frontend') } + describe ".reload" do + let(:runner) { instance_double("Guard::Runner", run: true) } + let(:group) { instance_double("Guard::Group", name: "frontend") } before do allow(Guard::Notifier).to receive(:connect) allow(Guard::UI).to receive(:info) allow(Guard::UI).to receive(:clear) - allow(scope).to receive(:titles).and_return(['all']) + allow(scope).to receive(:titles).and_return(["all"]) - stub_guardfile(' ') + stub_guardfile(" ") stub_user_guard_rb end - it 'clears the screen' do + it "clears the screen" do expect(Guard::UI).to receive(:clear) Guard.reload end - it 'reloads Guard' do + it "reloads Guard" do expect(runner).to receive(:run).with(:reload, groups: [group]) Guard.reload(groups: [group]) end end - describe '.run_all' do - let(:group) { instance_double('Guard::Group', name: 'frontend') } + describe ".run_all" do + let(:group) { instance_double("Guard::Group", name: "frontend") } before do allow(::Guard::Notifier).to receive(:connect) @@ -151,16 +151,16 @@ allow(::Guard::UI).to receive(:clear) end - context 'with a given scope' do - it 'runs all with the scope' do + context "with a given scope" do + it "runs all with the scope" do expect(runner).to receive(:run).with(:run_all, groups: [group]) subject.run_all(groups: [group]) end end - context 'with an empty scope' do - it 'runs all' do + context "with an empty scope" do + it "runs all" do expect(runner).to receive(:run).with(:run_all, {}) subject.run_all @@ -168,9 +168,9 @@ end end - describe '.pause' do - context 'when unpaused' do - let(:listener) { instance_double('Listen::Listener') } + describe ".pause" do + context "when unpaused" do + let(:listener) { instance_double("Listen::Listener") } before do allow(::Guard::Notifier).to receive(:connect) @@ -184,12 +184,12 @@ allow(listener).to receive(:pause) end - it 'pauses' do + it "pauses" do expect(listener).to receive(:pause) Guard.pause(mode) end - it 'shows a message' do + it "shows a message" do expected = /File event handling has been paused/ expect(Guard::UI).to receive(:info).with(expected) Guard.pause(mode) @@ -197,24 +197,24 @@ end end - context 'with :unpaused' do - it 'does nothing' do + context "with :unpaused" do + it "does nothing" do expect(listener).to_not receive(:start) expect(listener).to_not receive(:pause) Guard.pause(:unpaused) end end - context 'with invalid parameter' do - it 'raises an ArgumentError' do + context "with invalid parameter" do + it "raises an ArgumentError" do expect { Guard.pause(:invalid) } - .to raise_error(ArgumentError, 'invalid mode: :invalid') + .to raise_error(ArgumentError, "invalid mode: :invalid") end end end - context 'when already paused' do - let(:listener) { instance_double('Listen::Listener') } + context "when already paused" do + let(:listener) { instance_double("Listen::Listener") } before do allow(::Guard::Notifier).to receive(:connect) @@ -228,12 +228,12 @@ allow(listener).to receive(:start) end - it 'unpauses' do + it "unpauses" do expect(listener).to receive(:start) Guard.pause(mode) end - it 'shows a message' do + it "shows a message" do expected = /File event handling has been resumed/ expect(Guard::UI).to receive(:info).with(expected) Guard.pause(mode) @@ -241,32 +241,32 @@ end end - context 'with :paused' do - it 'does nothing' do + context "with :paused" do + it "does nothing" do expect(listener).to_not receive(:start) expect(listener).to_not receive(:pause) Guard.pause(:paused) end end - context 'with invalid parameter' do - it 'raises an ArgumentError' do + context "with invalid parameter" do + it "raises an ArgumentError" do expect { Guard.pause(:invalid) } - .to raise_error(ArgumentError, 'invalid mode: :invalid') + .to raise_error(ArgumentError, "invalid mode: :invalid") end end end end - describe '.show' do - let(:dsl_describer) { instance_double('Guard::DslDescriber') } + describe ".show" do + let(:dsl_describer) { instance_double("Guard::DslDescriber") } before do allow(Guard::DslDescriber).to receive(:new).with(no_args) .and_return(dsl_describer) end - it 'shows list of plugins' do + it "shows list of plugins" do expect(dsl_describer).to receive(:show) Guard.show end diff --git a/spec/lib/guard/commands/all_spec.rb b/spec/lib/guard/commands/all_spec.rb index 99860d0b9..795b8e2c7 100644 --- a/spec/lib/guard/commands/all_spec.rb +++ b/spec/lib/guard/commands/all_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'guard/plugin' +require "guard/plugin" -require 'guard/commands/all' +require "guard/commands/all" -require 'guard/internals/session' -require 'guard/internals/state' +require "guard/internals/session" +require "guard/internals/state" RSpec.describe Guard::Commands::All do let(:foo_group) { instance_double(Guard::Group) } let(:bar_guard) { instance_double(Guard::Plugin) } let(:output) { instance_double(Pry::Output) } - let(:state) { instance_double('Guard::Internals::State') } - let(:session) { instance_double('Guard::Internals::Session') } + let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double("Guard::Internals::Session") } class FakePry < Pry::Command def self.output; end @@ -27,18 +27,18 @@ def self.output; end allow(Guard).to receive(:state).and_return(state) allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with('all') do |&block| + allow(Pry::Commands).to receive(:create_command).with("all") do |&block| FakePry.instance_eval(&block) end described_class.import end - context 'without scope' do + context "without scope" do let(:given_scope) { [] } let(:converted_scope) { [{ groups: [], plugins: [] }, []] } - it 'runs the :run_all action' do + it "runs the :run_all action" do expect(Guard).to receive(:async_queue_add) .with([:guard_run_all, groups: [], plugins: []]) @@ -46,39 +46,39 @@ def self.output; end end end - context 'with a valid Guard group scope' do - let(:given_scope) { ['foo'] } + context "with a valid Guard group scope" do + let(:given_scope) { ["foo"] } let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } - it 'runs the :run_all action with the given scope' do + 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: []]) - FakePry.process('foo') + FakePry.process("foo") end end - context 'with a valid Guard plugin scope' do - let(:given_scope) { ['bar'] } + context "with a valid Guard plugin scope" do + let(:given_scope) { ["bar"] } let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } - it 'runs the :run_all action with the given scope' do + 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: []]) - FakePry.process('bar') + FakePry.process("bar") end end - context 'with an invalid scope' do - let(:given_scope) { ['baz'] } - let(:converted_scope) { [{ groups: [], plugins: [] }, ['baz']] } + context "with an invalid scope" do + let(:given_scope) { ["baz"] } + let(:converted_scope) { [{ groups: [], plugins: [] }, ["baz"]] } - it 'does not run the action' do - expect(output).to receive(:puts).with('Unknown scopes: baz') + it "does not run the action" do + expect(output).to receive(:puts).with("Unknown scopes: baz") expect(Guard).to_not receive(:async_queue_add) - FakePry.process('baz') + FakePry.process("baz") end end end diff --git a/spec/lib/guard/commands/change_spec.rb b/spec/lib/guard/commands/change_spec.rb index d81210e54..3cc1561f1 100644 --- a/spec/lib/guard/commands/change_spec.rb +++ b/spec/lib/guard/commands/change_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'guard/commands/change' +require "guard/commands/change" RSpec.describe Guard::Commands::Change do let(:output) { instance_double(Pry::Output) } @@ -11,35 +11,35 @@ def self.output; end before do allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with('change') do |&block| + allow(Pry::Commands).to receive(:create_command).with("change") do |&block| FakePry.instance_eval(&block) end described_class.import end - context 'with a file' do - it 'runs the :run_on_changes action with the given file' do + 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: []) + .with(modified: ["foo"], added: [], removed: []) - FakePry.process('foo') + FakePry.process("foo") end end - context 'with multiple files' do - it 'runs the :run_on_changes action with the given files' do + 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: []) - FakePry.process('foo', 'bar', 'baz') + FakePry.process("foo", "bar", "baz") end end - context 'without a file' do - it 'does not run the :run_on_changes action' do + context "without a file" do + it "does not run the :run_on_changes action" do expect(::Guard).to_not receive(:async_queue_add) - expect(output).to receive(:puts).with('Please specify a file.') + expect(output).to receive(:puts).with("Please specify a file.") FakePry.process end diff --git a/spec/lib/guard/commands/notification_spec.rb b/spec/lib/guard/commands/notification_spec.rb index 1ee175736..86a3d46cd 100644 --- a/spec/lib/guard/commands/notification_spec.rb +++ b/spec/lib/guard/commands/notification_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'guard/commands/notification' +require "guard/commands/notification" RSpec.describe Guard::Commands::Notification do let(:output) { instance_double(Pry::Output) } @@ -12,14 +12,14 @@ 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| + .with("notification") do |&block| FakePry.instance_eval(&block) end described_class.import end - it 'toggles the Guard notifier' do + it "toggles the Guard notifier" do expect(::Guard::Notifier).to receive(:toggle) FakePry.process end diff --git a/spec/lib/guard/commands/pause_spec.rb b/spec/lib/guard/commands/pause_spec.rb index 04c7ecce1..3dbce6ec6 100644 --- a/spec/lib/guard/commands/pause_spec.rb +++ b/spec/lib/guard/commands/pause_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'guard/commands/pause' +require "guard/commands/pause" RSpec.describe Guard::Commands::Pause do class FakePry < Pry::Command @@ -9,14 +9,14 @@ def self.output; end before do allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with('pause') do |&block| + allow(Pry::Commands).to receive(:create_command).with("pause") do |&block| FakePry.instance_eval(&block) end described_class.import end - it 'tells Guard to pause' do + it "tells Guard to pause" do expect(::Guard).to receive(:async_queue_add).with([:guard_pause]) FakePry.process end diff --git a/spec/lib/guard/commands/reload_spec.rb b/spec/lib/guard/commands/reload_spec.rb index a286e0eb6..054a46011 100644 --- a/spec/lib/guard/commands/reload_spec.rb +++ b/spec/lib/guard/commands/reload_spec.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require 'guard/commands/reload' +require "guard/commands/reload" -require 'guard/internals/session' -require 'guard/internals/state' +require "guard/internals/session" +require "guard/internals/state" RSpec.describe Guard::Commands::Reload do let(:output) { instance_double(Pry::Output) } - let(:state) { instance_double('Guard::Internals::State') } - let(:session) { instance_double('Guard::Internals::Session') } + let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double("Guard::Internals::Session") } let(:foo_group) { instance_double(Guard::Group) } let(:bar_guard) { instance_double(Guard::Plugin) } @@ -26,54 +26,54 @@ def self.output; end allow(Guard).to receive(:state).and_return(state) allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with('reload') do |&block| + allow(Pry::Commands).to receive(:create_command).with("reload") do |&block| FakePry.instance_eval(&block) end described_class.import end - context 'without scope' do + context "without scope" do let(:given_scope) { [] } let(:converted_scope) { [{ groups: [], plugins: [] }, []] } - it 'triggers the :reload action' do + it "triggers the :reload action" do expect(Guard).to receive(:async_queue_add) .with([:guard_reload, { groups: [], plugins: [] }]) FakePry.process end end - context 'with a valid Guard group scope' do - let(:given_scope) { ['foo'] } + context "with a valid Guard group scope" do + let(:given_scope) { ["foo"] } let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } - it 'triggers the :reload action with the given scope' do + it "triggers the :reload action with the given scope" do expect(Guard).to receive(:async_queue_add) .with([:guard_reload, { groups: [foo_group], plugins: [] }]) - FakePry.process('foo') + FakePry.process("foo") end end - context 'with a valid Guard plugin scope' do - let(:given_scope) { ['bar'] } + context "with a valid Guard plugin scope" do + let(:given_scope) { ["bar"] } let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } - it 'triggers the :reload action with the given scope' do + it "triggers the :reload action with the given scope" do expect(Guard).to receive(:async_queue_add) .with([:guard_reload, { plugins: [bar_guard], groups: [] }]) - FakePry.process('bar') + FakePry.process("bar") end end - context 'with an invalid scope' do - let(:given_scope) { ['baz'] } - let(:converted_scope) { [{ groups: [], plugins: [] }, ['baz']] } + context "with an invalid scope" do + let(:given_scope) { ["baz"] } + let(:converted_scope) { [{ groups: [], plugins: [] }, ["baz"]] } - it 'does not trigger the action' do - allow(output).to receive(:puts).with('Unknown scopes: baz') + it "does not trigger the action" do + allow(output).to receive(:puts).with("Unknown scopes: baz") expect(Guard).to_not receive(:async_queue_add) - FakePry.process('baz') + FakePry.process("baz") end end end diff --git a/spec/lib/guard/commands/scope_spec.rb b/spec/lib/guard/commands/scope_spec.rb index 8da0c6296..5fd4e5a1c 100644 --- a/spec/lib/guard/commands/scope_spec.rb +++ b/spec/lib/guard/commands/scope_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require 'guard/commands/scope' +require "guard/commands/scope" -require 'guard/internals/session' -require 'guard/internals/state' +require "guard/internals/session" +require "guard/internals/state" RSpec.describe Guard::Commands::Scope do let(:output) { instance_double(Pry::Output) } - let(:state) { instance_double('Guard::Internals::State') } - let(:scope) { instance_double('Guard::Internals::Scope') } - let(:session) { instance_double('Guard::Internals::Session') } + let(:state) { instance_double("Guard::Internals::State") } + let(:scope) { instance_double("Guard::Internals::Scope") } + let(:session) { instance_double("Guard::Internals::Session") } let(:foo_group) { instance_double(Guard::Group) } let(:bar_guard) { instance_double(Guard::PluginUtil) } @@ -27,7 +27,7 @@ def self.output; end allow(Guard).to receive(:state).and_return(state) allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with('scope') do |&block| + allow(Pry::Commands).to receive(:create_command).with("scope") do |&block| FakePry.instance_eval(&block) end @@ -37,47 +37,47 @@ def self.output; end described_class.import end - context 'without scope' do + context "without scope" do let(:given_scope) { [] } let(:converted_scope) { [{ groups: [], plugins: [] }, []] } - it 'does not call :scope= and shows usage' do - expect(output).to receive(:puts).with('Usage: scope ') + it "does not call :scope= and shows usage" do + expect(output).to receive(:puts).with("Usage: scope ") expect(scope).to_not receive(:from_interactor) FakePry.process end end - context 'with a valid Guard group scope' do - let(:given_scope) { ['foo'] } + context "with a valid Guard group scope" do + let(:given_scope) { ["foo"] } let(:converted_scope) { [{ groups: [foo_group], plugins: [] }, []] } - it 'sets up the scope with the given scope' do + it "sets up the scope with the given scope" do expect(scope).to receive(:from_interactor) .with(groups: [foo_group], plugins: []) - FakePry.process('foo') + FakePry.process("foo") end end - context 'with a valid Guard plugin scope' do - let(:given_scope) { ['bar'] } + context "with a valid Guard plugin scope" do + let(:given_scope) { ["bar"] } let(:converted_scope) { [{ groups: [], plugins: [bar_guard] }, []] } - it 'runs the :scope= action with the given scope' do + it "runs the :scope= action with the given scope" do expect(scope).to receive(:from_interactor) .with(plugins: [bar_guard], groups: []) - FakePry.process('bar') + FakePry.process("bar") end end - context 'with an invalid scope' do - let(:given_scope) { ['baz'] } - let(:converted_scope) { [{ groups: [], plugins: [] }, ['baz']] } + context "with an invalid scope" do + let(:given_scope) { ["baz"] } + let(:converted_scope) { [{ groups: [], plugins: [] }, ["baz"]] } - it 'does not change the scope and shows unknown scopes' do - expect(output).to receive(:puts).with('Unknown scopes: baz') + it "does not change the scope and shows unknown scopes" do + expect(output).to receive(:puts).with("Unknown scopes: baz") expect(scope).to_not receive(:from_interactor) - FakePry.process('baz') + FakePry.process("baz") end end end diff --git a/spec/lib/guard/commands/show_spec.rb b/spec/lib/guard/commands/show_spec.rb index 21108021a..fbfe2bf9f 100644 --- a/spec/lib/guard/commands/show_spec.rb +++ b/spec/lib/guard/commands/show_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require 'guard/commands/show' +require "guard/commands/show" # TODO: we only need the async queue -require 'guard' +require "guard" RSpec.describe Guard::Commands::Show do let(:output) { instance_double(Pry::Output) } @@ -14,14 +14,14 @@ def self.output; end before do allow(FakePry).to receive(:output).and_return(output) - allow(Pry::Commands).to receive(:create_command).with('show') do |&block| + allow(Pry::Commands).to receive(:create_command).with("show") do |&block| FakePry.instance_eval(&block) end described_class.import end - it 'tells Guard to output DSL description' do + it "tells Guard to output DSL description" do expect(::Guard).to receive(:async_queue_add).with([:guard_show]) FakePry.process end diff --git a/spec/lib/guard/config_spec.rb b/spec/lib/guard/config_spec.rb index e1bcbf043..f5574f77a 100644 --- a/spec/lib/guard/config_spec.rb +++ b/spec/lib/guard/config_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require 'guard/config' +require "guard/config" RSpec.describe Guard::Config, exclude_stubs: [:Nenv] do it { is_expected.to respond_to(:strict?) } it { is_expected.to respond_to(:silence_deprecations?) } - describe '.strict?' do + describe ".strict?" do before do allow(subject).to receive(:strict?).and_return(result) end diff --git a/spec/lib/guard/deprecated/dsl_spec.rb b/spec/lib/guard/deprecated/dsl_spec.rb index 0ed69c1e9..4a2594e6f 100644 --- a/spec/lib/guard/deprecated/dsl_spec.rb +++ b/spec/lib/guard/deprecated/dsl_spec.rb @@ -1,35 +1,35 @@ # frozen_string_literal: true -require 'guard/config' +require "guard/config" unless Guard::Config.new.strict? # Require listen now, so the requiring below doesn't use File methods - require 'listen' + require "listen" - require 'guard/deprecated/dsl' + require "guard/deprecated/dsl" - require 'guard/ui' - require 'guard/config' + require "guard/ui" + require "guard/config" RSpec.describe Guard::Deprecated::Dsl do subject do module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end - describe '.evaluate_guardfile' do + describe ".evaluate_guardfile" do before { stub_user_guard_rb } - before { stub_guardfile(' ') } + before { stub_guardfile(" ") } before { stub_user_guardfile } before { stub_user_project_guardfile } - let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } + let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } before do # TODO: this is a workaround for a bad require loop allow_any_instance_of(Guard::Config).to receive(:strict?) .and_return(false) - require 'guard/guardfile/evaluator' + require "guard/guardfile/evaluator" allow(Guard::Guardfile::Evaluator).to receive(:new) .and_return(evaluator) @@ -39,20 +39,20 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(Guard::UI).to receive(:deprecation) end - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Dsl::ClassMethods::EVALUATE_GUARDFILE) subject.evaluate_guardfile end - it 'delegates to Guard::Guardfile::Generator' do + it "delegates to Guard::Guardfile::Generator" do expect(Guard::Guardfile::Evaluator).to receive(:new) - .with(foo: 'bar') { evaluator } + .with(foo: "bar") { evaluator } expect(evaluator).to receive(:evaluate_guardfile) - subject.evaluate_guardfile(foo: 'bar') + subject.evaluate_guardfile(foo: "bar") end end end diff --git a/spec/lib/guard/deprecated/evaluator_spec.rb b/spec/lib/guard/deprecated/evaluator_spec.rb index 0afb841d8..f8a1d4d69 100644 --- a/spec/lib/guard/deprecated/evaluator_spec.rb +++ b/spec/lib/guard/deprecated/evaluator_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'guard/config' +require "guard/config" unless Guard::Config.new.strict? - require 'guard/deprecated/evaluator' - require 'guard/internals/state' + require "guard/deprecated/evaluator" + require "guard/internals/state" RSpec.describe Guard::Deprecated::Evaluator do subject do @@ -16,32 +16,32 @@ def evaluate; end TestClass.new end - let(:state) { instance_double('Guard::Internals::State') } + let(:state) { instance_double("Guard::Internals::State") } before do allow(Guard::UI).to receive(:deprecation) allow(Guard).to receive(:state).and_return(state) end - describe '#evaluate_guardfile' do + describe "#evaluate_guardfile" do before do allow(subject).to receive(:evaluate) end - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Evaluator::EVALUATE_GUARDFILE) subject.evaluate_guardfile end - it 'calls the recommended method' do + it "calls the recommended method" do expect(subject).to receive(:evaluate) subject.evaluate_guardfile end end - describe '#reevaluate_guardfile' do - it 'displays a deprecation warning to the user' do + 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) subject.reevaluate_guardfile diff --git a/spec/lib/guard/deprecated/guard_spec.rb b/spec/lib/guard/deprecated/guard_spec.rb index 7037c7ccd..5981faf57 100644 --- a/spec/lib/guard/deprecated/guard_spec.rb +++ b/spec/lib/guard/deprecated/guard_spec.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true -require 'guard/config' +require "guard/config" unless Guard::Config.new.strict? # require guard, to avoid circular require - require 'guard' + require "guard" # require "guard/deprecated/guard" - require 'guard/config' + require "guard/config" RSpec.describe Guard::Deprecated::Guard do - let(:session) { instance_double('Guard::Internals::Session') } - let(:state) { instance_double('Guard::Internals::State') } - let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:groups) { instance_double('Guard::Internals::Groups') } - let(:scope) { instance_double('Guard::Internals::Scope') } + let(:session) { instance_double("Guard::Internals::Session") } + let(:state) { instance_double("Guard::Internals::State") } + let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:groups) { instance_double("Guard::Internals::Groups") } + let(:scope) { instance_double("Guard::Internals::Scope") } subject do module TestModule @@ -40,113 +40,113 @@ def self._pluginless_guardfile? allow(groups).to receive(:all) end - describe '.guards' do + describe ".guards" do before do end - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::GUARDS) subject.guards end - it 'delegates to Plugins' do - expect(plugins).to receive(:all).with(group: 'backend') - subject.guards(group: 'backend') + it "delegates to Plugins" do + expect(plugins).to receive(:all).with(group: "backend") + subject.guards(group: "backend") end end - describe '.add_guard' do - before { allow(plugins).to receive(:add).with('rspec', {}) } + describe ".add_guard" do + before { allow(plugins).to receive(:add).with("rspec", {}) } - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::ADD_GUARD) - subject.add_guard('rspec') + subject.add_guard("rspec") end - it 'delegates to Guard.plugins' do - expect(subject).to receive(:add_plugin).with('rspec', group: 'backend') + it "delegates to Guard.plugins" do + expect(subject).to receive(:add_plugin).with("rspec", group: "backend") - subject.add_guard('rspec', group: 'backend') + subject.add_guard("rspec", group: "backend") end end - describe '.get_guard_class' do + describe ".get_guard_class" do let(:plugin_util) do - instance_double('Guard::PluginUtil', plugin_class: true) + instance_double("Guard::PluginUtil", plugin_class: true) end before do - allow(Guard::PluginUtil).to receive(:new).with('rspec') + allow(Guard::PluginUtil).to receive(:new).with("rspec") .and_return(plugin_util) end - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::GET_GUARD_CLASS) - subject.get_guard_class('rspec') + subject.get_guard_class("rspec") end - it 'delegates to Guard::PluginUtil' do + it "delegates to Guard::PluginUtil" do expect(plugin_util).to receive(:plugin_class) .with(fail_gracefully: false) - subject.get_guard_class('rspec') + subject.get_guard_class("rspec") end - describe ':fail_gracefully' do - it 'pass it to get_guard_class' do + describe ":fail_gracefully" do + it "pass it to get_guard_class" do expect(plugin_util).to receive(:plugin_class) .with(fail_gracefully: true) - subject.get_guard_class('rspec', true) + subject.get_guard_class("rspec", true) end end end - describe '.locate_guard' do + describe ".locate_guard" do let(:plugin_util) do - instance_double('Guard::PluginUtil', plugin_location: true) + instance_double("Guard::PluginUtil", plugin_location: true) end before do allow(Guard::PluginUtil).to receive(:new) { plugin_util } end - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::LOCATE_GUARD) - subject.locate_guard('rspec') + subject.locate_guard("rspec") end - it 'delegates to Guard::PluginUtil' do - expect(Guard::PluginUtil).to receive(:new).with('rspec') { plugin_util } + it "delegates to Guard::PluginUtil" do + expect(Guard::PluginUtil).to receive(:new).with("rspec") { plugin_util } expect(plugin_util).to receive(:plugin_location) - subject.locate_guard('rspec') + subject.locate_guard("rspec") end end - describe '.guard_gem_names' do + describe ".guard_gem_names" do before { allow(Guard::PluginUtil).to receive(:plugin_names) } - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::GUARD_GEM_NAMES) subject.guard_gem_names end - it 'delegates to Guard::PluginUtil' do + it "delegates to Guard::PluginUtil" do expect(Guard::PluginUtil).to receive(:plugin_names) subject.guard_gem_names end end - describe '.running' do - it 'show deprecation warning' do + describe ".running" do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::RUNNING) @@ -154,8 +154,8 @@ def self._pluginless_guardfile? end end - describe '.lock' do - it 'show deprecation warning' do + describe ".lock" do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::LOCK) @@ -163,41 +163,41 @@ def self._pluginless_guardfile? end end - describe '.listener=' do - it 'show deprecation warning' do + describe ".listener=" do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::LISTENER_ASSIGN) subject.listener = 123 end - it 'provides and alternative implementation' do + it "provides and alternative implementation" do subject.listener = 123 end end - describe 'reset_evaluator' do - it 'show deprecation warning' do + describe "reset_evaluator" do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::RESET_EVALUATOR) subject.reset_evaluator({}) end end - describe 'evaluator' do + describe "evaluator" do before do allow(Guard::Guardfile::Evaluator).to receive(:new) - .and_return(double('evaluator')) + .and_return(double("evaluator")) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::EVALUATOR) subject.evaluator end end - describe 'evaluate_guardfile' do - let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } + describe "evaluate_guardfile" do + let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } before do allow(::Guard::Guardfile::Evaluator).to receive(:new) @@ -205,19 +205,19 @@ def self._pluginless_guardfile? allow(evaluator).to receive(:evaluate) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::EVALUATOR) subject.evaluate_guardfile end - it 'evaluates the guardfile' do + it "evaluates the guardfile" do expect(evaluator).to receive(:evaluate) subject.evaluate_guardfile end end - describe 'options' do + describe "options" do before do allow(session).to receive(:clearing?) allow(session).to receive(:debug?) @@ -226,43 +226,43 @@ def self._pluginless_guardfile? allow(session).to receive(:interactor_name) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::OPTIONS) subject.options end - describe ':clear' do + describe ":clear" do before do allow(session).to receive(:clearing?).and_return(clearing) end - context 'when being set to true' do + context "when being set to true" do let(:clearing) { true } - it 'sets the clearing option accordingly' do + it "sets the clearing option accordingly" do expect(session).to receive(:clearing).with(true) subject.options[:clear] = true end end - context 'when being set to false' do + context "when being set to false" do let(:clearing) { false } - it 'sets the clearing option accordingly' do + it "sets the clearing option accordingly" do expect(session).to receive(:clearing).with(false) subject.options[:clear] = false end end - context 'when being read' do - context 'when not set' do + context "when being read" do + context "when not set" do let(:clearing) { false } - it 'provides an alternative implementation' do + it "provides an alternative implementation" do expect(subject.options).to include(clear: false) end end - context 'when set' do + context "when set" do let(:clearing) { true } - it 'provides an alternative implementation' do + it "provides an alternative implementation" do expect(subject.options).to include(clear: true) end end @@ -272,43 +272,43 @@ def self._pluginless_guardfile? # TODO: other options? end - describe '.add_group' do + describe ".add_group" do before do allow(groups).to receive(:add) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::ADD_GROUP) subject.add_group(:foo) end - it 'adds a group' do - group = instance_double('Guard::Group') + it "adds a group" do + group = instance_double("Guard::Group") expect(groups).to receive(:add).with(:foo, bar: 3).and_return(group) expect(subject.add_group(:foo, bar: 3)).to eq(group) end end - describe '.add_plugin' do + describe ".add_plugin" do before do allow(plugins).to receive(:add) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::ADD_PLUGIN) subject.add_plugin(:foo) end - it 'adds a plugin' do - plugin = instance_double('Guard::Plugin') + it "adds a plugin" do + plugin = instance_double("Guard::Plugin") expect(plugins).to receive(:add).with(:foo, bar: 3).and_return(plugin) expect(subject.add_plugin(:foo, bar: 3)).to be(plugin) end end - describe '.group' do + describe ".group" do let(:array) { instance_double(Array) } before do @@ -316,105 +316,105 @@ def self._pluginless_guardfile? allow(array).to receive(:first) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::GROUP) subject.group(:foo) end - it 'provides a similar implementation' do - group = instance_double('Guard::Group') + it "provides a similar implementation" do + group = instance_double("Guard::Group") expect(array).to receive(:first).and_return(group) expect(subject.group(:foo)).to be(group) end end - describe '.plugin' do + describe ".plugin" do let(:array) { instance_double(Array) } - let(:plugin) { instance_double('Guard::Plugin') } + let(:plugin) { instance_double("Guard::Plugin") } before do allow(plugins).to receive(:all).with(:foo).and_return(array) allow(array).to receive(:first).and_return(plugin) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::PLUGIN) subject.plugin(:foo) end - it 'provides a similar implementation' do + it "provides a similar implementation" do expect(subject.plugin(:foo)).to be(plugin) end end - describe '.groups' do + describe ".groups" do let(:array) { instance_double(Array) } before do allow(groups).to receive(:all).with(:foo).and_return(array) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::GROUPS) subject.groups(:foo) end - it 'provides a similar implementation' do + it "provides a similar implementation" do expect(subject.groups(:foo)).to be(array) end end - describe '.plugins' do + describe ".plugins" do let(:array) { instance_double(Array) } before do allow(plugins).to receive(:all).with(:foo).and_return(array) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::PLUGINS) subject.plugins(:foo) end - it 'provides a similar implementation' do + it "provides a similar implementation" do expect(subject.plugins(:foo)).to be(array) end end - describe '.scope' do + describe ".scope" do let(:hash) { instance_double(Hash) } before do allow(scope).to receive(:to_hash).and_return(hash) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::SCOPE) subject.scope end - it 'provides a similar implementation' do + it "provides a similar implementation" do expect(subject.scope).to be(hash) end end - describe '.scope=' do + describe ".scope=" do before do allow(scope).to receive(:from_interactor).with(foo: :bar) end - it 'show deprecation warning' do + it "show deprecation warning" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guard::ClassMethods::SCOPE_ASSIGN) subject.scope = { foo: :bar } end - it 'provides a similar implementation' do + it "provides a similar implementation" do expect(scope).to receive(:from_interactor).with(foo: :bar) subject.scope = { foo: :bar } end diff --git a/spec/lib/guard/deprecated/guardfile_spec.rb b/spec/lib/guard/deprecated/guardfile_spec.rb index ef3f79b3d..c52bd7d5d 100644 --- a/spec/lib/guard/deprecated/guardfile_spec.rb +++ b/spec/lib/guard/deprecated/guardfile_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require 'guard/config' +require "guard/config" unless Guard::Config.new.strict? - require 'guard/deprecated/guardfile' + require "guard/deprecated/guardfile" RSpec.describe Guard::Deprecated::Guardfile do subject do module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end - let(:generator) { instance_double('Guard::Guardfile::Generator') } + let(:generator) { instance_double("Guard::Guardfile::Generator") } before do allow(Guard::UI).to receive(:deprecation) end - describe '.create_guardfile' do + describe ".create_guardfile" do before do - allow(File).to receive(:exist?).with('Guardfile').and_return(false) + allow(File).to receive(:exist?).with("Guardfile").and_return(false) template = Guard::Guardfile::Generator::GUARDFILE_TEMPLATE - allow(FileUtils).to receive(:cp).with(template, 'Guardfile') + allow(FileUtils).to receive(:cp).with(template, "Guardfile") allow(Guard::Guardfile::Generator).to receive(:new) .and_return(generator) @@ -29,24 +29,24 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(generator).to receive(:create_guardfile) end - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guardfile::ClassMethods::CREATE_GUARDFILE) subject.create_guardfile end - it 'delegates to Guard::Guardfile::Generator' do + it "delegates to Guard::Guardfile::Generator" do expect(Guard::Guardfile::Generator).to receive(:new) - .with(foo: 'bar') { generator } + .with(foo: "bar") { generator } expect(generator).to receive(:create_guardfile) - subject.create_guardfile(foo: 'bar') + subject.create_guardfile(foo: "bar") end end - describe '.initialize_template' do + describe ".initialize_template" do before do expect(Guard::Guardfile::Generator).to receive(:new) do generator @@ -55,21 +55,21 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(generator).to receive(:initialize_template) end - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(Guard::Deprecated::Guardfile::ClassMethods::INITIALIZE_TEMPLATE) - subject.initialize_template('rspec') + subject.initialize_template("rspec") end - it 'delegates to Guard::Guardfile::Generator' do - expect(generator).to receive(:initialize_template).with('rspec') + it "delegates to Guard::Guardfile::Generator" do + expect(generator).to receive(:initialize_template).with("rspec") - subject.initialize_template('rspec') + subject.initialize_template("rspec") end end - describe '.initialize_all_templates' do + describe ".initialize_all_templates" do before do expect(Guard::Guardfile::Generator).to receive(:new) do generator @@ -78,14 +78,14 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(generator).to receive(:initialize_all_templates) end - it 'displays a deprecation warning to the user' do + it "displays a deprecation warning to the user" do expect(Guard::UI).to receive(:deprecation) .with(described_class::ClassMethods::INITIALIZE_ALL_TEMPLATES) subject.initialize_all_templates end - it 'delegates to Guard::Guardfile::Generator' do + it "delegates to Guard::Guardfile::Generator" do expect(generator).to receive(:initialize_all_templates) subject.initialize_all_templates diff --git a/spec/lib/guard/deprecated/watcher_spec.rb b/spec/lib/guard/deprecated/watcher_spec.rb index 0f26c5c27..f803b0883 100644 --- a/spec/lib/guard/deprecated/watcher_spec.rb +++ b/spec/lib/guard/deprecated/watcher_spec.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true -require 'guard/config' +require "guard/config" unless Guard::Config.new.strict? - require 'guard/deprecated/watcher' - require 'guard/guardfile/evaluator' + require "guard/deprecated/watcher" + require "guard/guardfile/evaluator" RSpec.describe Guard::Deprecated::Watcher do - let(:session) { instance_double('Guard::Internals::Session') } + let(:session) { instance_double("Guard::Internals::Session") } subject do module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } end - let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } - let(:options) { { guardfile: 'foo' } } + let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } + let(:options) { { guardfile: "foo" } } - let(:state) { instance_double('Guard::Internals::State') } + let(:state) { instance_double("Guard::Internals::State") } before do allow(session).to receive(:evaluator_options).and_return(options) @@ -25,7 +25,7 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(Guard).to receive(:state).and_return(state) allow(evaluator).to receive(:guardfile_path) - .and_return(File.expand_path('foo')) + .and_return(File.expand_path("foo")) allow(::Guard::Guardfile::Evaluator).to receive(:new).with(options) .and_return(evaluator) @@ -33,8 +33,8 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } allow(Guard::UI).to receive(:deprecation) end - describe '.match_guardfile?' do - it 'displays a deprecation warning to the user' do + 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) @@ -42,7 +42,7 @@ module TestModule; end.tap { |mod| described_class.add_deprecated(mod) } subject.match_guardfile?(files) end - it 'matches against current guardfile' do + 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) end diff --git a/spec/lib/guard/dsl_describer_spec.rb b/spec/lib/guard/dsl_describer_spec.rb index 9920b9a61..ceef61770 100644 --- a/spec/lib/guard/dsl_describer_spec.rb +++ b/spec/lib/guard/dsl_describer_spec.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -require 'guard/plugin' -require 'guard/dsl_describer' -require 'formatador' +require "guard/plugin" +require "guard/dsl_describer" +require "formatador" RSpec.describe Guard::DslDescriber do let(:interactor) { instance_double(Guard::Interactor) } - let(:env) { double('ENV') } + let(:env) { double("ENV") } - let(:session) { instance_double('Guard::Internals::Session') } - let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:groups) { instance_double('Guard::Internals::Groups') } - let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double("Guard::Internals::Session") } + let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:groups) { instance_double("Guard::Internals::Groups") } + let(:state) { instance_double("Guard::Internals::State") } before do allow(session).to receive(:groups).and_return(groups) @@ -19,15 +19,15 @@ allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) - allow(env).to receive(:[]).with('GUARD_NOTIFY_PID') - allow(env).to receive(:[]).with('GUARD_NOTIFY') - allow(env).to receive(:[]).with('GUARD_NOTIFIERS') - allow(env).to receive(:[]=).with('GUARD_NOTIFIERS', anything) + allow(env).to receive(:[]).with("GUARD_NOTIFY_PID") + allow(env).to receive(:[]).with("GUARD_NOTIFY") + allow(env).to receive(:[]).with("GUARD_NOTIFIERS") + allow(env).to receive(:[]=).with("GUARD_NOTIFIERS", anything) allow(Guard::Notifier).to receive(:turn_on) - stub_const 'Guard::Test', class_double('Guard::Plugin') - stub_const 'Guard::Another', class_double('Guard::Plugin') + stub_const "Guard::Test", class_double("Guard::Plugin") + stub_const "Guard::Another", class_double("Guard::Plugin") # TODO: Reenable rubocop and refactor to +'' one 2.2 compatibility is dropped @output = String.new @@ -42,7 +42,7 @@ end end - describe '#list' do + describe "#list" do let(:result) do <<-OUTPUT +---------+-----------+ @@ -56,27 +56,27 @@ OUTPUT end - let(:another) { instance_double('Guard::Plugin', title: 'Another') } - let(:test) { instance_double('Guard::Plugin', title: 'Test') } + let(:another) { instance_double("Guard::Plugin", title: "Another") } + let(:test) { instance_double("Guard::Plugin", title: "Test") } before do - allow(plugins).to receive(:all).with('another').and_return([another]) - allow(plugins).to receive(:all).with('test').and_return([test]) - allow(plugins).to receive(:all).with('even').and_return([]) - allow(plugins).to receive(:all).with('more').and_return([]) + allow(plugins).to receive(:all).with("another").and_return([another]) + allow(plugins).to receive(:all).with("test").and_return([test]) + allow(plugins).to receive(:all).with("even").and_return([]) + allow(plugins).to receive(:all).with("more").and_return([]) allow(Guard::PluginUtil).to receive(:plugin_names) do %w[test another even more] end end - it 'lists the available Guards declared as strings or symbols' do + it "lists the available Guards declared as strings or symbols" do subject.list expect(@output).to eq result end end - describe '.show' do + describe ".show" do let(:result) do <<-OUTPUT +---------+---------+--------+-------+ @@ -95,33 +95,33 @@ before do 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: :default, title: "Default"), + instance_double("Guard::Group", name: :a, title: "A"), + instance_double("Guard::Group", name: :b, title: "B") ] allow(plugins).to receive(:all).with(group: :default) do options = { a: :b, c: :d } - [instance_double('Guard::Plugin', title: 'Test', options: options)] + [instance_double("Guard::Plugin", title: "Test", options: options)] end allow(plugins).to receive(:all).with(group: :a) do options = { x: 1, y: 2 } - [instance_double('Guard::Plugin', title: 'Test', options: options)] + [instance_double("Guard::Plugin", title: "Test", options: options)] end allow(plugins).to receive(:all).with(group: :b).and_return [ - instance_double('Guard::Plugin', title: 'Another', options: []) + instance_double("Guard::Plugin", title: "Another", options: []) ] end - it 'shows the Guards and their options' do + it "shows the Guards and their options" do subject.show expect(@output).to eq result end end - describe '.notifiers' do + describe ".notifiers" do let(:result) do <<-OUTPUT +----------------+-----------+------+--------+-------+ @@ -147,7 +147,7 @@ allow(Guard::Notifier).to receive(:disconnect).once end - it 'properly connects and disconnects' do + it "properly connects and disconnects" do expect(Guard::Notifier).to receive(:connect).once.ordered expect(::Guard::Notifier).to receive(:detected).once.ordered.and_return [ { name: :gntp, options: { sticky: true } } @@ -158,7 +158,7 @@ subject.notifiers end - it 'shows the notifiers and their options' do + it "shows the notifiers and their options" do subject.notifiers expect(@output).to eq result end diff --git a/spec/lib/guard/dsl_reader_spec.rb b/spec/lib/guard/dsl_reader_spec.rb index d8925b4d7..5cb1ae71d 100644 --- a/spec/lib/guard/dsl_reader_spec.rb +++ b/spec/lib/guard/dsl_reader_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'guard/dsl_reader' +require "guard/dsl_reader" RSpec.describe Guard::DslReader, exclude_stubs: [Guard::Dsl] do methods = %w[ @@ -10,50 +10,50 @@ methods.each do |meth| describe "\##{meth} signature" do - it 'matches base signature' do + it "matches base signature" do expected = Guard::Dsl.instance_method(meth).arity expect(subject.method(meth).arity).to eq(expected) end end end - describe 'guard' do - context 'when it is a String' do - let(:name) { 'foo' } - it 'works without errors' do + describe "guard" do + context "when it is a String" do + let(:name) { "foo" } + it "works without errors" do expect { subject.guard(name, bar: :baz) }.to_not raise_error end - it 'reports the name as a String' do - subject.guard('foo', bar: :baz) + it "reports the name as a String" do + subject.guard("foo", bar: :baz) expect(subject.plugin_names).to eq(%w[foo]) end end - context 'when it is a Symbol' do + context "when it is a Symbol" do let(:name) { :foo } - it 'works without errors' do + it "works without errors" do expect { subject.guard(name, bar: :baz) }.to_not raise_error end - it 'reports the name as a String' do + it "reports the name as a String" do subject.guard(name, bar: :baz) expect(subject.plugin_names).to eq(%w[foo]) end end end - describe 'plugin_names' do - it 'returns encountered names' do - subject.guard('foo', bar: :baz) - subject.guard('bar', bar: :baz) - subject.guard('baz', bar: :baz) + describe "plugin_names" do + it "returns encountered names" do + 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]) end end - describe 'notification' do - it 'handles arguments without errors' do + describe "notification" do + it "handles arguments without errors" do expect { subject.notification(:off) }.to_not raise_error end end diff --git a/spec/lib/guard/dsl_spec.rb b/spec/lib/guard/dsl_spec.rb index 5614a7744..2fc788138 100644 --- a/spec/lib/guard/dsl_spec.rb +++ b/spec/lib/guard/dsl_spec.rb @@ -1,33 +1,33 @@ # frozen_string_literal: true -require 'guard/plugin' +require "guard/plugin" -require 'guard/dsl' +require "guard/dsl" RSpec.describe Guard::Dsl do - let(:ui_config) { instance_double('Guard::UI::Config') } + let(:ui_config) { instance_double("Guard::UI::Config") } let(:guardfile_evaluator) { instance_double(Guard::Guardfile::Evaluator) } let(:interactor) { instance_double(Guard::Interactor) } - let(:listener) { instance_double('Listen::Listener') } + let(:listener) { instance_double("Listen::Listener") } - let(:session) { instance_double('Guard::Internals::Session') } - let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:groups) { instance_double('Guard::Internals::Groups') } - let(:state) { instance_double('Guard::Internals::State') } - let(:scope) { instance_double('Guard::Internals::Scope') } + let(:session) { instance_double("Guard::Internals::Session") } + let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:groups) { instance_double("Guard::Internals::Groups") } + let(:state) { instance_double("Guard::Internals::State") } + let(:scope) { instance_double("Guard::Internals::Scope") } let(:evaluator) do proc do |contents| - Guard::Dsl.new.evaluate(contents, '', 1) + Guard::Dsl.new.evaluate(contents, "", 1) end end before do stub_user_guard_rb - stub_const 'Guard::Foo', instance_double(Guard::Plugin) - stub_const 'Guard::Bar', instance_double(Guard::Plugin) - stub_const 'Guard::Baz', instance_double(Guard::Plugin) + stub_const "Guard::Foo", instance_double(Guard::Plugin) + stub_const "Guard::Bar", instance_double(Guard::Plugin) + stub_const "Guard::Baz", instance_double(Guard::Plugin) allow(Guard::Notifier).to receive(:turn_on) allow(Guard::Interactor).to receive(:new).and_return(interactor) @@ -38,26 +38,26 @@ allow(Guard).to receive(:state).and_return(state) # For backtrace cleanup - allow(ENV).to receive(:[]).with('GEM_HOME').and_call_original - allow(ENV).to receive(:[]).with('GEM_PATH').and_call_original + allow(ENV).to receive(:[]).with("GEM_HOME").and_call_original + allow(ENV).to receive(:[]).with("GEM_PATH").and_call_original allow(Guard::UI::Config).to receive(:new).and_return(ui_config) end - describe '#ignore' do - context 'with ignore regexps' do - let(:contents) { 'ignore %r{^foo}, /bar/' } + describe "#ignore" do + context "with ignore regexps" do + let(:contents) { "ignore %r{^foo}, /bar/" } - it 'adds ignored regexps to the listener' do + it "adds ignored regexps to the listener" do expect(session).to receive(:guardfile_ignore=).with([/^foo/, /bar/]) evaluator.call(contents) end end - context 'with multiple ignore calls' do - let(:contents) { 'ignore(/foo/); ignore(/bar/)' } + context "with multiple ignore calls" do + let(:contents) { "ignore(/foo/); ignore(/bar/)" } - it 'adds all ignored regexps to the listener' do + it "adds all ignored regexps to the listener" do expect(session).to receive(:guardfile_ignore=).with([/foo/]).once expect(session).to receive(:guardfile_ignore=).with([/bar/]).once evaluator.call(contents) @@ -65,11 +65,11 @@ end end - describe '#ignore!' do - context 'when ignoring only foo* and *bar*' do - let(:contents) { 'ignore! %r{^foo}, /bar/' } + describe "#ignore!" do + context "when ignoring only foo* and *bar*" do + let(:contents) { "ignore! %r{^foo}, /bar/" } - it 'replaces listener regexps' do + it "replaces listener regexps" do expect(session).to receive(:guardfile_ignore_bang=) .with([[/^foo/, /bar/]]) @@ -77,10 +77,10 @@ end end - context 'when ignoring *.txt and *.zip and ignoring! only foo*' do + context "when ignoring *.txt and *.zip and ignoring! only foo*" do let(:contents) { "ignore! %r{.txt$}, /.*\\.zip/\n ignore! %r{^foo}" } - it 'replaces listener ignores, but keeps ignore! ignores' do + it "replaces listener ignores, but keeps ignore! ignores" do allow(session).to receive(:guardfile_ignore_bang=) .with([[/.txt$/, /.*\.zip/]]) @@ -98,37 +98,37 @@ def method_for(klass, meth) end # TODO: deprecated #filter - describe '#filter alias method' do + describe "#filter alias method" do subject { method_for(described_class, :filter) } it { is_expected.to eq(method_for(described_class, :ignore)) } end # TODO: deprecated #filter - describe '#filter! alias method' do + describe "#filter! alias method" do subject { method_for(described_class, :filter!) } it { is_expected.to eq(method_for(described_class, :ignore!)) } end - describe '#notification' do - context 'when notification' do - let(:contents) { 'notification :growl' } + describe "#notification" do + context "when notification" do + let(:contents) { "notification :growl" } - it 'adds a notification to the notifier' do + it "adds a notification to the notifier" do expect(session).to receive(:guardfile_notification=).with(growl: {}) evaluator.call(contents) end end - context 'with multiple notifications' do + context "with multiple notifications" do let(:contents) do "notification :growl\nnotification :ruby_gntp, host: '192.168.1.5'" end - it 'adds multiple notifiers' do + it "adds multiple notifiers" do expect(session).to receive(:guardfile_notification=).with(growl: {}) expect(session).to receive(:guardfile_notification=).with( - ruby_gntp: { host: '192.168.1.5' } + ruby_gntp: { host: "192.168.1.5" } ) evaluator.call(contents) @@ -136,43 +136,43 @@ def method_for(klass, meth) end end - describe '#interactor' do - context 'with interactor :off' do - let(:contents) { 'interactor :off' } - it 'disables the interactions with :off' do + describe "#interactor" do + context "with interactor :off" do + let(:contents) { "interactor :off" } + it "disables the interactions with :off" do expect(Guard::Interactor).to receive(:enabled=).with(false) evaluator.call(contents) end end - context 'with interactor options' do - let(:contents) { 'interactor option1: \'a\', option2: 123' } - it 'passes the options to the interactor' do + context "with interactor options" do + 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) + .with(option1: "a", option2: 123) evaluator.call(contents) end end end - describe '#group' do - context 'no plugins in group' do - let(:contents) { 'group :w' } + describe "#group" do + context "no plugins in group" do + let(:contents) { "group :w" } - it 'displays an error' do + it "displays an error" do expect(::Guard::UI).to receive(:error) .with("No Guard plugins found in the group 'w',"\ - ' please add at least one.') + " please add at least one.") evaluator.call(contents) end end - context 'group named :all' do - let(:contents) { 'group :all' } + context "group named :all" do + let(:contents) { "group :all" } - it 'raises an error' do + it "raises an error" do expect { evaluator.call(contents) } .to raise_error( Guard::Dsl::Error, @@ -184,7 +184,7 @@ def method_for(klass, meth) context 'group named "all"' do let(:contents) { "group 'all'" } - it 'raises an error' do + it "raises an error" do expect { evaluator.call(contents) } .to raise_error( Guard::Dsl::Error, @@ -193,10 +193,10 @@ def method_for(klass, meth) end end - context 'with a valid guardfile' do + context "with a valid guardfile" do let(:contents) { valid_guardfile_string } - it 'evaluates all groups' do + it "evaluates all groups" do expect(groups).to receive(:add).with(:w, {}) expect(groups).to receive(:add).with(:y, {}) expect(groups).to receive(:add).with(:x, halt_on_fail: true) @@ -218,9 +218,9 @@ def method_for(klass, meth) end end - context 'with multiple names' do - let(:contents) { 'group :foo, :bar do; end' } - it 'adds all given groups' do + context "with multiple names" do + let(:contents) { "group :foo, :bar do; end" } + it "adds all given groups" do expect(groups).to receive(:add).with(:foo, {}) expect(groups).to receive(:add).with(:bar, {}) @@ -229,33 +229,33 @@ def method_for(klass, meth) end end - describe '#guard' do - context 'with single-quoted name' do - let(:contents) { 'guard \'test\'' } + describe "#guard" do + context "with single-quoted name" do + let(:contents) { "guard 'test'" } - it 'loads a guard specified as a quoted string from the DSL' do + it "loads a guard specified as a quoted string from the DSL" do expect(plugins).to receive(:add) - .with('test', watchers: [], callbacks: [], group: :default) + .with("test", watchers: [], callbacks: [], group: :default) evaluator.call(contents) end end - context 'with double-quoted name' do + context "with double-quoted name" do let(:contents) { 'guard "test"' } - it 'loads a guard specified as a double quoted string from the DSL' do + 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) + .with("test", watchers: [], callbacks: [], group: :default) evaluator.call(contents) end end - context 'with symbol for name' do - let(:contents) { 'guard :test' } + context "with symbol for name" do + let(:contents) { "guard :test" } - it 'loads a guard specified as a symbol from the DSL' do + it "loads a guard specified as a symbol from the DSL" do expect(plugins).to receive(:add) .with(:test, watchers: [], callbacks: [], group: :default) @@ -263,37 +263,37 @@ def method_for(klass, meth) end end - context 'with name as symbol in parens' do - let(:contents) { 'guard(:test)' } + context "with name as symbol in parens" do + let(:contents) { "guard(:test)" } - it 'adds the plugin' do + it "adds the plugin" do 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\'' } + context "with options" do + let(:contents) { "guard 'test', opt_a: 1, opt_b: 'fancy'" } - it 'passes options to plugin' do + it "passes options to plugin" do options = { watchers: [], callbacks: [], opt_a: 1, - opt_b: 'fancy', + opt_b: "fancy", group: :default } - expect(plugins).to receive(:add).with('test', options) + expect(plugins).to receive(:add).with("test", options) evaluator.call(contents) end end - context 'with groups' do - let(:contents) { 'group :foo do; group :bar do; guard :test; end; end' } + context "with groups" do + let(:contents) { "group :foo do; group :bar do; guard :test; end; end" } - it 'adds plugin with group info' do + 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) @@ -303,12 +303,12 @@ def method_for(klass, meth) end end - context 'with plugins in custom and default groups' do + context "with plugins in custom and default groups" do let(:contents) do - 'group :foo do; group :bar do; guard :test; end; end; guard :rspec' + "group :foo do; group :bar do; guard :test; end; end; guard :rspec" end - it 'assigns plugins to correct groups' do + it "assigns plugins to correct groups" do expect(groups).to receive(:add).with(:foo, {}) expect(groups).to receive(:add).with(:bar, {}) @@ -323,15 +323,15 @@ def method_for(klass, meth) end end - describe '#watch' do + describe "#watch" do # TODO: this is testing too much - context 'with watchers' do + context "with watchers" do let(:watcher_a) do - instance_double('Guard::Watcher', pattern: 'a', action: proc { 'b' }) + instance_double("Guard::Watcher", pattern: "a", action: proc { "b" }) end let(:watcher_c) do - instance_double('Guard::Watcher', pattern: 'c', action: nil) + instance_double("Guard::Watcher", pattern: "c", action: nil) end let(:contents) do @@ -342,7 +342,7 @@ def method_for(klass, meth) end' end - it 'should receive watchers when specified' do + it "should receive watchers when specified" do call_params = { watchers: [anything, anything], callbacks: [], @@ -352,29 +352,29 @@ def method_for(klass, meth) 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 - expect(options[:watchers][1].pattern).to eq 'c' + expect(options[:watchers][0].pattern).to eq "a" + expect(options[:watchers][0].action.call).to eq proc { "b" }.call + expect(options[:watchers][1].pattern).to eq "c" expect(options[:watchers][1].action).to be_nil end - allow(Guard::Watcher).to receive(:new).with('a', anything) + allow(Guard::Watcher).to receive(:new).with("a", anything) .and_return(watcher_a) - allow(Guard::Watcher).to receive(:new).with('c', nil) + 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\')' } + context "with watch in main scope" do + let(:contents) { "watch('a')" } let(:watcher) do - instance_double('Guard::Watcher', pattern: 'a', action: nil) + instance_double("Guard::Watcher", pattern: "a", action: nil) end - it 'should create an implicit no-op guard when outside a guard block' do + it "should create an implicit no-op guard when outside a guard block" do plugin_options = { watchers: [anything], callbacks: [], @@ -384,11 +384,11 @@ def method_for(klass, meth) 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].pattern).to eq "a" expect(options[:watchers][0].action).to be_nil end - allow(Guard::Watcher).to receive(:new).with('a', nil) + allow(Guard::Watcher).to receive(:new).with("a", nil) .and_return(watcher) evaluator.call(contents) @@ -396,8 +396,8 @@ def method_for(klass, meth) end end - describe '#callback' do - context 'with ' do + describe "#callback" do + context "with " do let(:contents) do ' guard :rspec do @@ -410,7 +410,7 @@ def method_for(klass, meth) end' end - it 'creates callbacks for the guard' do + it "creates callbacks for the guard" do class MyCustomCallback def self.call(_plugin, _event, _args) # do nothing @@ -433,11 +433,11 @@ def self.call(_plugin, _event, _args) expect(callback0[:events]).to eq :start_end - plugin = instance_double('Guard::Plugin', title: 'RSpec') - result = callback0[:listener].call(plugin, :start_end, 'foo') + plugin = instance_double("Guard::Plugin", title: "RSpec") + result = callback0[:listener].call(plugin, :start_end, "foo") - expect(result).to eq 'RSpec executed \'start_end\' hook'\ - ' with foo!' + expect(result).to eq "RSpec executed 'start_end' hook"\ + " with foo!" callback1 = opt[:callbacks][1] expect(callback1[:events]).to eq %i[start_begin run_all_begin] @@ -448,7 +448,7 @@ def self.call(_plugin, _event, _args) end end - context 'without a guard block' do + context "without a guard block" do let(:contents) do ' callback(:start_end) do |plugin, event, args| @@ -458,20 +458,20 @@ def self.call(_plugin, _event, _args) callback(MyCustomCallback, [:start_begin, :run_all_begin])' end - it 'fails' do + it "fails" do expect { evaluator.call(contents) }.to raise_error(/guard block/i) end end end - describe '#logger' do + describe "#logger" do before do allow(Guard::UI).to receive(:options).and_return({}) allow(Guard::UI).to receive(:options=) end - describe 'options' do - let(:contents) { '' } + describe "options" do + let(:contents) { "" } before do evaluator.call(contents) @@ -479,60 +479,60 @@ def self.call(_plugin, _event, _args) subject { Guard::UI } - context 'with logger level :error' do - let(:contents) { 'logger level: :error' } + context "with logger level :error" do + let(:contents) { "logger level: :error" } it { is_expected.to have_received(:options=).with(level: :error) } 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\'' } + context "with logger template" do + let(:contents) { "logger template: ':message - :severity'" } it do is_expected.to have_received(:options=) - .with(template: ':message - :severity') + .with(template: ":message - :severity") end end - context 'with a logger time format' do - let(:contents) { 'logger time_format: \'%Y\'' } + context "with a logger time format" do + let(:contents) { "logger time_format: '%Y'" } it do - is_expected.to have_received(:options=).with(time_format: '%Y') + is_expected.to have_received(:options=).with(time_format: "%Y") end end - context 'with a logger only filter from a symbol' do - let(:contents) { 'logger only: :cucumber' } + context "with a logger only filter from a symbol" do + let(:contents) { "logger only: :cucumber" } it { is_expected.to have_received(:options=).with(only: /cucumber/i) } end - context 'with logger only filter from a string' do - let(:contents) { 'logger only: \'jasmine\'' } + context "with logger only filter from a string" do + 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\']' } + context "with logger only filter from an array of symbols and string" do + let(:contents) { "logger only: [:rspec, 'cucumber']" } it do is_expected.to have_received(:options=).with(only: /rspec|cucumber/i) end end - context 'with logger except filter from a symbol' do - let(:contents) { 'logger except: :jasmine' } + context "with logger except filter from a symbol" do + let(:contents) { "logger except: :jasmine" } it { is_expected.to have_received(:options=).with(except: /jasmine/i) } end - context 'with logger except filter from a string' do - let(:contents) { 'logger except: \'jasmine\'' } + context "with logger except filter from a string" do + 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]' } + context "with logger except filter from array of symbols and string" do + let(:contents) { "logger except: [:rspec, 'cucumber', :jasmine]" } it do is_expected.to have_received(:options=) .with(except: /rspec|cucumber|jasmine/i) @@ -540,35 +540,35 @@ def self.call(_plugin, _event, _args) end end - context 'with invalid options' do - context 'for the log level' do - let(:contents) { 'logger level: :baz' } + context "with invalid options" do + context "for the log level" do + let(:contents) { "logger level: :baz" } - it 'shows a warning' do + it "shows a warning" do expect(Guard::UI).to receive(:warning) - .with 'Invalid log level `baz` ignored.'\ - ' Please use either :debug, :info, :warn or :error.' + .with "Invalid log level `baz` ignored."\ + " Please use either :debug, :info, :warn or :error." evaluator.call(contents) end - it 'does not set the invalid value' do + it "does not set the invalid value" do expect(Guard::UI).to receive(:options=).with({}) evaluator.call(contents) end end - context 'when having both the :only and :except options' do - let(:contents) { 'logger only: :jasmine, except: :rspec' } + context "when having both the :only and :except options" do + let(:contents) { "logger only: :jasmine, except: :rspec" } - it 'shows a warning' do + it "shows a warning" do expect(Guard::UI).to receive(:warning) - .with 'You cannot specify the logger options'\ - ' :only and :except at the same time.' + .with "You cannot specify the logger options"\ + " :only and :except at the same time." evaluator.call(contents) end - it 'removes the options' do + it "removes the options" do expect(Guard::UI).to receive(:options=).with({}) evaluator.call(contents) end @@ -576,9 +576,9 @@ def self.call(_plugin, _event, _args) end end - describe '#scope' do - context 'with any parameters' do - let(:contents) { 'scope plugins: [:foo, :bar]' } + describe "#scope" do + context "with any parameters" do + let(:contents) { "scope plugins: [:foo, :bar]" } it "sets the guardfile's default scope" do expect(session).to receive(:guardfile_scope).with(plugins: %i[foo bar]) @@ -587,37 +587,37 @@ def self.call(_plugin, _event, _args) end end - describe '#directories' do - context 'with valid directories' do - let(:contents) { 'directories %w(foo bar)' } + describe "#directories" do + context "with valid directories" do + let(:contents) { "directories %w(foo bar)" } before do - allow(Dir).to receive(:exist?).with('foo').and_return(true) - allow(Dir).to receive(:exist?).with('bar').and_return(true) + allow(Dir).to receive(:exist?).with("foo").and_return(true) + allow(Dir).to receive(:exist?).with("bar").and_return(true) end - it 'sets the watchdirs to given values' do + it "sets the watchdirs to given values" do expect(session).to receive(:watchdirs=).with(%w[foo bar]) evaluator.call(contents) end end - context 'with no parameters' do - let(:contents) { 'directories []' } + context "with no parameters" do + let(:contents) { "directories []" } - it 'sets the watchdirs to empty' do + it "sets the watchdirs to empty" do expect(session).to receive(:watchdirs=).with([]) evaluator.call(contents) end end - context 'with non-existing directory' do + context "with non-existing directory" do let(:contents) { "directories ['foo']" } before do - allow(Dir).to receive(:exist?).with('foo').and_return(false) + allow(Dir).to receive(:exist?).with("foo").and_return(false) end - it 'fails with an error' do + it "fails with an error" do expect(session).to_not receive(:watchdirs=) expect do evaluator.call(contents) @@ -626,18 +626,18 @@ def self.call(_plugin, _event, _args) end end - describe '#clear' do - context 'with clear :off' do - let(:contents) { 'clearing :off' } - it 'disables clearing the screen after every task' do + describe "#clear" do + context "with clear :off" do + let(:contents) { "clearing :off" } + it "disables clearing the screen after every task" do expect(session).to receive(:clearing).with(false) evaluator.call(contents) end end - context 'with clear :on' do - let(:contents) { 'clearing :on' } - it 'enabled clearing the screen after every task' do + context "with clear :on" do + let(:contents) { "clearing :on" } + it "enabled clearing the screen after every task" do expect(session).to receive(:clearing).with(true) evaluator.call(contents) end diff --git a/spec/lib/guard/group_spec.rb b/spec/lib/guard/group_spec.rb index 1f0713d5d..e779baf99 100644 --- a/spec/lib/guard/group_spec.rb +++ b/spec/lib/guard/group_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'guard/group' +require "guard/group" RSpec.describe Guard::Group do subject { described_class.new(name, options) } @@ -8,29 +8,29 @@ let(:name) { :foo } let(:options) { {} } - describe '#name' do + describe "#name" do specify { expect(subject.name).to eq :foo } - context 'when initialized from a string' do - let(:name) { 'foo' } + context "when initialized from a string" do + let(:name) { "foo" } specify { expect(subject.name).to eq :foo } end end - describe '#options' do - context 'when provided' do + describe "#options" do + context "when provided" do let(:options) { { halt_on_fail: true } } specify { expect(subject.options).to eq options } end end - describe '#title' do - specify { expect(subject.title).to eq 'Foo' } + describe "#title" do + specify { expect(subject.title).to eq "Foo" } end - describe '#to_s' do + describe "#to_s" do specify do - expect(subject.to_s).to eq '#' + expect(subject.to_s).to eq "#" end end end diff --git a/spec/lib/guard/guardfile/evaluator_spec.rb b/spec/lib/guard/guardfile/evaluator_spec.rb index 77e2b878a..e18b653c9 100644 --- a/spec/lib/guard/guardfile/evaluator_spec.rb +++ b/spec/lib/guard/guardfile/evaluator_spec.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -require 'guard/guardfile/evaluator' +require "guard/guardfile/evaluator" # TODO: shouldn't be necessary -require 'guard' +require "guard" RSpec.describe Guard::Guardfile::Evaluator do let(:options) { {} } subject { described_class.new(options) } - let!(:local_guardfile) { (Pathname.pwd + 'Guardfile').to_s } - let!(:home_guardfile) { (Pathname('~').expand_path + '.Guardfile').to_s } - let!(:home_config) { (Pathname('~').expand_path + '.guard.rb').to_s } + let!(:local_guardfile) { (Pathname.pwd + "Guardfile").to_s } + let!(:home_guardfile) { (Pathname("~").expand_path + ".Guardfile").to_s } + let!(:home_config) { (Pathname("~").expand_path + ".guard.rb").to_s } - let(:valid_guardfile_string) { 'group :foo; do guard :bar; end; end; ' } + let(:valid_guardfile_string) { "group :foo; do guard :bar; end; end; " } - let(:dsl) { instance_double('Guard::Dsl') } + let(:dsl) { instance_double("Guard::Dsl") } let(:rel_guardfile) do - Pathname('../relative_path_to_Guardfile').expand_path.to_s + Pathname("../relative_path_to_Guardfile").expand_path.to_s end before do @@ -27,24 +27,24 @@ allow(dsl).to receive(:instance_eval) end - describe '.evaluate' do - describe 'error cases' do - context 'with an invalid Guardfile' do - let(:options) { { contents: 'guard :foo Bad Guardfile' } } + describe ".evaluate" do + describe "error cases" do + context "with an invalid Guardfile" do + let(:options) { { contents: "guard :foo Bad Guardfile" } } - it 'displays an error message and raises original exception' do + 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:') + "Invalid Guardfile, original error is:") expect { subject.evaluate }.to raise_error(Guard::Dsl::Error) end end - context 'with no Guardfile at all' do - it 'displays an error message and exits' do + context "with no Guardfile at all" do + it "displays an error message and exits" do stub_guardfile stub_user_guardfile stub_user_project_guardfile @@ -54,47 +54,47 @@ end end - context 'with a problem reading a Guardfile' do - let(:path) { File.expand_path('Guardfile') } + context "with a problem reading a Guardfile" do + let(:path) { File.expand_path("Guardfile") } before do stub_user_project_guardfile - stub_guardfile(' ') do - fail Errno::EACCES.new('permission error') + stub_guardfile(" ") do + fail Errno::EACCES.new("permission error") end end - it 'displays an error message and exits' do + it "displays an error message and exits" do expect(Guard::UI).to receive(:error).with(/^Error reading file/) expect { subject.evaluate }.to raise_error(SystemExit) end end - context 'with empty Guardfile content' do - let(:options) { { contents: '' } } + context "with empty Guardfile content" do + let(:options) { { contents: "" } } - it 'displays an error message about no plugins' do + it "displays an error message about no plugins" do stub_user_guard_rb - stub_guardfile(' ') - allow(dsl).to receive(:evaluate).with('', '', 1) + stub_guardfile(" ") + allow(dsl).to receive(:evaluate).with("", "", 1) expect { subject.evaluate } .to raise_error(Guard::Guardfile::Evaluator::NoPluginsError) end end - context 'when provided :contents is nil' do + context "when provided :contents is nil" do before do # Anything - stub_guardfile('guard :foo') + stub_guardfile("guard :foo") stub_user_guard_rb stub_user_project_guardfile stub_user_guardfile end - it 'does not raise error and skip it' do - allow(dsl).to receive(:evaluate).with('guard :foo', anything, 1) + it "does not raise error and skip it" do + allow(dsl).to receive(:evaluate).with("guard :foo", anything, 1) expect(Guard::UI).to_not receive(:error) expect do @@ -103,55 +103,55 @@ end end - context 'with a non-existing Guardfile given' do - let(:non_existing_path) { '/non/existing/path/to/Guardfile' } + context "with a non-existing Guardfile given" do + let(:non_existing_path) { "/non/existing/path/to/Guardfile" } let(:options) { { guardfile: non_existing_path } } before do stub_file(non_existing_path) end - it 'raises error' do + it "raises error" do expect { subject.evaluate } .to raise_error(Guard::Guardfile::Evaluator::NoCustomGuardfile) end end end - describe 'selection of the Guardfile data contents' do - context 'with a valid :contents option' do + describe "selection of the Guardfile data contents" do + context "with a valid :contents option" do before do stub_user_guard_rb allow(dsl).to receive(:evaluate) end - context 'with inline content and other Guardfiles available' do - let(:inline_code) { 'guard :foo' } + context "with inline content and other Guardfiles available" do + let(:inline_code) { "guard :foo" } let(:options) do { contents: inline_code, - guardfile: '/abc/Guardfile' + guardfile: "/abc/Guardfile" } end before do - stub_file('/abc/Guardfile', 'guard :bar') - stub_guardfile('guard :baz') - stub_user_guardfile('guard :buz') + stub_file("/abc/Guardfile", "guard :bar") + stub_guardfile("guard :baz") + stub_user_guardfile("guard :buz") end - it 'gives ultimate precedence to inline content' do - expect(dsl).to receive(:evaluate).with(inline_code, '', 1) + it "gives ultimate precedence to inline content" do + expect(dsl).to receive(:evaluate).with(inline_code, "", 1) subject.evaluate end end end - context 'with the :guardfile option' do - let(:options) { { guardfile: '../relative_path_to_Guardfile' } } + context "with the :guardfile option" do + let(:options) { { guardfile: "../relative_path_to_Guardfile" } } before do - stub_file(File.expand_path('../relative_path_to_Guardfile'), + stub_file(File.expand_path("../relative_path_to_Guardfile"), valid_guardfile_string) allow(dsl).to receive(:evaluate) .with(valid_guardfile_string, anything, 1) @@ -160,26 +160,26 @@ end end - describe '#inline?' do + describe "#inline?" do before do allow(dsl).to receive(:evaluate) - stub_guardfile('guard :bar') + stub_guardfile("guard :bar") stub_user_guard_rb subject.evaluate end - context 'when content is provided' do - let(:options) { { guardfile_contents: 'guard :foo' } } + context "when content is provided" do + let(:options) { { guardfile_contents: "guard :foo" } } it { is_expected.to be_inline } end - context 'when no content is provided' do + context "when no content is provided" do let(:options) { {} } it { is_expected.to_not be_inline } end end - describe '.guardfile_include?' do + describe ".guardfile_include?" do subject do evaluator = described_class.new(options) evaluator.evaluate @@ -195,27 +195,27 @@ stub_user_guard_rb end - context 'when plugin is present' do + context "when plugin is present" do let(:options) { { contents: 'guard "test" {watch("c")}' } } - it 'returns true' do + it "returns true" do allow(dsl_reader) - .to receive(:evaluate).with('guard "test" {watch("c")}', '', 1) + .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') + allow(dsl_reader).to receive(:plugin_names).and_return(["test"]) + expect(subject).to be_guardfile_include("test") end end - context 'when plugin is not present' do + context "when plugin is not present" do let(:options) { { contents: 'guard "other" {watch("c")}' } } - it 'returns false' do + it "returns false" do allow(dsl_reader) - .to receive(:evaluate).with('guard "test" {watch("c")}', '', 1) + .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') + allow(dsl_reader).to receive(:plugin_names).and_return(["other"]) + expect(subject).to_not be_guardfile_include("test") end end end diff --git a/spec/lib/guard/guardfile/generator_spec.rb b/spec/lib/guard/guardfile/generator_spec.rb index 7eff812b4..0e23ee830 100644 --- a/spec/lib/guard/guardfile/generator_spec.rb +++ b/spec/lib/guard/guardfile/generator_spec.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true -require 'guard/guardfile/generator' +require "guard/guardfile/generator" RSpec.describe Guard::Guardfile::Generator do - let(:plugin_util) { instance_double('Guard::PluginUtil') } + let(:plugin_util) { instance_double("Guard::PluginUtil") } let(:guardfile_generator) { described_class.new } - it 'has a valid Guardfile template' do + it "has a valid Guardfile template" do allow(File).to receive(:exist?) .with(described_class::GUARDFILE_TEMPLATE).and_call_original expect(File.exist?(described_class::GUARDFILE_TEMPLATE)).to be_truthy end - describe '#create_guardfile' do - context 'with an existing Guardfile' do + describe "#create_guardfile" do + context "with an existing Guardfile" do before do allow_any_instance_of(Pathname).to receive(:exist?).and_return(true) end - it 'does not copy the Guardfile template or notify the user' do + it "does not copy the Guardfile template or notify the user" do expect(::Guard::UI).to_not receive(:info) expect(FileUtils).to_not receive(:cp) begin @@ -28,7 +28,7 @@ end end - it 'does not display information' do + it "does not display information" do expect(::Guard::UI).to_not receive(:info) begin subject.create_guardfile @@ -36,7 +36,7 @@ end end - it 'displays an error message' do + it "displays an error message" do expect(::Guard::UI).to receive(:error) .with(%r{Guardfile already exists at .*/Guardfile}) begin @@ -45,24 +45,24 @@ end end - it 'aborts' do + it "aborts" do expect { subject.create_guardfile }.to raise_error(SystemExit) end end - context 'without an existing Guardfile' do + context "without an existing Guardfile" do before do allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) allow(FileUtils).to receive(:cp) end - it 'does not display any kind of error or abort' do + it "does not display any kind of error or abort" do expect(::Guard::UI).to_not receive(:error) expect(described_class).to_not receive(:abort) described_class.new.create_guardfile end - it 'copies the Guardfile template and notifies the user' do + it "copies the Guardfile template and notifies the user" do expect(::Guard::UI).to receive(:info) expect(FileUtils).to receive(:cp) @@ -71,40 +71,40 @@ end end - describe '#initialize_template' do - context 'with an installed Guard implementation' do + describe "#initialize_template" do + context "with an installed Guard implementation" do before do expect(Guard::PluginUtil).to receive(:new) { plugin_util } expect(plugin_util).to receive(:plugin_class) do - double('Guard::Foo').as_null_object + double("Guard::Foo").as_null_object end end - it 'initializes the Guard' do + it "initializes the Guard" do expect(plugin_util).to receive(:add_to_guardfile) - described_class.new.initialize_template('foo') + described_class.new.initialize_template("foo") end end - context 'with a user defined template' do - let(:template) { File.join(described_class::HOME_TEMPLATES, '/bar') } + context "with a user defined template" do + let(:template) { File.join(described_class::HOME_TEMPLATES, "/bar") } - it 'copies the Guardfile template and initializes the Guard' do + it "copies the Guardfile template and initializes the Guard" do expect(IO).to receive(:read) - .with(template).and_return 'Template content' + .with(template).and_return "Template content" expected = "\nTemplate content\n" expect(IO).to receive(:binwrite) - .with('Guardfile', expected, open_args: ['a']) + .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') + allow(Guard::PluginUtil).to receive(:new).with("bar") .and_return(plugin_util) - described_class.new.initialize_template('bar') + described_class.new.initialize_template("bar") end end @@ -112,27 +112,27 @@ before do expect(::Guard::PluginUtil).to receive(:new) { plugin_util } allow(plugin_util).to receive(:plugin_class) { nil } - path = File.expand_path('~/.guard/templates/foo') + path = File.expand_path("~/.guard/templates/foo") expect(IO).to receive(:read).with(path) do fail Errno::ENOENT end end - it 'notifies the user about the problem' do - expect { described_class.new.initialize_template('foo') } + it "notifies the user about the problem" do + expect { described_class.new.initialize_template("foo") } .to raise_error(Guard::Guardfile::Generator::Error) end end end - describe '#initialize_all_templates' do + describe "#initialize_all_templates" do let(:plugins) { %w[rspec spork phpunit] } before do expect(::Guard::PluginUtil).to receive(:plugin_names) { plugins } end - it 'calls Guard.initialize_template on all installed plugins' do + it "calls Guard.initialize_template on all installed plugins" do plugins.each do |g| expect(subject).to receive(:initialize_template).with(g) end diff --git a/spec/lib/guard/interactor_spec.rb b/spec/lib/guard/interactor_spec.rb index 17ab806e2..b6adc5458 100644 --- a/spec/lib/guard/interactor_spec.rb +++ b/spec/lib/guard/interactor_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'guard/interactor' +require "guard/interactor" # TODO: this shouldn't be necessary -require 'guard/jobs/pry_wrapper' -require 'guard/jobs/sleep' +require "guard/jobs/pry_wrapper" +require "guard/jobs/sleep" RSpec.describe Guard::Interactor do - let!(:pry_interactor) { instance_double('Guard::Jobs::PryWrapper') } - let!(:sleep_interactor) { instance_double('Guard::Jobs::Sleep') } - let(:pry_class) { class_double('Guard::Jobs::PryWrapper') } - let(:sleep_class) { class_double('Guard::Jobs::Sleep') } + let!(:pry_interactor) { instance_double("Guard::Jobs::PryWrapper") } + let!(:sleep_interactor) { instance_double("Guard::Jobs::Sleep") } + let(:pry_class) { class_double("Guard::Jobs::PryWrapper") } + let(:sleep_class) { class_double("Guard::Jobs::Sleep") } before do - stub_const('Guard::Jobs::PryWrapper', pry_class) - stub_const('Guard::Jobs::Sleep', sleep_class) + stub_const("Guard::Jobs::PryWrapper", pry_class) + stub_const("Guard::Jobs::Sleep", sleep_class) allow(Guard::Jobs::PryWrapper).to receive(:new).and_return(pry_interactor) allow(Guard::Jobs::Sleep).to receive(:new).and_return(sleep_interactor) @@ -25,87 +25,87 @@ after { described_class.enabled = @interactor_enabled } - describe '.enabled & .enabled=' do - it 'returns true by default' do + describe ".enabled & .enabled=" do + it "returns true by default" do expect(described_class).to be_enabled end - context 'interactor not enabled' do + context "interactor not enabled" do before { described_class.enabled = false } - it 'returns false' do + it "returns false" do expect(described_class).to_not be_enabled end end end - describe '.options & .options=' do + describe ".options & .options=" do before { described_class.options = nil } - it 'returns {} by default' do + it "returns {} by default" do expect(described_class.options).to eq({}) end - context 'options set to { foo: :bar }' do + context "options set to { foo: :bar }" do before { described_class.options = { foo: :bar } } - it 'returns { foo: :bar }' do + it "returns { foo: :bar }" do expect(described_class.options).to eq(foo: :bar) end end end - context 'when enabled' do + context "when enabled" do before { described_class.enabled = true } - describe '#foreground' do - it 'starts Pry' do + describe "#foreground" do + it "starts Pry" do expect(pry_interactor).to receive(:foreground) subject.foreground end end - describe '#background' do - it 'hides Pry' do + describe "#background" do + it "hides Pry" do expect(pry_interactor).to receive(:background) subject.background end end - describe '#handle_interrupt' do - it 'interrupts Pry' do + describe "#handle_interrupt" do + it "interrupts Pry" do expect(pry_interactor).to receive(:handle_interrupt) subject.handle_interrupt end end end - context 'when disabled' do + context "when disabled" do before { described_class.enabled = false } - describe '#foreground' do - it 'sleeps' do + describe "#foreground" do + it "sleeps" do expect(sleep_interactor).to receive(:foreground) subject.foreground end end - describe '#background' do - it 'wakes up from sleep' do + describe "#background" do + it "wakes up from sleep" do expect(sleep_interactor).to receive(:background) subject.background end end - describe '#handle_interrupt' do - it 'interrupts sleep' do + describe "#handle_interrupt" do + it "interrupts sleep" do expect(sleep_interactor).to receive(:handle_interrupt) subject.handle_interrupt end end end - describe 'job selection' do + describe "job selection" do subject do Guard::Interactor.new(no_interactions) Guard::Interactor @@ -115,12 +115,12 @@ Guard::Interactor.enabled = dsl_enabled end - context 'when enabled from the DSL' do + context "when enabled from the DSL" do let(:dsl_enabled) { true } - context 'when enabled from the commandline' do + context "when enabled from the commandline" do let(:no_interactions) { false } - it 'uses only pry' do + it "uses only pry" do expect(pry_class).to receive(:new) expect(sleep_class).to_not receive(:new) subject @@ -128,9 +128,9 @@ it { is_expected.to be_enabled } end - context 'when disabled from the commandline' do + context "when disabled from the commandline" do let(:no_interactions) { true } - it 'uses only sleeper' do + it "uses only sleeper" do expect(pry_class).to_not receive(:new) expect(sleep_class).to receive(:new) subject @@ -141,12 +141,12 @@ end end - context 'when disabled from the DSL' do + context "when disabled from the DSL" do let(:dsl_enabled) { false } - context 'when enabled from the commandline' do + context "when enabled from the commandline" do let(:no_interactions) { false } - it 'uses only sleeper' do + it "uses only sleeper" do expect(pry_class).to_not receive(:new) expect(sleep_class).to receive(:new) subject @@ -154,9 +154,9 @@ it { is_expected.to_not be_enabled } end - context 'when disabled from the commandline' do + context "when disabled from the commandline" do let(:no_interactions) { true } - it 'uses only sleeper' do + it "uses only sleeper" do expect(pry_class).to_not receive(:new) expect(sleep_class).to receive(:new) subject diff --git a/spec/lib/guard/internals/debugging_spec.rb b/spec/lib/guard/internals/debugging_spec.rb index 71210b5b5..76e9be2d4 100644 --- a/spec/lib/guard/internals/debugging_spec.rb +++ b/spec/lib/guard/internals/debugging_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'guard/internals/debugging' +require "guard/internals/debugging" RSpec.describe Guard::Internals::Debugging do let(:null) { IO::NULL } @@ -8,8 +8,8 @@ let(:tracing) { class_spy(::Guard::Internals::Tracing) } before do - stub_const('::Guard::Internals::Tracing', tracing) - stub_const('::Guard::UI', ui) + stub_const("::Guard::Internals::Tracing", tracing) + stub_const("::Guard::UI", ui) allow(ui).to receive(:debug) allow(ui).to receive(:level=) allow(Thread).to receive(:abort_on_exception=) @@ -19,93 +19,93 @@ described_class.send(:_reset) end - describe '#start' do - it 'traces Kernel.system' do + describe "#start" do + it "traces Kernel.system" do expect(tracing).to receive(:trace).with(Kernel, :system) do |*_, &block| - expect(ui).to receive(:debug).with('Command execution: foo') - block.call 'foo' + expect(ui).to receive(:debug).with("Command execution: foo") + block.call "foo" end described_class.start end - it 'traces Kernel.`' do + it "traces Kernel.`" do expect(tracing).to receive(:trace).with(Kernel, :`) do |*_, &block| - expect(ui).to receive(:debug).with('Command execution: foo') - block.call('foo') + expect(ui).to receive(:debug).with("Command execution: foo") + block.call("foo") end described_class.start end - it 'traces Open3.popen3' do + it "traces Open3.popen3" do expect(tracing).to receive(:trace).with(Open3, :popen3) do |*_, &block| - expect(ui).to receive(:debug).with('Command execution: foo') - block.call('foo') + expect(ui).to receive(:debug).with("Command execution: foo") + block.call("foo") end described_class.start end - it 'traces Kernel.spawn' do + it "traces Kernel.spawn" do expect(tracing).to receive(:trace).with(Kernel, :spawn) do |*_, &block| - expect(ui).to receive(:debug).with('Command execution: foo') - block.call('foo') + expect(ui).to receive(:debug).with("Command execution: foo") + block.call("foo") end described_class.start end - context 'when not started' do + context "when not started" do before { described_class.start } - it 'sets logger to debug' do + it "sets logger to debug" do expect(ui).to have_received(:level=).with(Logger::DEBUG) end - it 'makes threads abort on exceptions' do + it "makes threads abort on exceptions" do expect(Thread).to have_received(:abort_on_exception=).with(true) end end - context 'when already started' do + context "when already started" do before do allow(tracing).to receive(:trace) described_class.start end - it 'does not set log level' do + it "does not set log level" do expect(ui).to_not receive(:level=) described_class.start end end end - describe '#stop' do - context 'when already started' do + describe "#stop" do + context "when already started" do before do described_class.start described_class.stop end - it 'sets logger level to info' do + it "sets logger level to info" do expect(ui).to have_received(:level=).with(Logger::INFO) end - it 'untraces Kernel.system' do + it "untraces Kernel.system" do expect(tracing).to have_received(:untrace).with(Kernel, :system) end - it 'untraces Kernel.`' do + it "untraces Kernel.`" do expect(tracing).to have_received(:untrace).with(Kernel, :`) end - it 'untraces Open3.popen3' do + it "untraces Open3.popen3" do expect(tracing).to have_received(:untrace).with(Kernel, :popen3) end end - context 'when not started' do - it 'does not set logger level' do + context "when not started" do + it "does not set logger level" do described_class.stop expect(ui).to_not have_received(:level=) end diff --git a/spec/lib/guard/internals/groups_spec.rb b/spec/lib/guard/internals/groups_spec.rb index c059bdeac..f1c11e2f5 100644 --- a/spec/lib/guard/internals/groups_spec.rb +++ b/spec/lib/guard/internals/groups_spec.rb @@ -1,26 +1,26 @@ # frozen_string_literal: true -require 'guard/internals/groups' +require "guard/internals/groups" RSpec.describe Guard::Internals::Groups do - describe '#all' do - let(:common) { instance_double('Guard::Group', name: :common) } - let(:default) { instance_double('Guard::Group', name: :default) } + describe "#all" do + let(:common) { instance_double("Guard::Group", name: :common) } + let(:default) { instance_double("Guard::Group", name: :default) } before do allow(Guard::Group).to receive(:new).with(:common).and_return(common) allow(Guard::Group).to receive(:new).with(:default).and_return(default) end - context 'with only default groups' do - it 'initializes the groups' do + context "with only default groups" do + it "initializes the groups" do expect(subject.all.map(&:name)).to eq %i[common default] end end - context 'with existing groups' do - let(:frontend) { instance_double('Guard::Group', name: :frontend) } - let(:backend) { instance_double('Guard::Group', name: :backend) } + context "with existing groups" do + let(:frontend) { instance_double("Guard::Group", name: :frontend) } + let(:backend) { instance_double("Guard::Group", name: :backend) } before do allow(Guard::Group).to receive(:new).with(:frontend, {}) @@ -33,39 +33,39 @@ subject.add(:backend) end - context 'with no arguments' do + context "with no arguments" do let(:args) { [] } - it 'returns all groups' do + it "returns all groups" do expect(subject.all(*args)).to eq [common, default, frontend, backend] end end - context 'with a string argument' do - it 'returns an array of groups if plugins are found' do - expect(subject.all('backend')).to eq [backend] + context "with a string argument" do + it "returns an array of groups if plugins are found" do + expect(subject.all("backend")).to eq [backend] end end - context 'with a symbol argument matching a group' do - it 'returns an array of groups if plugins are found' do + context "with a symbol argument matching a group" do + it "returns an array of groups if plugins are found" do expect(subject.all(:backend)).to eq [backend] end end - context 'with a symbol argument not matching a group' do - it 'returns an empty array when no group is found' do + context "with a symbol argument not matching a group" do + it "returns an empty array when no group is found" do expect(subject.all(:foo)).to be_empty end end - context 'with a regexp argument matching a group' do - it 'returns an array of groups' do + context "with a regexp argument matching a group" do + it "returns an array of groups" do expect(subject.all(/^back/)).to eq [backend] end end - context 'with a regexp argument not matching a group' do - it 'returns an empty array when no group is found' do + context "with a regexp argument not matching a group" do + it "returns an empty array when no group is found" do expect(subject.all(/back$/)).to be_empty end end @@ -73,47 +73,47 @@ end # TOOD: test adding with options - describe '#add' do - let(:common) { instance_double('Guard::Group', name: :common) } - let(:default) { instance_double('Guard::Group', name: :default) } + describe "#add" do + let(:common) { instance_double("Guard::Group", name: :common) } + let(:default) { instance_double("Guard::Group", name: :default) } before do allow(Guard::Group).to receive(:new).with(:common).and_return(common) allow(Guard::Group).to receive(:new).with(:default).and_return(default) end - context 'with existing groups' do - let(:frontend) { instance_double('Guard::Group', name: :frontend) } - let(:backend) { instance_double('Guard::Group', name: :backend) } + context "with existing groups" do + let(:frontend) { instance_double("Guard::Group", name: :frontend) } + let(:backend) { instance_double("Guard::Group", name: :backend) } before do - allow(Guard::Group).to receive(:new).with('frontend', {}) + allow(Guard::Group).to receive(:new).with("frontend", {}) .and_return(frontend) - subject.add('frontend') + subject.add("frontend") end - it 'add the given group' do - subject.add('frontend') + it "add the given group" do + subject.add("frontend") expect(subject.all).to match_array([common, default, frontend]) end - it 'add the given group with options' do - subject.add('frontend', foo: :bar) + it "add the given group with options" do + subject.add("frontend", foo: :bar) expect(subject.all).to match_array([common, default, frontend]) end # TODO: what if group is added multiple times with different options? - context 'with an existing group' do - before { subject.add('frontend') } + context "with an existing group" do + before { subject.add("frontend") } - it 'does not add duplicate groups when name is a string' do - subject.add('frontend') + it "does not add duplicate groups when name is a string" do + subject.add("frontend") expect(subject.all).to match_array([common, default, frontend]) end - it 'does not add duplicate groups when name is a symbol' do + it "does not add duplicate groups when name is a symbol" do subject.add(:frontend) expect(subject.all).to match_array([common, default, frontend]) end diff --git a/spec/lib/guard/internals/plugins_spec.rb b/spec/lib/guard/internals/plugins_spec.rb index a11b17230..27eaaee34 100644 --- a/spec/lib/guard/internals/plugins_spec.rb +++ b/spec/lib/guard/internals/plugins_spec.rb @@ -1,55 +1,55 @@ # frozen_string_literal: true -require 'guard/internals/plugins' +require "guard/internals/plugins" RSpec.describe Guard::Internals::Plugins do def stub_plugin(name, group) - instance_double('Guard::Plugin', name: name, group: group) + instance_double("Guard::Plugin", name: name, group: group) end # TODO: all this is crazy - let(:frontend) { instance_double('Guard::Group', name: :frontend) } - let(:backend) { instance_double('Guard::Group', name: :backend) } + let(:frontend) { instance_double("Guard::Group", name: :frontend) } + let(:backend) { instance_double("Guard::Group", name: :backend) } - let(:foo_bar_frontend) { stub_plugin('foobar', frontend) } - let(:foo_baz_frontend) { stub_plugin('foobaz', frontend) } - let(:foo_bar_backend) { stub_plugin('foobar', backend) } - let(:foo_baz_backend) { stub_plugin('foobaz', backend) } + let(:foo_bar_frontend) { stub_plugin("foobar", frontend) } + let(:foo_baz_frontend) { stub_plugin("foobaz", frontend) } + let(:foo_bar_backend) { stub_plugin("foobar", backend) } + let(:foo_baz_backend) { stub_plugin("foobaz", backend) } - let(:pu_foobar) { instance_double('Guard::PluginUtil') } - let(:pu_foobaz) { instance_double('Guard::PluginUtil') } + let(:pu_foobar) { instance_double("Guard::PluginUtil") } + let(:pu_foobaz) { instance_double("Guard::PluginUtil") } before do - allow(Guard::PluginUtil).to receive(:new).with('foobar') + allow(Guard::PluginUtil).to receive(:new).with("foobar") .and_return(pu_foobar) - allow(Guard::PluginUtil).to receive(:new).with('foobaz') + allow(Guard::PluginUtil).to receive(:new).with("foobaz") .and_return(pu_foobaz) - allow(pu_foobar).to receive(:initialize_plugin).with(group: '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') + 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') + 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') + allow(pu_foobaz).to receive(:initialize_plugin).with(group: "backend") .and_return(foo_baz_backend) end - describe '#all' do + describe "#all" do before do - subject.add('foobar', group: 'frontend') - subject.add('foobaz', group: 'frontend') - subject.add('foobar', group: 'backend') - subject.add('foobaz', group: 'backend') + subject.add("foobar", group: "frontend") + subject.add("foobaz", group: "frontend") + subject.add("foobar", group: "backend") + subject.add("foobaz", group: "backend") end - context 'with no arguments' do + context "with no arguments" do let(:args) { [] } - it 'returns all plugins' do + it "returns all plugins" do expect(subject.all(*args)).to eq [ foo_bar_frontend, foo_baz_frontend, @@ -59,75 +59,75 @@ def stub_plugin(name, group) end end - context 'find a plugin by as string' do - it 'returns an array of plugins if plugins are found' do - expect(subject.all('foo-bar')) + 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]) end end - context 'find a plugin by as symbol' do - it 'returns an array of plugins if plugins are found' do + 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]) end - it 'returns an empty array when no plugin is found' do - expect(subject.all('foo-foo')).to be_empty + it "returns an empty array when no plugin is found" do + expect(subject.all("foo-foo")).to be_empty end end - context 'find plugins matching a regexp' do - it 'returns an array of plugins if plugins are found' do + 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]) end - it 'returns an empty array when no plugin is found' do + it "returns an empty array when no plugin is found" do expect(subject.all(/foo$/)).to be_empty end end - 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')) + 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] end end - context 'find plugins by their group as a symbol' do - it 'returns an array of plugins if plugins are found' do + 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] end - it 'returns an empty array when no plugin is found' do + it "returns an empty array when no plugin is found" do expect(subject.all(group: :unknown)).to be_empty end end - 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')) + 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] end - it 'returns an empty array when no plugin is found' do + it "returns an empty array when no plugin is found" do expect(subject.all(group: :unknown, name: :'foo-baz')) .to be_empty end end end - describe '#remove' do + describe "#remove" do before do - subject.add('foobar', group: 'frontend') - subject.add('foobaz', group: 'frontend') - subject.add('foobar', group: 'backend') - subject.add('foobaz', group: 'backend') + subject.add("foobar", group: "frontend") + subject.add("foobaz", group: "frontend") + subject.add("foobar", group: "backend") + subject.add("foobaz", group: "backend") end - it 'removes given plugin' do + it "removes given plugin" do subject.remove(foo_bar_frontend) expect(subject.all).to match_array [ diff --git a/spec/lib/guard/internals/scope_spec.rb b/spec/lib/guard/internals/scope_spec.rb index a4387765d..23f02581a 100644 --- a/spec/lib/guard/internals/scope_spec.rb +++ b/spec/lib/guard/internals/scope_spec.rb @@ -1,31 +1,31 @@ # frozen_string_literal: true -require 'guard/internals/scope' +require "guard/internals/scope" RSpec.describe Guard::Internals::Scope do - let(:session) { instance_double('Guard::Internals::Session') } - let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double("Guard::Internals::Session") } + let(:state) { instance_double("Guard::Internals::State") } - let(:groups) { instance_double('Guard::Internals::Groups') } - let(:plugins) { instance_double('Guard::Internals::Plugins') } + let(:groups) { instance_double("Guard::Internals::Groups") } + let(:plugins) { instance_double("Guard::Internals::Plugins") } - let(:foo_plugin) { instance_double('Guard::Plugin', name: :foo) } - let(:bar_plugin) { instance_double('Guard::Plugin', name: :bar) } - let(:baz_plugin) { instance_double('Guard::Plugin', name: :baz) } + let(:foo_plugin) { instance_double("Guard::Plugin", name: :foo) } + let(:bar_plugin) { instance_double("Guard::Plugin", name: :bar) } + let(:baz_plugin) { instance_double("Guard::Plugin", name: :baz) } - let(:foo_group) { instance_double('Guard::Group', name: :foo) } - let(:bar_group) { instance_double('Guard::Group', name: :bar) } - let(:baz_group) { instance_double('Guard::Group', name: :baz) } + let(:foo_group) { instance_double("Guard::Group", name: :foo) } + let(:bar_group) { instance_double("Guard::Group", name: :bar) } + let(:baz_group) { instance_double("Guard::Group", name: :baz) } before do - allow(groups).to receive(:all).with('foo').and_return([foo_group]) - allow(groups).to receive(:all).with('bar').and_return([bar_group]) - allow(groups).to receive(:all).with('baz').and_return([baz_group]) + allow(groups).to receive(:all).with("foo").and_return([foo_group]) + allow(groups).to receive(:all).with("bar").and_return([bar_group]) + allow(groups).to receive(:all).with("baz").and_return([baz_group]) allow(groups).to receive(:all).with(:baz).and_return([baz_group]) - allow(plugins).to receive(:all).with('foo').and_return([foo_plugin]) - allow(plugins).to receive(:all).with('bar').and_return([bar_plugin]) - allow(plugins).to receive(:all).with('baz').and_return([baz_plugin]) + allow(plugins).to receive(:all).with("foo").and_return([foo_plugin]) + allow(plugins).to receive(:all).with("bar").and_return([bar_plugin]) + allow(plugins).to receive(:all).with("baz").and_return([baz_plugin]) allow(plugins).to receive(:all).with(:baz).and_return([baz_plugin]) allow(session).to receive(:cmdline_plugins).and_return([]) @@ -41,7 +41,7 @@ end # TODO: move to Session? - describe '#to_hash' do + describe "#to_hash" do %i[group plugin].each do |scope| describe scope.inspect do let(:hash) do @@ -49,38 +49,38 @@ end # NOTE: interactor returns objects - context 'when set from interactor' do + context "when set from interactor" do before do stub_obj = send("baz_#{scope}") subject.from_interactor(:"#{scope}s" => stub_obj) end - it 'uses interactor scope' do - expect(hash).to contain_exactly('baz') + it "uses interactor scope" do + expect(hash).to contain_exactly("baz") end end - context 'when not set in interactor' do - context 'when set in commandline' do + 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]) end - it 'uses commandline scope' do - expect(hash).to contain_exactly('baz') + it "uses commandline scope" do + expect(hash).to contain_exactly("baz") end end - context 'when not set in commandline' do - context 'when set in Guardfile' do + 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]) end - it 'uses guardfile scope' do - expect(hash).to contain_exactly('baz') + it "uses guardfile scope" do + expect(hash).to contain_exactly("baz") end end end @@ -89,7 +89,7 @@ end end - describe '#titles' do + describe "#titles" do pending end end diff --git a/spec/lib/guard/internals/session_spec.rb b/spec/lib/guard/internals/session_spec.rb index 454b7324d..bfcec9216 100644 --- a/spec/lib/guard/internals/session_spec.rb +++ b/spec/lib/guard/internals/session_spec.rb @@ -1,131 +1,131 @@ # frozen_string_literal: true -require 'guard/internals/session' +require "guard/internals/session" RSpec.describe Guard::Internals::Session do let(:options) { {} } subject { described_class.new(options) } - let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:groups) { instance_double('Guard::Internals::Plugins') } + let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:groups) { instance_double("Guard::Internals::Plugins") } before do allow(Guard::Internals::Plugins).to receive(:new).and_return(plugins) allow(Guard::Internals::Groups).to receive(:new).and_return(groups) end - describe '#initialize' do - describe '#listener_args' do + describe "#initialize" do + describe "#listener_args" do subject { described_class.new(options).listener_args } - context 'with a single watchdir' do - let(:options) { { watchdir: ['/usr'] } } - let(:dir) { Gem.win_platform? ? 'C:/usr' : '/usr' } + context "with a single watchdir" do + let(:options) { { watchdir: ["/usr"] } } + let(:dir) { Gem.win_platform? ? "C:/usr" : "/usr" } it { is_expected.to eq [:to, dir, {}] } end - context 'with multiple watchdirs' do - let(:options) { { watchdir: ['/usr', '/bin'] } } - let(:dir1) { Gem.win_platform? ? 'C:/usr' : '/usr' } - let(:dir2) { Gem.win_platform? ? 'C:/bin' : '/bin' } + context "with multiple watchdirs" do + let(:options) { { watchdir: ["/usr", "/bin"] } } + let(:dir1) { Gem.win_platform? ? "C:/usr" : "/usr" } + let(:dir2) { Gem.win_platform? ? "C:/bin" : "/bin" } it { is_expected.to eq [:to, dir1, dir2, {}] } end - context 'with force_polling option' do + context "with force_polling option" do let(:options) { { force_polling: true } } it { is_expected.to eq [:to, Dir.pwd, force_polling: true] } end - context 'with latency option' do + context "with latency option" do let(:options) { { latency: 1.5 } } it { is_expected.to eq [:to, Dir.pwd, latency: 1.5] } end end - context 'with the plugin option' do + context "with the plugin option" do let(:options) do { plugin: %w[cucumber jasmine], - guardfile_contents: 'guard :jasmine do; end; '\ - 'guard :cucumber do; end; guard :coffeescript do; end' + guardfile_contents: "guard :jasmine do; end; "\ + "guard :cucumber do; end; guard :coffeescript do; end" } end - let(:jasmine) { instance_double('Guard::Plugin') } - let(:cucumber) { instance_double('Guard::Plugin') } - let(:coffeescript) { instance_double('Guard::Plugin') } + let(:jasmine) { instance_double("Guard::Plugin") } + let(:cucumber) { instance_double("Guard::Plugin") } + let(:coffeescript) { instance_double("Guard::Plugin") } before do - stub_const 'Guard::Jasmine', jasmine - stub_const 'Guard::Cucumber', cucumber - stub_const 'Guard::CoffeeScript', coffeescript + stub_const "Guard::Jasmine", jasmine + stub_const "Guard::Cucumber", cucumber + stub_const "Guard::CoffeeScript", coffeescript end - it 'initializes the plugin scope' do - allow(plugins).to receive(:add).with('cucumber', {}) + it "initializes the plugin scope" do + allow(plugins).to receive(:add).with("cucumber", {}) .and_return(cucumber) - allow(plugins).to receive(:add).with('jasmine', {}) + allow(plugins).to receive(:add).with("jasmine", {}) .and_return(jasmine) expect(subject.cmdline_plugins).to match_array(%w[cucumber jasmine]) end end - context 'with the group option' do + context "with the group option" do let(:options) do { group: %w[backend frontend], - guardfile_contents: 'group :backend do; end; '\ - 'group :frontend do; end; group :excluded do; end' + guardfile_contents: "group :backend do; end; "\ + "group :frontend do; end; group :excluded do; end" } end before do - g3 = instance_double('Guard::Group', name: :backend, options: {}) - g4 = instance_double('Guard::Group', name: :frontend, options: {}) - allow(Guard::Group).to receive(:new).with('backend', {}).and_return(g3) - allow(Guard::Group).to receive(:new).with('frontend', {}).and_return(g4) + g3 = instance_double("Guard::Group", name: :backend, options: {}) + g4 = instance_double("Guard::Group", name: :frontend, options: {}) + allow(Guard::Group).to receive(:new).with("backend", {}).and_return(g3) + allow(Guard::Group).to receive(:new).with("frontend", {}).and_return(g4) end - it 'initializes the group scope' do + it "initializes the group scope" do expect(subject.cmdline_groups).to match_array(%w[backend frontend]) end end end - describe '#clearing' do - context 'when not set' do - context 'when clearing is not set from commandline' do + describe "#clearing" do + context "when not set" do + context "when clearing is not set from commandline" do it { is_expected.to_not be_clearing } end - context 'when clearing is set from commandline' do + context "when clearing is set from commandline" do let(:options) { { clear: false } } it { is_expected.to_not be_clearing } end end - context 'when set from guardfile' do - context 'when set to :on' do + context "when set from guardfile" do + context "when set to :on" do before { subject.clearing(true) } it { is_expected.to be_clearing } end - context 'when set to :off' do + context "when set to :off" do before { subject.clearing(false) } it { is_expected.to_not be_clearing } end end end - describe '#guardfile_ignore=' do - context 'when set from guardfile' do + describe "#guardfile_ignore=" do + context "when set from guardfile" do before { subject.guardfile_ignore = [/foo/] } specify { expect(subject.guardfile_ignore).to eq([/foo/]) } end - context 'when set multiple times from guardfile' do + context "when set multiple times from guardfile" do before do subject.guardfile_ignore = [/foo/] subject.guardfile_ignore = [/bar/] @@ -133,117 +133,117 @@ specify { expect(subject.guardfile_ignore).to eq([/foo/, /bar/]) } end - context 'when unset' do + context "when unset" do specify { expect(subject.guardfile_ignore).to eq([]) } end end - describe '#guardfile_ignore_bang=' do - context 'when set from guardfile' do + describe "#guardfile_ignore_bang=" do + context "when set from guardfile" do before { subject.guardfile_ignore_bang = [/foo/] } specify { expect(subject.guardfile_ignore_bang).to eq([/foo/]) } end - context 'when unset' do + context "when unset" do specify { expect(subject.guardfile_ignore_bang).to eq([]) } end end - describe '#guardfile_scope' do + describe "#guardfile_scope" do before do subject.guardfile_scope(scope) end - context 'with a groups scope' do + context "with a groups scope" do let(:scope) { { groups: [:foo] } } - it 'sets the groups' do + it "sets the groups" do expect(subject.guardfile_group_scope).to eq([:foo]) end end - context 'with a group scope' do + context "with a group scope" do let(:scope) { { group: [:foo] } } - it 'sets the groups' do + it "sets the groups" do expect(subject.guardfile_group_scope).to eq([:foo]) end end - context 'with a plugin scope' do + context "with a plugin scope" do let(:scope) { { plugin: [:foo] } } - it 'sets the plugins' do + it "sets the plugins" do expect(subject.guardfile_plugin_scope).to eq([:foo]) end end - context 'with a plugins scope' do + context "with a plugins scope" do let(:scope) { { plugins: [:foo] } } - it 'sets the plugins' do + it "sets the plugins" do expect(subject.guardfile_plugin_scope).to eq([:foo]) end end end - describe '.convert_scope' do - let(:foo) { instance_double('Guard::Plugin', name: 'foo') } - let(:bar) { instance_double('Guard::Plugin', name: 'bar') } - let(:backend) { instance_double('Guard::Group', name: 'backend') } - let(:frontend) { instance_double('Guard::Group', name: 'frontend') } + describe ".convert_scope" do + let(:foo) { instance_double("Guard::Plugin", name: "foo") } + let(:bar) { instance_double("Guard::Plugin", name: "bar") } + let(:backend) { instance_double("Guard::Group", name: "backend") } + let(:frontend) { instance_double("Guard::Group", name: "frontend") } before do - stub_const 'Guard::Foo', class_double('Guard::Plugin') - stub_const 'Guard::Bar', class_double('Guard::Plugin') - - allow(plugins).to receive(:all).with('backend').and_return([]) - allow(plugins).to receive(:all).with('frontend').and_return([]) - allow(plugins).to receive(:all).with('foo').and_return([foo]) - allow(plugins).to receive(:all).with('bar').and_return([bar]) - allow(plugins).to receive(:all).with('unknown').and_return([]) - allow(plugins).to receive(:all).with('scope').and_return([]) - - allow(groups).to receive(:all).with('backend').and_return([backend]) - allow(groups).to receive(:all).with('frontend').and_return([frontend]) - allow(groups).to receive(:all).with('unknown').and_return([]) - allow(groups).to receive(:all).with('scope').and_return([]) + stub_const "Guard::Foo", class_double("Guard::Plugin") + stub_const "Guard::Bar", class_double("Guard::Plugin") + + allow(plugins).to receive(:all).with("backend").and_return([]) + allow(plugins).to receive(:all).with("frontend").and_return([]) + allow(plugins).to receive(:all).with("foo").and_return([foo]) + allow(plugins).to receive(:all).with("bar").and_return([bar]) + allow(plugins).to receive(:all).with("unknown").and_return([]) + allow(plugins).to receive(:all).with("scope").and_return([]) + + allow(groups).to receive(:all).with("backend").and_return([backend]) + allow(groups).to receive(:all).with("frontend").and_return([frontend]) + allow(groups).to receive(:all).with("unknown").and_return([]) + allow(groups).to receive(:all).with("scope").and_return([]) end - it 'returns a group scope' do + it "returns a group scope" do scopes, = subject.convert_scope %w[backend] expect(scopes).to eq(groups: [backend], plugins: []) scopes, = subject.convert_scope %w[frontend] expect(scopes).to eq(groups: [frontend], plugins: []) end - it 'returns a plugin scope' do + it "returns a plugin scope" do scopes, = subject.convert_scope %w[foo] expect(scopes).to eq(plugins: [foo], groups: []) scopes, = subject.convert_scope %w[bar] expect(scopes).to eq(plugins: [bar], groups: []) end - it 'returns multiple group scopes' do + it "returns multiple group scopes" do scopes, = subject.convert_scope %w[backend frontend] expected = { groups: [backend, frontend], plugins: [] } expect(scopes).to eq(expected) end - it 'returns multiple plugin scopes' do + it "returns multiple plugin scopes" do scopes, = subject.convert_scope %w[foo bar] expect(scopes).to eq(plugins: [foo, bar], groups: []) end - it 'returns a plugin and group scope' do + it "returns a plugin and group scope" do scopes, = subject.convert_scope %w[foo backend] expect(scopes).to eq(plugins: [foo], groups: [backend]) end - it 'returns the unkown scopes' do + it "returns the unkown scopes" do _, unknown = subject.convert_scope %w[unknown scope] expect(unknown).to eq %w[unknown scope] end end - describe '#guardfile_notification=' do - context 'when set from guardfile' do + describe "#guardfile_notification=" do + context "when set from guardfile" do before do subject.guardfile_notification = { foo: { bar: :baz } } end @@ -258,13 +258,13 @@ end end - context 'when set multiple times from guardfile' do + context "when set multiple times from guardfile" do before do subject.guardfile_notification = { foo: { param: 1 } } subject.guardfile_notification = { bar: { param: 2 } } end - it 'merges results' do + it "merges results" do expect(subject.notify_options).to eq( notify: true, notifiers: { @@ -275,7 +275,7 @@ end end - context 'when unset' do + context "when unset" do specify do expect(subject.notify_options).to eq(notify: true, notifiers: {}) end diff --git a/spec/lib/guard/internals/state_spec.rb b/spec/lib/guard/internals/state_spec.rb index b870d146e..f406a8938 100644 --- a/spec/lib/guard/internals/state_spec.rb +++ b/spec/lib/guard/internals/state_spec.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require 'guard/internals/state' +require "guard/internals/state" RSpec.describe Guard::Internals::State do let(:options) { {} } subject { described_class.new(options) } - let(:scope) { instance_double('Guard::Internals::Scope') } - let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:groups) { instance_double('Guard::Internals::Groups') } - let(:session) { instance_double('Guard::Internals::Session') } + let(:scope) { instance_double("Guard::Internals::Scope") } + let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:groups) { instance_double("Guard::Internals::Groups") } + let(:session) { instance_double("Guard::Internals::Session") } before do allow(Guard::Internals::Session).to receive(:new).and_return(session) @@ -19,25 +19,25 @@ allow(session).to receive(:groups).and_return(groups) end - describe '#initialize' do - describe 'debugging' do + describe "#initialize" do + describe "debugging" do let(:options) { { debug: debug } } before do allow(session).to receive(:debug?).and_return(debug) expect(Guard::Internals::Session).to receive(:new).with(debug: debug) end - context 'when debug is set to true' do + context "when debug is set to true" do let(:debug) { true } - it 'sets up debugging' do + it "sets up debugging" do expect(Guard::Internals::Debugging).to receive(:start) subject end end - context 'when debug is set to false' do + context "when debug is set to false" do let(:debug) { false } - it 'does not set up debugging' do + it "does not set up debugging" do expect(Guard::Internals::Debugging).to_not receive(:start) subject end diff --git a/spec/lib/guard/internals/tracing_spec.rb b/spec/lib/guard/internals/tracing_spec.rb index 2e7208f8c..275e62a3a 100644 --- a/spec/lib/guard/internals/tracing_spec.rb +++ b/spec/lib/guard/internals/tracing_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'guard/internals/tracing' +require "guard/internals/tracing" RSpec.describe Guard::Internals::Tracing do let(:null) { IO::NULL } @@ -13,17 +13,17 @@ # Stubbing just Kernel.system isn't "deep" enough, but not only that, # we don't want to stub here, we want to TEST the stubbing # - describe 'Module method tracing' do + describe "Module method tracing" do let(:result) { Kernel.send(meth, *args) } subject { result } - let(:callback) { double('callback', call: true) } + let(:callback) { double("callback", call: true) } # Since we can't stub the C code in Ruby, only "right" way to test this is: # actually call a real command and compare the output before { allow(Kernel).to receive(meth).and_call_original } - context 'when tracing' do + context "when tracing" do before do described_class.trace(Kernel, meth) { |*args| callback.call(*args) } subject @@ -31,81 +31,81 @@ after { described_class.untrace(Kernel, meth) } - context 'with no command arguments' do + context "with no command arguments" do let(:args) { ["echo >#{null}"] } - context 'when #system' do - let(:meth) { 'system' } + context "when #system" do + let(:meth) { "system" } it { is_expected.to eq(true) } - it 'outputs command' do + it "outputs command" do expect(callback).to have_received(:call).with("echo >#{null}") end end - context 'when backticks' do + context "when backticks" do let(:meth) { :` } - it { is_expected.to eq('') } + it { is_expected.to eq("") } - it 'outputs command' do + it "outputs command" do expect(callback).to have_received(:call).with("echo >#{null}") end end end - context 'with command arguments' do + context "with command arguments" do let(:args) { %w[true 123] } - context 'when #system' do - let(:meth) { 'system' } + context "when #system" do + let(:meth) { "system" } it { is_expected.to eq(true) } - it 'outputs command arguments' do - expect(callback).to have_received(:call).with('true', '123') + it "outputs command arguments" do + expect(callback).to have_received(:call).with("true", "123") end end end end - context 'when not tracing' do + context "when not tracing" do before { subject } - context 'with no command arguments' do + context "with no command arguments" do let(:args) { ["echo test > #{null}"] } - context 'when #system' do + context "when #system" do let(:meth) { :system } it { is_expected.to eq(true) } - it 'does not output anything' do + it "does not output anything" do expect(callback).to_not have_received(:call) end end - context 'when backticks' do + context "when backticks" do let(:meth) { :` } - it { is_expected.to eq('') } + it { is_expected.to eq("") } - it 'does not output anything' do + it "does not output anything" do expect(callback).to_not have_received(:call) end end end - context 'with command arguments' do + context "with command arguments" do let(:args) { %w[true 123] } - context 'when #system' do + context "when #system" do let(:meth) { :system } it { is_expected.to eq(true) } - it 'does not output anything' do + it "does not output anything" do expect(callback).to_not have_received(:call) end end diff --git a/spec/lib/guard/internals/traps_spec.rb b/spec/lib/guard/internals/traps_spec.rb index 077eb197b..bb0b21587 100644 --- a/spec/lib/guard/internals/traps_spec.rb +++ b/spec/lib/guard/internals/traps_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'guard/internals/traps' +require "guard/internals/traps" RSpec.describe Guard::Internals::Traps do - describe '.handle' do + describe ".handle" do let(:signal_class) { class_double(Signal) } before do - stub_const('Signal', signal_class) + stub_const("Signal", signal_class) end - context 'with a supported signal name' do - let(:signal) { 'USR1' } + context "with a supported signal name" do + let(:signal) { "USR1" } - it 'sets up a handler' do - allow(Signal).to receive(:list).and_return('USR1' => 10) + it "sets up a handler" do + allow(Signal).to receive(:list).and_return("USR1" => 10) allow(Signal).to receive(:trap).with(signal) do |_, &block| block.call end @@ -23,11 +23,11 @@ end end - context 'with an unsupported signal name' do - let(:signal) { 'ABCD' } + context "with an unsupported signal name" do + let(:signal) { "ABCD" } - it 'does not set a handler' do - allow(Signal).to receive(:list).and_return('KILL' => 9) + it "does not set a handler" do + allow(Signal).to receive(:list).and_return("KILL" => 9) expect(Signal).to_not receive(:trap) described_class.handle(signal) end diff --git a/spec/lib/guard/jobs/pry_wrapper_spec.rb b/spec/lib/guard/jobs/pry_wrapper_spec.rb index 80a01c244..af3910228 100644 --- a/spec/lib/guard/jobs/pry_wrapper_spec.rb +++ b/spec/lib/guard/jobs/pry_wrapper_spec.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true -require 'guard/jobs/pry_wrapper' +require "guard/jobs/pry_wrapper" RSpec.describe Guard::Jobs::PryWrapper do subject { described_class.new({}) } - let(:listener) { instance_double('Listen::Listener') } - let(:pry_config) { double('pry_config') } - let(:pry_history) { double('pry_history') } - let(:pry_commands) { double('pry_commands') } - let(:pry_hooks) { double('pry_hooks') } - let(:terminal_settings) { instance_double('Guard::Jobs::TerminalSettings') } - - let(:session) { instance_double('Guard::Internals::Session') } - let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:groups) { instance_double('Guard::Internals::Groups') } - let(:state) { instance_double('Guard::Internals::State') } - let(:scope) { instance_double('Guard::Internals::Scope') } + let(:listener) { instance_double("Listen::Listener") } + let(:pry_config) { double("pry_config") } + let(:pry_history) { double("pry_history") } + let(:pry_commands) { double("pry_commands") } + let(:pry_hooks) { double("pry_hooks") } + let(:terminal_settings) { instance_double("Guard::Jobs::TerminalSettings") } + + let(:session) { instance_double("Guard::Internals::Session") } + let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:groups) { instance_double("Guard::Internals::Groups") } + let(:state) { instance_double("Guard::Internals::State") } + let(:scope) { instance_double("Guard::Internals::Scope") } before do # TODO: this are here to mock out Pry completely @@ -34,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('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) @@ -61,7 +61,7 @@ allow(terminal_settings).to receive(:restore) end - describe '#foreground' do + describe "#foreground" do before do allow(Pry).to receive(:start) do # sleep for a long time (anything > 0.6) @@ -73,7 +73,7 @@ subject.background end - it 'waits for Pry thread to finish' do + it "waits for Pry thread to finish" do was_alive = false Thread.new do @@ -86,7 +86,7 @@ expect(was_alive).to be end - it 'prevents the Pry thread from being killed too quickly' do + it "prevents the Pry thread from being killed too quickly" do start = Time.now.to_f Thread.new do @@ -100,7 +100,7 @@ expect(killed_moment - start).to be > 0.5 end - it 'return :stopped when brought into background' do + it "return :stopped when brought into background" do Thread.new do sleep 0.1 subject.background @@ -110,7 +110,7 @@ end end - describe '#background' do + describe "#background" do before do allow(Pry).to receive(:start) do # 0.5 is enough for Pry, so we use 0.4 @@ -118,7 +118,7 @@ end end - it 'kills the Pry thread' do + it "kills the Pry thread" do subject.foreground sleep 1 # give Pry 0.5 sec to boot subject.background @@ -128,57 +128,57 @@ end end - describe '#_prompt(ending_char)' do - let(:prompt) { subject.send(:_prompt, '>') } + describe "#_prompt(ending_char)" do + let(:prompt) { subject.send(:_prompt, ">") } before do - allow(Shellany::Sheller).to receive(:run).with('hash', 'stty') { false } - allow(scope).to receive(:titles).and_return(['all']) + 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) - expect(Pry).to receive(:view_clip).and_return('main') + expect(Pry).to receive(:view_clip).and_return("main") end let(:pry) { instance_double(Pry, input_array: []) } - context 'Guard is not paused' do + context "Guard is not paused" do it 'displays "guard"' do expect(prompt.call(double, 0, pry)) - .to eq '[0] guard(main)> ' + .to eq "[0] guard(main)> " end end - context 'Guard is paused' do + context "Guard is paused" do before do allow(listener).to receive(:paused?).and_return(true) end it 'displays "pause"' do expect(prompt.call(double, 0, pry)) - .to eq '[0] pause(main)> ' + .to eq "[0] pause(main)> " end end - context 'with a groups scope' do + context "with a groups scope" do before do allow(scope).to receive(:titles).and_return(%w[Backend Frontend]) end - it 'displays the group scope title in the prompt' do + it "displays the group scope title in the prompt" do expect(prompt.call(double, 0, pry)) - .to eq '[0] Backend,Frontend guard(main)> ' + .to eq "[0] Backend,Frontend guard(main)> " end end - context 'with a plugins scope' do + context "with a plugins scope" do before do allow(scope).to receive(:titles).and_return(%w[RSpec Ronn]) end - it 'displays the group scope title in the prompt' do + it "displays the group scope title in the prompt" do result = prompt.call(double, 0, pry) - expect(result).to eq '[0] RSpec,Ronn guard(main)> ' + expect(result).to eq "[0] RSpec,Ronn guard(main)> " end end end diff --git a/spec/lib/guard/jobs/sleep_spec.rb b/spec/lib/guard/jobs/sleep_spec.rb index 6067b6840..6cc171197 100644 --- a/spec/lib/guard/jobs/sleep_spec.rb +++ b/spec/lib/guard/jobs/sleep_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'guard/jobs/sleep' +require "guard/jobs/sleep" RSpec.describe Guard::Jobs::Sleep do subject { described_class.new({}) } - describe '#foreground' do - it 'sleeps' do - status = 'unknown' + describe "#foreground" do + it "sleeps" do + status = "unknown" Thread.new do sleep 0.1 @@ -17,10 +17,10 @@ subject.foreground - expect(status).to eq('sleep') + expect(status).to eq("sleep") end - it 'returns :stopped when put to background' do + it "returns :stopped when put to background" do Thread.new do sleep 0.1 subject.background @@ -30,9 +30,9 @@ end end - describe '#background' do - it 'wakes up main thread' do - status = 'unknown' + describe "#background" do + it "wakes up main thread" do + status = "unknown" Thread.new do sleep 0.1 # give enough time for foreground to put main thread to sleep @@ -55,7 +55,7 @@ rescue Timeout::Error end - expect(status).to eq('run') + expect(status).to eq("run") end end end diff --git a/spec/lib/guard/notifier_spec.rb b/spec/lib/guard/notifier_spec.rb index e1bc91f55..5f23724d9 100644 --- a/spec/lib/guard/notifier_spec.rb +++ b/spec/lib/guard/notifier_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'guard/notifier' +require "guard/notifier" RSpec.describe Guard::Notifier do subject { described_class } - let(:notifier) { instance_double('Notiffany::Notifier') } + let(:notifier) { instance_double("Notiffany::Notifier") } before do allow(Notiffany::Notifier).to receive(:new).and_return(notifier) @@ -14,31 +14,31 @@ Guard::Notifier.instance_variable_set(:@notifier, nil) end - describe 'toggle_notification' do + describe "toggle_notification" do before do allow(notifier).to receive(:enabled?).and_return(true) end - context 'with available notifiers' do - context 'when currently on' do + context "with available notifiers" do + context "when currently on" do before do allow(notifier).to receive(:active?).and_return(true) subject.connect end - it 'suspends notifications' do + it "suspends notifications" do expect(notifier).to receive(:turn_off) subject.toggle end end - context 'when currently off' do + context "when currently off" do before do subject.connect allow(notifier).to receive(:active?).and_return(false) end - it 'resumes notifications' do + it "resumes notifications" do expect(notifier).to receive(:turn_on) subject.toggle end @@ -46,37 +46,37 @@ end end - describe '.notify' do + describe ".notify" do before do subject.connect allow(notifier).to receive(:notify) end - context 'with no options' do - it 'notifies' do - expect(notifier).to receive(:notify).with('A', {}) - subject.notify('A') + context "with no options" do + it "notifies" do + expect(notifier).to receive(:notify).with("A", {}) + subject.notify("A") end end - context 'with multiple parameters' do - it 'notifies' do + context "with multiple parameters" do + it "notifies" do expect(notifier).to receive(:notify) - .with('A', priority: 2, image: :failed) - subject.notify('A', priority: 2, image: :failed) + .with("A", priority: 2, image: :failed) + subject.notify("A", priority: 2, image: :failed) end end - context 'with a runtime error' do + context "with a runtime error" do before do - allow(notifier).to receive(:notify).and_raise(RuntimeError, 'an error') + allow(notifier).to receive(:notify).and_raise(RuntimeError, "an error") end - it 'shows an error' do + it "shows an error" do expect(Guard::UI).to receive(:error) .with(/Notification failed for .+: an error/) - subject.notify('A', priority: 2, image: :failed) + subject.notify("A", priority: 2, image: :failed) end end end diff --git a/spec/lib/guard/options_spec.rb b/spec/lib/guard/options_spec.rb index 58f65fa41..683e4cf03 100644 --- a/spec/lib/guard/options_spec.rb +++ b/spec/lib/guard/options_spec.rb @@ -1,33 +1,33 @@ # frozen_string_literal: true -require 'guard/options' +require "guard/options" RSpec.describe Guard::Options do - describe '.initialize' do - it 'handles nil options' do + describe ".initialize" do + it "handles nil options" do expect { described_class.new(nil) }.to_not raise_error end - it 'has indifferent access' do - options = described_class.new({ foo: 'bar' }, 'foo2' => 'baz') + it "has indifferent access" do + options = described_class.new({ foo: "bar" }, "foo2" => "baz") - expect(options[:foo]).to eq 'bar' - expect(options['foo']).to eq 'bar' + expect(options[:foo]).to eq "bar" + expect(options["foo"]).to eq "bar" - expect(options[:foo2]).to eq 'baz' - expect(options['foo2']).to eq 'baz' + expect(options[:foo2]).to eq "baz" + expect(options["foo2"]).to eq "baz" end - it 'can be passed defaults' do - options = described_class.new({}, foo: 'bar') + it "can be passed defaults" do + options = described_class.new({}, foo: "bar") - expect(options[:foo]).to eq 'bar' + expect(options[:foo]).to eq "bar" end - it 'merges the sensible defaults to the given options' do - options = described_class.new({ plugin: ['rspec'] }, plugin: ['test']) + it "merges the sensible defaults to the given options" do + options = described_class.new({ plugin: ["rspec"] }, plugin: ["test"]) - expect(options[:plugin]).to eq ['rspec'] + expect(options[:plugin]).to eq ["rspec"] end end end diff --git a/spec/lib/guard/plugin_spec.rb b/spec/lib/guard/plugin_spec.rb index 98d318d90..a5712dcdf 100644 --- a/spec/lib/guard/plugin_spec.rb +++ b/spec/lib/guard/plugin_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require 'guard/plugin' +require "guard/plugin" -require 'guard/watcher' +require "guard/watcher" RSpec.describe Guard::Plugin do - let(:default) { instance_double('Guard::Group') } - let(:test) { instance_double('Guard::Group') } + let(:default) { instance_double("Guard::Group") } + let(:test) { instance_double("Guard::Group") } - let(:session) { instance_double('Guard::Internals::Session') } - let(:groups) { instance_double('Guard::Internals::Groups') } - let(:state) { instance_double('Guard::Internals::State') } + let(:session) { instance_double("Guard::Internals::Session") } + let(:groups) { instance_double("Guard::Internals::Groups") } + let(:state) { instance_double("Guard::Internals::State") } before do allow(groups).to receive(:add).with(:default).and_return(default) @@ -29,32 +29,32 @@ end end - describe '#initialize' do - it 'assigns the defined watchers' do - watchers = [double('foo')] + describe "#initialize" do + it "assigns the defined watchers" do + watchers = [double("foo")] expect(Guard::Plugin.new(watchers: watchers).watchers).to eq watchers end - it 'assigns the defined options' do + it "assigns the defined options" do options = { a: 1, b: 2 } expect(Guard::Plugin.new(options).options).to eq options end - context 'with a group in the options' do - it 'assigns the given group' do + context "with a group in the options" do + it "assigns the given group" do expect(Guard::Plugin.new(group: :test).group).to eq test end end - context 'without a group in the options' do - it 'assigns a default group' do + context "without a group in the options" do + it "assigns a default group" do allow(groups).to receive(:add).with(:default).and_return(default) expect(Guard::Plugin.new.group).to eq default end end - context 'with a callback' do - it 'adds the callback' do + context "with a callback" do + it "adds the callback" do block = instance_double(Proc) events = %i[start_begin start_end] callbacks = [{ events: events, listener: block }] @@ -64,7 +64,7 @@ end end - context 'with a plugin instance' do + context "with a plugin instance" do subject do module Guard class DuMmy < Guard::Plugin @@ -77,47 +77,47 @@ class DuMmy < Guard::Plugin Guard.send(:remove_const, :DuMmy) end - describe '.non_namespaced_classname' do - it 'remove the Guard:: namespace' do - expect(subject.non_namespaced_classname).to eq 'DuMmy' + describe ".non_namespaced_classname" do + it "remove the Guard:: namespace" do + expect(subject.non_namespaced_classname).to eq "DuMmy" end end - describe '.non_namespaced_name' do - it 'remove the Guard:: namespace and downcase' do - expect(subject.non_namespaced_name).to eq 'dummy' + describe ".non_namespaced_name" do + it "remove the Guard:: namespace and downcase" do + expect(subject.non_namespaced_name).to eq "dummy" end end - describe '.template' do + describe ".template" do before do allow(File).to receive(:read) end - it 'reads the default template' do + it "reads the default template" do expect(File).to receive(:read) - .with('/guard-dummy/lib/guard/dummy/templates/Guardfile') { true } + .with("/guard-dummy/lib/guard/dummy/templates/Guardfile") { true } - subject.template('/guard-dummy') + subject.template("/guard-dummy") end end - describe '#name' do - it 'outputs the short plugin name' do - expect(subject.new.name).to eq 'dummy' + describe "#name" do + it "outputs the short plugin name" do + expect(subject.new.name).to eq "dummy" end end - describe '#title' do - it 'outputs the plugin title' do - expect(subject.new.title).to eq 'DuMmy' + describe "#title" do + it "outputs the plugin title" do + expect(subject.new.title).to eq "DuMmy" end end - describe '#to_s' do - let(:default) { instance_double('Guard::Group', name: :default) } + describe "#to_s" do + let(:default) { instance_double("Guard::Group", name: :default) } - it 'output the short plugin name' do + it "output the short plugin name" do expect(subject.new.to_s) .to match(/#/) end @@ -126,10 +126,10 @@ class DuMmy < Guard::Plugin let(:listener) { instance_double(Proc, call: nil) } - describe '.add_callback' do - let(:foo) { double('foo plugin') } + describe ".add_callback" do + let(:foo) { double("foo plugin") } - it 'can add a run_on_modifications callback' do + it "can add a run_on_modifications callback" do described_class.add_callback( listener, foo, @@ -140,7 +140,7 @@ class DuMmy < Guard::Plugin expect(result).to include(listener) end - it 'can add multiple callbacks' do + it "can add multiple callbacks" do described_class.add_callback(listener, foo, %i[event1 event2]) result = described_class.callbacks[[foo, :event1]] @@ -151,46 +151,46 @@ class DuMmy < Guard::Plugin end end - describe '.notify' do - let(:foo) { double('foo plugin') } - let(:bar) { double('bar plugin') } + describe ".notify" do + let(:foo) { double("foo plugin") } + let(:bar) { double("bar plugin") } before do described_class.add_callback(listener, foo, :start_begin) end it "sends :call to the given Guard class's start_begin callback" do - expect(listener).to receive(:call).with(foo, :start_begin, 'args') - described_class.notify(foo, :start_begin, 'args') + expect(listener).to receive(:call).with(foo, :start_begin, "args") + described_class.notify(foo, :start_begin, "args") end it "sends :call to the given Guard class's start_begin callback" do - expect(listener).to receive(:call).with(foo, :start_begin, 'args') - described_class.notify(foo, :start_begin, 'args') + expect(listener).to receive(:call).with(foo, :start_begin, "args") + described_class.notify(foo, :start_begin, "args") end - it 'runs only the given callbacks' do - listener2 = double('listener2') + it "runs only the given callbacks" do + listener2 = double("listener2") described_class.add_callback(listener2, foo, :start_end) expect(listener2).to_not receive(:call).with(foo, :start_end) described_class.notify(foo, :start_begin) end - it 'runs callbacks only for the guard given' do + it "runs callbacks only for the guard given" do described_class.add_callback(listener, bar, :start_begin) expect(listener).to_not receive(:call).with(bar, :start_begin) described_class.notify(foo, :start_begin) end end - describe '#hook' do - let(:foo) { double('foo plugin') } + describe "#hook" do + let(:foo) { double("foo plugin") } before do described_class.add_callback(listener, foo, :start_begin) end - it 'notifies the hooks' do + it "notifies the hooks" do class Foo < described_class def run_all hook :begin @@ -204,10 +204,10 @@ def run_all foo.run_all end - it 'passes the hooks name' do + it "passes the hooks name" do class Foo < described_class def start - hook 'my_hook' + hook "my_hook" end end @@ -216,20 +216,20 @@ def start foo.start end - it 'accepts extra arguments' do + it "accepts extra arguments" do class Foo < described_class def stop - hook :begin, 'args' - hook 'special_sauce', 'first_arg', 'second_arg' + hook :begin, "args" + hook "special_sauce", "first_arg", "second_arg" end end foo = Foo.new expect(described_class).to receive(:notify) - .with(foo, :stop_begin, 'args') + .with(foo, :stop_begin, "args") expect(described_class).to receive(:notify) - .with(foo, :special_sauce, 'first_arg', 'second_arg') + .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 590f0951e..6bcc40b95 100644 --- a/spec/lib/guard/plugin_util_spec.rb +++ b/spec/lib/guard/plugin_util_spec.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require 'guard/plugin_util' +require "guard/plugin_util" -require 'guard/guardfile/evaluator' +require "guard/guardfile/evaluator" RSpec.describe Guard::PluginUtil do - let(:guard_rspec_class) { class_double('Guard::Plugin') } - let(:guard_rspec) { instance_double('Guard::Plugin') } - let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } - let(:session) { instance_double('Guard::Internals::Session') } - let(:state) { instance_double('Guard::Internals::State') } + let(:guard_rspec_class) { class_double("Guard::Plugin") } + let(:guard_rspec) { instance_double("Guard::Plugin") } + let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } + let(:session) { instance_double("Guard::Internals::Session") } + let(:state) { instance_double("Guard::Internals::State") } before do allow(session).to receive(:evaluator_options).and_return({}) @@ -18,52 +18,52 @@ allow(Guard::Guardfile::Evaluator).to receive(:new).and_return(evaluator) end - describe '.plugin_names' do + describe ".plugin_names" do before do spec = Gem::Specification gems = [ - 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-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") ] allow(File).to receive(:exist?) - .with('/gem1/lib/guard/gem1.rb') { false } + .with("/gem1/lib/guard/gem1.rb") { false } allow(File).to receive(:exist?) - .with('/gem2/lib/guard/gem2.rb') { true } + .with("/gem2/lib/guard/gem2.rb") { true } gem = class_double(Gem::Specification) - stub_const('Gem::Specification', gem) + stub_const("Gem::Specification", gem) expect(Gem::Specification).to receive(:find_all) { gems } allow(Gem::Specification).to receive(:unresolved_deps) { [] } end - it 'returns the list of guard gems' do - expect(described_class.plugin_names).to include('myplugin') + it "returns the list of guard gems" do + expect(described_class.plugin_names).to include("myplugin") end - it 'returns the list of embedded guard gems' do - expect(described_class.plugin_names).to include('gem2') + it "returns the list of embedded guard gems" do + expect(described_class.plugin_names).to include("gem2") end - it 'ignores guard-compat' do - expect(described_class.plugin_names).to_not include('compat') + it "ignores guard-compat" do + expect(described_class.plugin_names).to_not include("compat") end end - describe '#initialize' do - it 'accepts a name without guard-' do - expect(described_class.new('rspec').name).to eq 'rspec' + describe "#initialize" do + it "accepts a name without guard-" do + expect(described_class.new("rspec").name).to eq "rspec" end - it 'accepts a name with guard-' do - expect(described_class.new('guard-rspec').name).to eq 'rspec' + it "accepts a name with guard-" do + expect(described_class.new("guard-rspec").name).to eq "rspec" end end - describe '#initialize_plugin' do - let(:plugin_util) { described_class.new('rspec') } + describe "#initialize_plugin" do + let(:plugin_util) { described_class.new("rspec") } before do allow_any_instance_of(described_class) @@ -71,13 +71,13 @@ .and_return(guard_rspec_class) end - context 'with a plugin inheriting from Guard::Plugin' do + context "with a plugin inheriting from Guard::Plugin" do before do expect(guard_rspec_class).to receive(:ancestors) { [::Guard::Plugin] } end - it 'instantiate the plugin using the new API' do - options = { watchers: ['watcher'], group: 'foo' } + it "instantiate the plugin using the new API" do + options = { watchers: ["watcher"], group: "foo" } expect(guard_rspec_class).to receive(:new).with(options) { guard_rspec } expect(plugin_util.initialize_plugin(options)).to eq guard_rspec @@ -85,17 +85,17 @@ end end - describe '#plugin_location' do - subject { described_class.new('rspec') } + describe "#plugin_location" do + subject { described_class.new("rspec") } - it 'returns the path of a Guard gem' do + 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(subject.plugin_location).to eq 'gems/guard-rspec' + .with("guard-rspec") { double(full_gem_path: "gems/guard-rspec") } + expect(subject.plugin_location).to eq "gems/guard-rspec" end end - describe '#plugin_class' do + describe "#plugin_class" do after do # TODO: use RSpec's stub const consts = %i[Classname @@ -112,23 +112,23 @@ end end - it 'reports an error if the class is not found' do + it "reports an error if the class is not found" do expect(::Guard::UI).to receive(:error).with(/Could not load/) expect(::Guard::UI).to receive(:error).with(/Error is: cannot load/) 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 --') + plugin = described_class.new("notAGuardClass") + allow(plugin).to receive(:require).with("guard/notaguardclass") + .and_raise(LoadError, "cannot load such file --") plugin.plugin_class end - context 'with a nested Guard class' do - it 'resolves the Guard class from string' do - plugin = described_class.new('classname') + context "with a nested Guard class" do + it "resolves the Guard class from string" do + plugin = described_class.new("classname") expect(plugin).to receive(:require) do |classname| - expect(classname).to eq 'guard/classname' + expect(classname).to eq "guard/classname" module Guard class Classname end @@ -137,10 +137,10 @@ class Classname expect(plugin.plugin_class).to eq Guard::Classname end - it 'resolves the Guard class from symbol' do + it "resolves the Guard class from symbol" do plugin = described_class.new(:classname) expect(plugin).to receive(:require) do |classname| - expect(classname).to eq 'guard/classname' + expect(classname).to eq "guard/classname" module Guard class Classname end @@ -150,11 +150,11 @@ class Classname end end - context 'with a name with dashes' do - it 'returns the Guard class' do - plugin = described_class.new('dashed-class-name') + context "with a name with dashes" do + it "returns the Guard class" do + plugin = described_class.new("dashed-class-name") expect(plugin).to receive(:require) do |classname| - expect(classname).to eq 'guard/dashed-class-name' + expect(classname).to eq "guard/dashed-class-name" module Guard class DashedClassName end @@ -164,11 +164,11 @@ class DashedClassName end end - context 'with a name with underscores' do - it 'returns the Guard class' do - plugin = described_class.new('underscore_class_name') + context "with a name with underscores" do + it "returns the Guard class" do + plugin = described_class.new("underscore_class_name") expect(plugin).to receive(:require) do |classname| - expect(classname).to eq 'guard/underscore_class_name' + expect(classname).to eq "guard/underscore_class_name" module Guard class UnderscoreClassName end @@ -178,12 +178,12 @@ class UnderscoreClassName end end - context 'with a name like VSpec' do - it 'returns the Guard class' do - plugin = described_class.new('vspec') + context "with a name like VSpec" do + it "returns the Guard class" do + plugin = described_class.new("vspec") mod = nil allow(plugin).to receive(:require) do |classname| - expect(classname).to eq 'guard/vspec' + expect(classname).to eq "guard/vspec" module Guard class VSpec end @@ -195,11 +195,11 @@ class VSpec end end - context 'with an inline Guard class' do - subject { described_class.new('inline') } - let(:plugin_class) { class_double('Guard::Plugin') } + context "with an inline Guard class" do + subject { described_class.new("inline") } + let(:plugin_class) { class_double("Guard::Plugin") } - it 'returns the Guard class' do + 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) @@ -209,10 +209,10 @@ class VSpec end end - context 'when set to fail gracefully' do + context "when set to fail gracefully" do options = { fail_gracefully: true } - subject { described_class.new('notAGuardClass') } - it 'does not print error messages on fail' do + subject { described_class.new("notAGuardClass") } + it "does not print error messages on fail" do expect(::Guard::UI).to_not receive(:error) plugin = subject allow(plugin).to receive(:require).and_raise(LoadError) @@ -221,30 +221,30 @@ class VSpec end end - describe '#add_to_guardfile' do + describe "#add_to_guardfile" do before do allow(Guard::Guardfile::Evaluator).to receive(:new).and_return(evaluator) allow(evaluator).to receive(:evaluate) end - context 'when the Guard is already in the Guardfile' do + context "when the Guard is already in the Guardfile" do before do allow(evaluator).to receive(:guardfile_include?) { true } end - it 'shows an info message' do + it "shows an info message" do expect(::Guard::UI).to receive(:info) - .with 'Guardfile already includes myguard guard' + .with "Guardfile already includes myguard guard" - described_class.new('myguard').add_to_guardfile + described_class.new("myguard").add_to_guardfile end end - context 'when Guardfile is empty' do - let(:plugin_util) { described_class.new('myguard') } - let(:plugin_class) { class_double('Guard::Plugin') } - let(:location) { '/Users/me/projects/guard-myguard' } - let(:gem_spec) { instance_double('Gem::Specification') } + context "when Guardfile is empty" do + let(:plugin_util) { described_class.new("myguard") } + let(:plugin_class) { class_double("Guard::Plugin") } + let(:location) { "/Users/me/projects/guard-myguard" } + let(:gem_spec) { instance_double("Gem::Specification") } let(:io) { StringIO.new } before do @@ -258,26 +258,26 @@ class VSpec .and_return(plugin_class) allow(Gem::Specification).to receive(:find_by_name) - .with('guard-myguard').and_return(gem_spec) + .with("guard-myguard").and_return(gem_spec) allow(plugin_class).to receive(:template).with(location) - .and_return('Template content') + .and_return("Template content") - allow(File).to receive(:read).with('Guardfile') { 'Guardfile content' } - allow(File).to receive(:open).with('Guardfile', 'wb').and_yield io + allow(File).to receive(:read).with("Guardfile") { "Guardfile content" } + allow(File).to receive(:open).with("Guardfile", "wb").and_yield io end - it 'appends the template to the Guardfile' do + it "appends the template to the Guardfile" do plugin_util.add_to_guardfile expect(io.string).to eq "Guardfile content\n\nTemplate content\n" end end - context 'when the Guard is not in the Guardfile' do - let(:plugin_util) { described_class.new('myguard') } - let(:plugin_class) { class_double('Guard::Plugin') } - let(:location) { '/Users/me/projects/guard-myguard' } - let(:gem_spec) { instance_double('Gem::Specification') } + context "when the Guard is not in the Guardfile" do + let(:plugin_util) { described_class.new("myguard") } + let(:plugin_class) { class_double("Guard::Plugin") } + let(:location) { "/Users/me/projects/guard-myguard" } + let(:gem_spec) { instance_double("Gem::Specification") } let(:io) { StringIO.new } before do @@ -288,16 +288,16 @@ class VSpec .and_return(plugin_class) allow(Gem::Specification).to receive(:find_by_name) - .with('guard-myguard').and_return(gem_spec) + .with("guard-myguard").and_return(gem_spec) allow(plugin_class).to receive(:template).with(location) - .and_return('Template content') + .and_return("Template content") - allow(File).to receive(:read).with('Guardfile') { 'Guardfile content' } - allow(File).to receive(:open).with('Guardfile', 'wb').and_yield io + allow(File).to receive(:read).with("Guardfile") { "Guardfile content" } + allow(File).to receive(:open).with("Guardfile", "wb").and_yield io end - it 'appends the template to the Guardfile' do + it "appends the template to the Guardfile" do plugin_util.add_to_guardfile expect(io.string).to eq "Guardfile content\n\nTemplate content\n" end diff --git a/spec/lib/guard/runner_spec.rb b/spec/lib/guard/runner_spec.rb index ab4679ced..36c81b6bc 100644 --- a/spec/lib/guard/runner_spec.rb +++ b/spec/lib/guard/runner_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require 'guard/runner' +require "guard/runner" -require 'guard/plugin' +require "guard/plugin" RSpec.describe Guard::Runner do - let(:ui_config) { instance_double('Guard::UI::Config') } + let(:ui_config) { instance_double("Guard::UI::Config") } let(:backend_group) do - instance_double('Guard::Group', options: {}, name: :backend) + instance_double("Guard::Group", options: {}, name: :backend) end let(:frontend_group) do - instance_double('Guard::Group', options: {}, name: :frontend) + instance_double("Guard::Group", options: {}, name: :frontend) end - let(:foo_plugin) { double('foo', group: backend_group, hook: nil) } - let(:bar_plugin) { double('bar', group: frontend_group, hook: nil) } - let(:baz_plugin) { double('baz', group: frontend_group, hook: nil) } + let(:foo_plugin) { double("foo", group: backend_group, hook: nil) } + let(:bar_plugin) { double("bar", group: frontend_group, hook: nil) } + let(:baz_plugin) { double("baz", group: frontend_group, hook: nil) } - let(:scope) { instance_double('Guard::Internals::Scope') } - let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:state) { instance_double('Guard::Internals::State') } - let(:session) { instance_double('Guard::Internals::Session') } + let(:scope) { instance_double("Guard::Internals::Scope") } + let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:state) { instance_double("Guard::Internals::State") } + let(:session) { instance_double("Guard::Internals::Session") } before do allow(session).to receive(:plugins).and_return(plugins) @@ -41,7 +41,7 @@ Guard::UI.options = nil end - describe '#run' do + describe "#run" do before do allow(scope).to receive(:grouped_plugins).with({}) .and_return([[nil, [foo_plugin, bar_plugin, baz_plugin]]]) @@ -49,7 +49,7 @@ allow(ui_config).to receive(:with_progname).and_yield end - it 'executes supervised task on all registered plugins implementing it' do + it "executes supervised task on all registered plugins implementing it" do [foo_plugin, bar_plugin].each do |plugin| expect(plugin).to receive(:my_hard_task) end @@ -57,26 +57,26 @@ subject.run(:my_hard_task) end - it 'marks an action as unit of work' do + it "marks an action as unit of work" do expect(Lumberjack).to receive(:unit_of_work) subject.run(:my_task) end - context 'with interrupted task' do + context "with interrupted task" do before do allow(foo_plugin).to receive(:failing).and_raise(Interrupt) # allow(Guard).to receive(:plugins).and_return([foo_plugin]) end - it 'catches the thrown symbol' do + it "catches the thrown symbol" do expect { subject.run(:failing) }.to_not throw_symbol(:task_has_failed) end end - context 'with a scope' do + context "with a scope" do let(:scope_hash) { { plugin: :bar } } - it 'executes the supervised task on the specified plugin only' do + 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]]]) @@ -88,10 +88,10 @@ end end - context 'with no scope' do + context "with no scope" do let(:scope_hash) { nil } - it 'executes the supervised task using current scope' do + it "executes the supervised task using current scope" do expect(bar_plugin).to receive(:my_task) expect(foo_plugin).to receive(:my_task) expect(baz_plugin).to receive(:my_task) @@ -101,7 +101,7 @@ end end - describe '#run_on_changes' do + describe "#run_on_changes" do let(:changes) { [[], [], []] } let(:watcher_module) { Guard::Watcher } @@ -109,22 +109,22 @@ allow(watcher_module).to receive(:match_files) { [] } allow(Guard::UI).to receive(:clear) - allow(foo_plugin).to receive(:regular_without_arg) { fail 'not stubbed' } - allow(foo_plugin).to receive(:regular_with_arg) { fail 'not stubbed' } - allow(foo_plugin).to receive(:failing) { fail 'not stubbed' } + allow(foo_plugin).to receive(:regular_without_arg) { fail "not stubbed" } + allow(foo_plugin).to receive(:regular_with_arg) { fail "not stubbed" } + allow(foo_plugin).to receive(:failing) { fail "not stubbed" } # TODO: runner shouldn't have to know about these - allow(foo_plugin).to receive(:run_on_modifications) { fail 'not stubbed' } - allow(foo_plugin).to receive(:run_on_change) { fail 'not stubbed' } - allow(foo_plugin).to receive(:run_on_additions) { fail 'not stubbed' } - allow(foo_plugin).to receive(:run_on_removals) { fail 'not stubbed' } - allow(foo_plugin).to receive(:run_on_deletion) { fail 'not stubbed' } + allow(foo_plugin).to receive(:run_on_modifications) { fail "not stubbed" } + allow(foo_plugin).to receive(:run_on_change) { fail "not stubbed" } + allow(foo_plugin).to receive(:run_on_additions) { fail "not stubbed" } + allow(foo_plugin).to receive(:run_on_removals) { fail "not stubbed" } + allow(foo_plugin).to receive(:run_on_deletion) { fail "not stubbed" } allow(foo_plugin).to receive(:my_task) allow(bar_plugin).to receive(:my_task) allow(baz_plugin).to receive(:my_task) - allow(foo_plugin).to receive(:name).and_return('Foo') + allow(foo_plugin).to receive(:name).and_return("Foo") allow(scope).to receive(:grouped_plugins) do |args| fail "stub me (#{args.inspect})!" @@ -144,7 +144,7 @@ allow(ui_config).to receive(:with_progname).and_yield end - it 'always calls UI.clearable' do + 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]]]) @@ -152,8 +152,8 @@ subject.run_on_changes(*changes) end - context 'when clearable' do - it 'clear UI' do + 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]]]) @@ -161,8 +161,8 @@ end end - context 'with no changes' do - it 'does not run any task' do + context "with no changes" do + it "does not run any task" do %w[ run_on_modifications run_on_change @@ -176,7 +176,7 @@ end end - context 'with modified files but modified paths is empty' do + context "with modified files but modified paths is empty" do let(:modified) { %w[file.txt image.png] } before do @@ -187,13 +187,13 @@ # stub so respond_to? works end - it 'does not call run anything' do + it "does not call run anything" do expect(foo_plugin).to_not receive(:run_on_modifications) subject.run_on_changes(*changes) end end - context 'with modified paths' do + context "with modified paths" do let(:modified) { %w[file.txt image.png] } before do @@ -202,13 +202,13 @@ .with(foo_plugin, modified).and_return(modified) end - it 'executes the :run_first_task_found task' do + it "executes the :run_first_task_found task" do expect(foo_plugin).to receive(:run_on_modifications).with(modified) {} subject.run_on_changes(*changes) end end - context 'with added files but added paths is empty' do + context "with added files but added paths is empty" do let(:added) { %w[file.txt image.png] } before do @@ -217,13 +217,13 @@ .with(foo_plugin, added).and_return([]) end - it 'does not call run anything' do + it "does not call run anything" do expect(foo_plugin).to_not receive(:run_on_additions) subject.run_on_changes(*changes) end end - context 'with added paths' do + context "with added paths" do let(:added) { %w[file.txt image.png] } before do @@ -232,13 +232,13 @@ .with(foo_plugin, added).and_return(added) end - it 'executes the :run_on_additions task' do + it "executes the :run_on_additions task" do expect(foo_plugin).to receive(:run_on_additions).with(added) {} subject.run_on_changes(*changes) end end - context 'with non-matching removed paths' do + context "with non-matching removed paths" do let(:removed) { %w[file.txt image.png] } before do @@ -250,13 +250,13 @@ allow(foo_plugin).to receive(:run_on_removals) end - it 'does not call tasks' do + it "does not call tasks" do expect(foo_plugin).to_not receive(:run_on_removals) subject.run_on_changes(*changes) end end - context 'with matching removed paths' do + context "with matching removed paths" do let(:removed) { %w[file.txt image.png] } before do @@ -265,82 +265,82 @@ .with(foo_plugin, removed) { removed } end - it 'executes the :run_on_removals task' do + it "executes the :run_on_removals task" do expect(foo_plugin).to receive(:run_on_removals).with(removed) {} subject.run_on_changes(*changes) end end end - describe '#_supervise' do + describe "#_supervise" do before do allow(ui_config).to receive(:with_progname).and_yield end - it 'executes the task on the passed guard' do + it "executes the task on the passed guard" do expect(foo_plugin).to receive(:my_task) subject.send(:_supervise, foo_plugin, :my_task) end - context 'with a task that succeeds' do - context 'without any arguments' do + context "with a task that succeeds" do + context "without any arguments" do before do allow(foo_plugin).to receive(:regular_without_arg) { true } end - it 'does not remove the Guard' do + it "does not remove the Guard" do expect(plugins).to_not receive(:remove) subject.send(:_supervise, foo_plugin, :regular_without_arg) end - it 'returns the result of the task' do + it "returns the result of the task" do result = subject.send(:_supervise, foo_plugin, :regular_without_arg) expect(result).to be_truthy end - it 'calls :begin and :end hooks' do + it "calls :begin and :end hooks" do expect(foo_plugin).to receive(:hook) - .with('regular_without_arg_begin') + .with("regular_without_arg_begin") expect(foo_plugin).to receive(:hook) - .with('regular_without_arg_end', true) + .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 + it "passes the result of the supervised method to the :end hook" do expect(foo_plugin).to receive(:hook) - .with('regular_without_arg_begin') + .with("regular_without_arg_begin") expect(foo_plugin).to receive(:hook) - .with('regular_without_arg_end', true) + .with("regular_without_arg_end", true) subject.send(:_supervise, foo_plugin, :regular_without_arg) end end - context 'with arguments' do + context "with arguments" do before do allow(foo_plugin).to receive(:regular_with_arg) - .with('given_path') { "I'm a success" } + .with("given_path") { "I'm a success" } end - it 'does not remove the Guard' do + it "does not remove the Guard" do expect(plugins).to_not receive(:remove) subject.send( :_supervise, foo_plugin, :regular_with_arg, - 'given_path' + "given_path" ) end - it 'returns the result of the task' do + it "returns the result of the task" do result = subject.send( :_supervise, foo_plugin, :regular_with_arg, - 'given_path' + "given_path" ) expect(result).to eq "I'm a success" @@ -348,26 +348,26 @@ end end - context 'with a task that throws :task_has_failed' do + context "with a task that throws :task_has_failed" do before do allow(foo_plugin).to receive(:failing) { throw :task_has_failed } end - context 'in a group' do - context 'with halt_on_fail: true' do + context "in a group" do + context "with halt_on_fail: true" do before { backend_group.options[:halt_on_fail] = true } - it 'throws :task_has_failed' do + it "throws :task_has_failed" do expect do subject.send(:_supervise, foo_plugin, :failing) end.to throw_symbol(:task_has_failed) end end - context 'with halt_on_fail: false' do + context "with halt_on_fail: false" do before { backend_group.options[:halt_on_fail] = false } - it 'catches :task_has_failed' do + it "catches :task_has_failed" do expect do subject.send(:_supervise, foo_plugin, :failing) end.to_not throw_symbol(:task_has_failed) @@ -376,63 +376,63 @@ end end - context 'with a task that raises an exception' do + context "with a task that raises an exception" do before do - allow(foo_plugin).to receive(:failing) { fail 'I break your system' } + allow(foo_plugin).to receive(:failing) { fail "I break your system" } allow(plugins).to receive(:remove).with(foo_plugin) end - it 'removes the Guard' do + it "removes the Guard" do expect(plugins).to receive(:remove).with(foo_plugin) {} subject.send(:_supervise, foo_plugin, :failing) end - it 'display an error to the user' do + it "display an error to the user" do expect(::Guard::UI).to receive :error expect(::Guard::UI).to receive :info subject.send(:_supervise, foo_plugin, :failing) end - it 'returns the exception' do + it "returns the exception" do failing_result = subject.send(:_supervise, foo_plugin, :failing) expect(failing_result).to be_kind_of(Exception) - expect(failing_result.message).to eq 'I break your system' + expect(failing_result.message).to eq "I break your system" end - it 'calls the default begin hook but not the default end hook' do - expect(foo_plugin).to receive(:hook).with('failing_begin') - expect(foo_plugin).to_not receive(:hook).with('failing_end') + it "calls the default begin hook but not the default end hook" do + expect(foo_plugin).to receive(:hook).with("failing_begin") + expect(foo_plugin).to_not receive(:hook).with("failing_end") subject.send(:_supervise, foo_plugin, :failing) end end end - describe '.stopping_symbol_for' do - let(:guard_plugin) { instance_double('Guard::Plugin') } - let(:group) { instance_double('Guard::Group', title: 'Foo') } + describe ".stopping_symbol_for" do + let(:guard_plugin) { instance_double("Guard::Plugin") } + let(:group) { instance_double("Guard::Group", title: "Foo") } before do allow(guard_plugin).to receive(:group).and_return(group) end - context 'for a group with :halt_on_fail' do + context "for a group with :halt_on_fail" do before do allow(group).to receive(:options).and_return(halt_on_fail: true) end - it 'returns :no_catch' do + it "returns :no_catch" do symbol = described_class.stopping_symbol_for(guard_plugin) expect(symbol).to eq :no_catch end end - context 'for a group without :halt_on_fail' do + context "for a group without :halt_on_fail" do before do allow(group).to receive(:options).and_return(halt_on_fail: false) end - it 'returns :task_has_failed' do + it "returns :task_has_failed" do symbol = described_class.stopping_symbol_for(guard_plugin) expect(symbol).to eq :task_has_failed end diff --git a/spec/lib/guard/terminal_spec.rb b/spec/lib/guard/terminal_spec.rb index 502c2f9ad..035072d59 100644 --- a/spec/lib/guard/terminal_spec.rb +++ b/spec/lib/guard/terminal_spec.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true -require 'guard/terminal' +require "guard/terminal" RSpec.describe Guard::Terminal do subject { described_class } it { is_expected.to respond_to(:clear) } - let(:sheller) { class_double('Shellany::Sheller') } + let(:sheller) { class_double("Shellany::Sheller") } before do - stub_const('Shellany::Sheller', sheller) + stub_const("Shellany::Sheller", sheller) end - describe '.clear' do - context 'when on UNIX' do + describe ".clear" do + context "when on UNIX" do before { allow(Gem).to receive(:win_platform?).and_return(false) } - context 'when the clear command exists' do - let(:result) { [0, "\e[H\e[2J", ''] } + context "when the clear command exists" do + let(:result) { [0, "\e[H\e[2J", ""] } it "clears the screen using 'clear'" do expect(sheller).to receive(:system).with("printf '\33c\e[3J';") @@ -26,7 +26,7 @@ end end - context 'when the clear command fails' do + context "when the clear command fails" do let(:result) { [nil, nil, 'Guard failed to run "clear;"'] } before do @@ -34,30 +34,30 @@ .and_return(result) end - it 'fails' do + it "fails" do expect { ::Guard::Terminal.clear } .to raise_error(Errno::ENOENT, /Guard failed to run "clear;"/) end end end - context 'when on Windows' do + context "when on Windows" do before { allow(Gem).to receive(:win_platform?).and_return(true) } - it 'clears the screen' do - result = [0, "\f", ''] - expect(sheller).to receive(:system).with('cls').and_return(result) + it "clears the screen" do + result = [0, "\f", ""] + expect(sheller).to receive(:system).with("cls").and_return(result) ::Guard::Terminal.clear end - context 'when the clear command fails' do + context "when the clear command fails" do let(:result) { [nil, nil, 'Guard failed to run "cls"'] } before do - allow(sheller).to receive(:system).with('cls').and_return(result) + allow(sheller).to receive(:system).with("cls").and_return(result) end - it 'fails' do + it "fails" do expect { ::Guard::Terminal.clear } .to raise_error(Errno::ENOENT, /Guard failed to run "cls"/) end diff --git a/spec/lib/guard/ui/config_spec.rb b/spec/lib/guard/ui/config_spec.rb index 4bd282d31..059dac67b 100644 --- a/spec/lib/guard/ui/config_spec.rb +++ b/spec/lib/guard/ui/config_spec.rb @@ -1,72 +1,72 @@ # frozen_string_literal: true -require 'guard/ui/config' +require "guard/ui/config" RSpec.describe Guard::UI::Config do - describe '#device' do - context 'when not set' do - context 'when accessed as a method' do - it 'returns $stderr' do + describe "#device" do + context "when not set" do + context "when accessed as a method" do + it "returns $stderr" do expect(subject.device).to be($stderr) end end - context 'when accessed as a string' do - it 'returns $stderr' do - expect(subject['device']).to be($stderr) + context "when accessed as a string" do + it "returns $stderr" do + expect(subject["device"]).to be($stderr) end end - context 'when accessed as a symbol' do - it 'returns $stderr' do + context "when accessed as a symbol" do + it "returns $stderr" do expect(subject[:device]).to be($stderr) end end end end - describe '#logger_config' do + describe "#logger_config" do let(:options) { {} } subject { described_class.new(options) } - let(:logger_config) { instance_double('Guard::UI::Logger::Config') } + let(:logger_config) { instance_double("Guard::UI::Logger::Config") } before do allow(Guard::UI::Logger::Config).to receive(:new) .and_return(logger_config) end - context 'with defaults' do - it 'provides a logger config' do + context "with defaults" do + it "provides a logger config" do expect(subject.logger_config).to be(logger_config) end end - context 'with deprecated options set' do - context 'when set using a string' do - subject { described_class.new('time_format': 'foo') } + context "with deprecated options set" do + context "when set using a string" do + subject { described_class.new('time_format': "foo") } - it 'passes deprecated options to logger' do + it "passes deprecated options to logger" do expect(Guard::UI::Logger::Config).to receive(:new) - .with(time_format: 'foo') + .with(time_format: "foo") subject end - it 'provides a logger config' do + it "provides a logger config" do expect(subject.logger_config).to be(logger_config) end end - context 'when set using a symbol' do - let(:options) { { time_format: 'foo' } } + context "when set using a symbol" do + let(:options) { { time_format: "foo" } } - it 'passes deprecated options to logger' do + it "passes deprecated options to logger" do expect(Guard::UI::Logger::Config).to receive(:new) - .with(time_format: 'foo') + .with(time_format: "foo") subject end - it 'provides a logger config' do + it "provides a logger config" do expect(subject.logger_config).to be(logger_config) end end diff --git a/spec/lib/guard/ui/logger_spec.rb b/spec/lib/guard/ui/logger_spec.rb index add017ac4..1374f05b9 100644 --- a/spec/lib/guard/ui/logger_spec.rb +++ b/spec/lib/guard/ui/logger_spec.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true -require 'guard/ui/logger' +require "guard/ui/logger" RSpec.describe Guard::UI::Logger::Config do - describe 'defaults' do - it 'flushes device by default' do + describe "defaults" do + it "flushes device by default" do expect(subject[:flush_seconds]).to eq(0) end end - describe '#level=' do - context 'with a valid value' do + describe "#level=" do + context "with a valid value" do before do subject.level = Logger::WARN end - it 'stores the level' do + it "stores the level" do expect(subject[:level]).to eq(Logger::WARN) - expect(subject['level']).to eq(Logger::WARN) + expect(subject["level"]).to eq(Logger::WARN) end end end diff --git a/spec/lib/guard/ui_spec.rb b/spec/lib/guard/ui_spec.rb index de1b4cb5b..e70594b37 100644 --- a/spec/lib/guard/ui_spec.rb +++ b/spec/lib/guard/ui_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'guard/notifier' +require "guard/notifier" # NOTE: this is here so that no UI does not require anything, # since it could be activated by guard plugins during development @@ -8,28 +8,28 @@ # # TODO: regardless, the dependency on Guard.state should be removed # -require 'guard/ui' +require "guard/ui" -require 'guard/internals/session' +require "guard/internals/session" RSpec.describe Guard::UI do - let(:interactor) { instance_double('Guard::Interactor') } - let(:logger) { instance_double('Lumberjack::Logger') } - let(:config) { instance_double('Guard::UI::Config') } - let(:logger_config) { instance_double('Guard::UI::Logger::Config') } + let(:interactor) { instance_double("Guard::Interactor") } + let(:logger) { instance_double("Lumberjack::Logger") } + let(:config) { instance_double("Guard::UI::Config") } + let(:logger_config) { instance_double("Guard::UI::Logger::Config") } - let(:terminal) { class_double('Guard::Terminal') } + let(:terminal) { class_double("Guard::Terminal") } - let(:session) { instance_double('Guard::Internals::Session') } - let(:state) { instance_double('Guard::Internals::State') } - let(:scope) { instance_double('Guard::Internals::Scope') } + let(:session) { instance_double("Guard::Internals::Session") } + let(:state) { instance_double("Guard::Internals::State") } + let(:scope) { instance_double("Guard::Internals::Scope") } before do allow(state).to receive(:scope).and_return(scope) allow(state).to receive(:session).and_return(session) allow(Guard).to receive(:state).and_return(state) - stub_const('Guard::Terminal', terminal) + stub_const("Guard::Terminal", terminal) allow(Guard::Notifier).to receive(:turn_on) {} @@ -69,19 +69,19 @@ Guard::UI.options = nil end - describe '.logger' do + describe ".logger" do before do allow(config).to receive(:device).and_return(device) end - context 'with no logger set yet' do - let(:device) { 'foo.log' } + context "with no logger set yet" do + let(:device) { "foo.log" } - it 'returns the logger instance' do + it "returns the logger instance" do expect(Guard::UI.logger).to be(logger) end - it 'sets the logger device' do + it "sets the logger device" do expect(Lumberjack::Logger).to receive(:new) .with(device, logger_config) @@ -90,13 +90,13 @@ end end - describe '.level=' do + describe ".level=" do before do allow(logger).to receive(:level=) allow(logger_config).to receive(:level=) end - context 'when logger is set up' do + context "when logger is set up" do before { Guard::UI.logger } it "sets the logger's level" do @@ -112,7 +112,7 @@ end end - context 'when logger is not set up yet' do + context "when logger is not set up yet" do before { Guard::UI.reset_logger } it "sets the logger's config level" do @@ -121,7 +121,7 @@ Guard::UI.level = level end - it 'does not autocreate the logger' do + it "does not autocreate the logger" do level = Logger::WARN expect(logger).to_not receive(:level=).with(level) Guard::UI.level = level @@ -129,8 +129,8 @@ end end - describe '.options=' do - let(:new_config) { instance_double('Guard::UI::Config') } + describe ".options=" do + let(:new_config) { instance_double("Guard::UI::Config") } before do allow(Guard::UI::Config).to receive(:new).with(hi: :ho) @@ -139,101 +139,101 @@ allow(new_config).to receive(:[]).with(:hi).and_return(:ho) end - it 'sets the logger options' do + it "sets the logger options" do Guard::UI.options = { hi: :ho } expect(Guard::UI.options[:hi]).to eq :ho end end - shared_examples_for 'a logger method' do - it 'resets the line with the :reset option' do + shared_examples_for "a logger method" do + it "resets the line with the :reset option" do expect(Guard::UI).to receive :reset_line Guard::UI.send(ui_method, input, reset: true) end - it 'logs the message with the given severity' do + it "logs the message with the given severity" do expect(logger).to receive(severity).with(output) Guard::UI.send(ui_method, input) end - context 'with the :only option' do + context "with the :only option" do before { allow(config).to receive(:only).and_return(/A/) } - it 'allows logging matching messages' do + it "allows logging matching messages" do expect(logger).to receive(severity).with(output) - Guard::UI.send(ui_method, input, plugin: 'A') + Guard::UI.send(ui_method, input, plugin: "A") end - it 'prevents logging other messages' do + it "prevents logging other messages" do expect(logger).to_not receive(severity) - Guard::UI.send(ui_method, input, plugin: 'B') + Guard::UI.send(ui_method, input, plugin: "B") end end - context 'with the :except option' do + context "with the :except option" do before { allow(config).to receive(:except).and_return(/A/) } - it 'prevents logging matching messages' do + it "prevents logging matching messages" do expect(logger).to_not receive(severity) - Guard::UI.send(ui_method, input, plugin: 'A') + Guard::UI.send(ui_method, input, plugin: "A") end - it 'allows logging other messages' do + it "allows logging other messages" do expect(logger).to receive(severity).with(output) - Guard::UI.send(ui_method, input, plugin: 'B') + Guard::UI.send(ui_method, input, plugin: "B") end end end - describe '.info' do - it_behaves_like 'a logger method' do + describe ".info" do + it_behaves_like "a logger method" do let(:ui_method) { :info } let(:severity) { :info } - let(:input) { 'Info' } - let(:output) { 'Info' } + let(:input) { "Info" } + let(:output) { "Info" } end end - describe '.warning' do - it_behaves_like 'a logger method' do + describe ".warning" do + it_behaves_like "a logger method" do let(:ui_method) { :warning } let(:severity) { :warn } - let(:input) { 'Warning' } + let(:input) { "Warning" } let(:output) { "\e[0;33mWarning\e[0m" } end end - describe '.error' do - it_behaves_like 'a logger method' do + describe ".error" do + it_behaves_like "a logger method" do let(:ui_method) { :error } let(:severity) { :error } - let(:input) { 'Error' } + let(:input) { "Error" } let(:output) { "\e[0;31mError\e[0m" } end end - describe '.deprecation' do + describe ".deprecation" do before do - allow(ENV).to receive(:[]).with('GUARD_GEM_SILENCE_DEPRECATIONS') + allow(ENV).to receive(:[]).with("GUARD_GEM_SILENCE_DEPRECATIONS") .and_return(value) end - context 'with GUARD_GEM_SILENCE_DEPRECATIONS set to 1' do - let(:value) { '1' } + context "with GUARD_GEM_SILENCE_DEPRECATIONS set to 1" do + let(:value) { "1" } - it 'silences deprecations' do + it "silences deprecations" do expect(Guard::UI.logger).to_not receive(:warn) - Guard::UI.deprecation 'Deprecator message' + Guard::UI.deprecation "Deprecator message" end end - context 'with GUARD_GEM_SILENCE_DEPRECATIONS unset' do + context "with GUARD_GEM_SILENCE_DEPRECATIONS unset" do let(:value) { nil } - it_behaves_like 'a logger method' do + it_behaves_like "a logger method" do let(:ui_method) { :deprecation } let(:severity) { :warn } - let(:input) { 'Deprecated' } + let(:input) { "Deprecated" } let(:output) do /^\e\[0;33mDeprecated\nDeprecation backtrace: .*\e\[0m$/m end @@ -241,55 +241,55 @@ end end - describe '.debug' do - it_behaves_like 'a logger method' do + describe ".debug" do + it_behaves_like "a logger method" do let(:ui_method) { :debug } let(:severity) { :debug } - let(:input) { 'Debug' } + let(:input) { "Debug" } let(:output) { "\e[0;33mDebug\e[0m" } end end - describe '.clear' do - context 'with UI set up and ready' do + describe ".clear" do + context "with UI set up and ready" do before do allow(session).to receive(:clear?).and_return(false) Guard::UI.reset_and_clear end - context 'when clear option is disabled' do - it 'does not clear the output' do + context "when clear option is disabled" do + it "does not clear the output" do expect(terminal).to_not receive(:clear) Guard::UI.clear end end - context 'when clear option is enabled' do + context "when clear option is enabled" do before do allow(session).to receive(:clear?).and_return(true) end - context 'when the screen is marked as needing clearing' do + context "when the screen is marked as needing clearing" do before { Guard::UI.clearable } - it 'clears the output' do + it "clears the output" do expect(terminal).to receive(:clear) Guard::UI.clear end - it 'clears the output only once' do + it "clears the output only once" do expect(terminal).to receive(:clear).once Guard::UI.clear Guard::UI.clear end - context 'when the command fails' do + context "when the command fails" do before do allow(terminal).to receive(:clear) - .and_raise(Errno::ENOENT, 'failed to run command') + .and_raise(Errno::ENOENT, "failed to run command") end - it 'shows a warning' do + it "shows a warning" do expect(logger).to receive(:warn) do |arg| expect(arg).to match(/failed to run command/) end @@ -298,18 +298,18 @@ end end - context 'when the screen has just been cleared' do + context "when the screen has just been cleared" do before { Guard::UI.clear } - it 'does not clear' do + it "does not clear" do expect(terminal).to_not receive(:clear) Guard::UI.clear end - context 'when forced' do + context "when forced" do let(:opts) { { force: true } } - it 'clears the outputs if forced' do + it "clears the outputs if forced" do expect(terminal).to receive(:clear) Guard::UI.clear(opts) end @@ -319,45 +319,45 @@ end end - describe '.action_with_scopes' do - let(:rspec) { double('Rspec', title: 'Rspec') } - let(:jasmine) { double('Jasmine', title: 'Jasmine') } - let(:group) { instance_double('Guard::Group', title: 'Frontend') } + describe ".action_with_scopes" do + let(:rspec) { double("Rspec", title: "Rspec") } + let(:jasmine) { double("Jasmine", title: "Jasmine") } + let(:group) { instance_double("Guard::Group", title: "Frontend") } - context 'with a plugins scope' do - it 'shows the plugin scoped action' do + 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]) - expect(Guard::UI).to receive(:info).with('Reload Rspec, Jasmine') - Guard::UI.action_with_scopes('Reload', plugins: [rspec, jasmine]) + expect(Guard::UI).to receive(:info).with("Reload Rspec, Jasmine") + Guard::UI.action_with_scopes("Reload", plugins: [rspec, jasmine]) end end - context 'with a groups scope' do - it 'shows the group scoped action' do + 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]) - expect(Guard::UI).to receive(:info).with('Reload Frontend') - Guard::UI.action_with_scopes('Reload', groups: [group]) + expect(Guard::UI).to receive(:info).with("Reload Frontend") + Guard::UI.action_with_scopes("Reload", groups: [group]) end end - context 'without a scope' do - context 'with a global plugin scope' do - it 'shows the global plugin scoped action' do + 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]) - expect(Guard::UI).to receive(:info).with('Reload Rspec, Jasmine') - Guard::UI.action_with_scopes('Reload', {}) + expect(Guard::UI).to receive(:info).with("Reload Rspec, Jasmine") + Guard::UI.action_with_scopes("Reload", {}) end end - context 'with a global group scope' do - it 'shows the global group scoped action' do + context "with a global group scope" do + it "shows the global group scoped action" do allow(scope).to receive(:titles).and_return(%w[Frontend]) - expect(Guard::UI).to receive(:info).with('Reload Frontend') - Guard::UI.action_with_scopes('Reload', {}) + expect(Guard::UI).to receive(:info).with("Reload Frontend") + Guard::UI.action_with_scopes("Reload", {}) end end end diff --git a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb index d26364ca0..4debd5fee 100644 --- a/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb +++ b/spec/lib/guard/watcher/pattern/deprecated_regexp_spec.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true -require 'guard/watcher/pattern/deprecated_regexp' +require "guard/watcher/pattern/deprecated_regexp" RSpec.describe Guard::Watcher::Pattern::DeprecatedRegexp do - describe '.deprecated?' do - specify { expect(described_class.new('^spec_helper.rb')).to be_deprecated } - specify { expect(described_class.new('spec_helper.rb$')).to be_deprecated } + describe ".deprecated?" do + specify { expect(described_class.new("^spec_helper.rb")).to be_deprecated } + specify { expect(described_class.new("spec_helper.rb$")).to be_deprecated } end - describe 'Matcher returned by .convert' do + describe "Matcher returned by .convert" do let(:matcher) { Guard::Watcher::Pattern::Matcher } before { allow(matcher).to receive(:new) } { - '^foo.rb' => /^foo.rb/, - 'foo.rb$' => /foo.rb$/, + "^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 fd72f8543..19d965adb 100644 --- a/spec/lib/guard/watcher/pattern/match_result_spec.rb +++ b/spec/lib/guard/watcher/pattern/match_result_spec.rb @@ -1,46 +1,46 @@ # frozen_string_literal: true -require 'guard/watcher/pattern/match_result' +require "guard/watcher/pattern/match_result" RSpec.describe Guard::Watcher::Pattern::MatchResult do - let(:match_result) { double('match_data') } - let(:original_value) { 'foo/bar.rb' } + let(:match_result) { double("match_data") } + let(:original_value) { "foo/bar.rb" } subject { described_class.new(match_result, original_value) } - describe '#initialize' do - context 'with valid arguments' do - it 'does not fail' do + describe "#initialize" do + context "with valid arguments" do + it "does not fail" do expect { subject }.to_not raise_error end end end - describe '#[]' do - context 'with a valid match' do - let(:match_result) { double('match_data', to_a: %w[foo bar baz]) } + describe "#[]" do + context "with a valid match" do + let(:match_result) { double("match_data", to_a: %w[foo bar baz]) } - context 'when asked for the non-first item' do + context "when asked for the non-first item" do let(:index) { 1 } - it 'returns the value at given index' do - expect(subject[index]).to eq('bar') + it "returns the value at given index" do + expect(subject[index]).to eq("bar") end end - context 'when asked for the first item' do + context "when asked for the first item" do let(:index) { 0 } - it 'returns the full original value' do - expect(subject[index]).to eq('foo/bar.rb') + it "returns the full original value" do + expect(subject[index]).to eq("foo/bar.rb") end end - context 'when asked for a name match via a symbol' do + context "when asked for a name match via a symbol" do let(:index) { :foo } before do - allow(match_result).to receive(:[]).with(:foo).and_return('baz') + allow(match_result).to receive(:[]).with(:foo).and_return("baz") end - it 'returns the value by name' do - expect(subject[index]).to eq('baz') + it "returns the value by name" do + expect(subject[index]).to eq("baz") end end end diff --git a/spec/lib/guard/watcher/pattern/matcher_spec.rb b/spec/lib/guard/watcher/pattern/matcher_spec.rb index 46d233d4b..b156803f5 100644 --- a/spec/lib/guard/watcher/pattern/matcher_spec.rb +++ b/spec/lib/guard/watcher/pattern/matcher_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'guard/watcher/pattern/matcher' +require "guard/watcher/pattern/matcher" RSpec.describe Guard::Watcher::Pattern::Matcher do subject { described_class.new(obj) } - describe '#match' do - let(:expected) { double('match_result') } + describe "#match" do + let(:expected) { double("match_result") } - context 'when constructed with valid matcher object' do - let(:obj) { double('matcher') } + context "when constructed with valid matcher object" do + let(:obj) { double("matcher") } - context 'when matched against a Pathname' do + context "when matched against a Pathname" do before do allow(obj).to receive(:match).and_return(expected) end - let(:filename) { Pathname('foo.rb') } + let(:filename) { Pathname("foo.rb") } - it 'returns the match result' do + it "returns the match result" do expect(subject.match(filename)).to be(expected) end - it 'passes the Pathname to the matcher' do + it "passes the Pathname to the matcher" do allow(obj).to receive(:match).with(filename) subject.match(filename) end end - context 'when matched against a String' do + context "when matched against a String" do before do allow(obj).to receive(:match).and_return(expected) end - let(:filename) { 'foo.rb' } + let(:filename) { "foo.rb" } - it 'returns the match result' do + it "returns the match result" do expect(subject.match(filename)).to be(expected) end - it 'passes a Pathname to the matcher' do + it "passes a Pathname to the matcher" do allow(obj).to receive(:match).with(Pathname(filename)) subject.match(filename) end @@ -44,51 +44,51 @@ end end - describe '#==' do - it 'returns true for equal matchers' do + describe "#==" do + it "returns true for equal matchers" do expect(described_class.new(/spec_helper\.rb/)) .to eq(described_class.new(/spec_helper\.rb/)) end - it 'returns false for unequal matchers' do + it "returns false for unequal matchers" do expect(described_class.new(/spec_helper\.rb/)) .not_to eq(described_class.new(/spec_helper\.r/)) end end - describe 'integration' do - describe '#match result' do + describe "integration" do + describe "#match result" do subject { described_class.new(obj).match(filename) } - context 'when constructed with valid regexp' do + context "when constructed with valid regexp" do let(:obj) { /foo.rb$/ } - context 'when matched file is a string' do - context 'when filename matches' do - let(:filename) { 'foo.rb' } - specify { expect(subject.to_a).to eq(['foo.rb']) } + context "when matched file is a string" do + context "when filename matches" do + let(:filename) { "foo.rb" } + specify { expect(subject.to_a).to eq(["foo.rb"]) } end - context 'when filename does not match' do - let(:filename) { 'bar.rb' } + context "when filename does not match" do + let(:filename) { "bar.rb" } specify { expect(subject).to be_nil } end end - context 'when matched file is an unclean Pathname' do - context 'when filename matches' do - let(:filename) { Pathname('./foo.rb') } - specify { expect(subject.to_a).to eq(['foo.rb']) } + context "when matched file is an unclean Pathname" do + context "when filename matches" do + let(:filename) { Pathname("./foo.rb") } + specify { expect(subject.to_a).to eq(["foo.rb"]) } end - context 'when filename does not match' do - let(:filename) { Pathname('./bar.rb') } + context "when filename does not match" do + let(:filename) { Pathname("./bar.rb") } specify { expect(subject).to be_nil } end end - context 'when matched file contains a $' do - let(:filename) { Pathname('lib$/foo.rb') } - specify { expect(subject.to_a).to eq(['foo.rb']) } + context "when matched file contains a $" do + let(:filename) { Pathname("lib$/foo.rb") } + specify { expect(subject.to_a).to eq(["foo.rb"]) } end 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 578ed45af..63e665533 100644 --- a/spec/lib/guard/watcher/pattern/pathname_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/pathname_path_spec.rb @@ -1,34 +1,34 @@ # frozen_string_literal: true -require 'guard/watcher/pattern/pathname_path' +require "guard/watcher/pattern/pathname_path" RSpec.describe Guard::Watcher::Pattern::PathnamePath do subject { described_class.new(path) } - describe '#match result' do + describe "#match result" do subject { described_class.new(path).match(filename) } - context 'when constructed with an unclean Pathname' do - let(:path) { Pathname('./foo.rb') } + context "when constructed with an unclean Pathname" do + let(:path) { Pathname("./foo.rb") } - context 'when matched file is a string' do - context 'when filename matches' do - let(:filename) { 'foo.rb' } - specify { expect(subject).to eq([Pathname('foo.rb')]) } + context "when matched file is a string" do + context "when filename matches" do + let(:filename) { "foo.rb" } + specify { expect(subject).to eq([Pathname("foo.rb")]) } end - context 'when filename does not match' do - let(:filename) { 'bar.rb' } + context "when filename does not match" do + let(:filename) { "bar.rb" } specify { expect(subject).to be_nil } end end - context 'when matched file is an unclean Pathname' do - context 'when filename matches' do - let(:filename) { Pathname('./foo.rb') } - specify { expect(subject).to eq([Pathname('foo.rb')]) } + context "when matched file is an unclean Pathname" do + context "when filename matches" do + let(:filename) { Pathname("./foo.rb") } + specify { expect(subject).to eq([Pathname("foo.rb")]) } end - context 'when filename does not match' do - let(:filename) { Pathname('./bar.rb') } + context "when filename does not match" do + let(:filename) { Pathname("./bar.rb") } specify { expect(subject).to be_nil } end end diff --git a/spec/lib/guard/watcher/pattern/simple_path_spec.rb b/spec/lib/guard/watcher/pattern/simple_path_spec.rb index 7d35c65ea..491525be0 100644 --- a/spec/lib/guard/watcher/pattern/simple_path_spec.rb +++ b/spec/lib/guard/watcher/pattern/simple_path_spec.rb @@ -1,34 +1,34 @@ # frozen_string_literal: true -require 'guard/watcher/pattern/simple_path' +require "guard/watcher/pattern/simple_path" RSpec.describe Guard::Watcher::Pattern::SimplePath do subject { described_class.new(path) } - describe '#match result' do - context 'when constructed with filename string' do - let(:path) { 'foo.rb' } + describe "#match result" do + context "when constructed with filename string" do + let(:path) { "foo.rb" } - context 'when matched file is a string' do - context 'when filename matches' do - let(:filename) { 'foo.rb' } - specify { expect(subject.match(filename)).to eq(['foo.rb']) } + context "when matched file is a string" do + context "when filename matches" do + let(:filename) { "foo.rb" } + specify { expect(subject.match(filename)).to eq(["foo.rb"]) } end - context 'when filename does not match' do - let(:filename) { 'bar.rb' } + context "when filename does not match" do + let(:filename) { "bar.rb" } specify { expect(subject.match(filename)).to be_nil } end end - context 'when matched file is an unclean Pathname' do - context 'when filename matches' do - let(:filename) { Pathname('./foo.rb') } - specify { expect(subject.match(filename)).to eq(['foo.rb']) } + context "when matched file is an unclean Pathname" do + context "when filename matches" do + let(:filename) { Pathname("./foo.rb") } + specify { expect(subject.match(filename)).to eq(["foo.rb"]) } end - context 'when filename does not match' do - let(:filename) { Pathname('./bar.rb') } + context "when filename does not match" do + let(:filename) { Pathname("./bar.rb") } specify { expect(subject.match(filename)).to be_nil } end end diff --git a/spec/lib/guard/watcher/pattern_spec.rb b/spec/lib/guard/watcher/pattern_spec.rb index 03cd5f38e..9f83e1844 100644 --- a/spec/lib/guard/watcher/pattern_spec.rb +++ b/spec/lib/guard/watcher/pattern_spec.rb @@ -1,37 +1,37 @@ # frozen_string_literal: true -require 'guard/watcher/pattern' +require "guard/watcher/pattern" RSpec.describe Guard::Watcher::Pattern do - describe '.create' do + describe ".create" do subject { described_class.create(pattern) } - context 'when a string is given' do - let(:pattern) { 'foo.rb' } + context "when a string is given" do + let(:pattern) { "foo.rb" } it { is_expected.to be_a(described_class::SimplePath) } end - context 'when a Pathname is given' do - let(:pattern) { Pathname('foo.rb') } + context "when a Pathname is given" do + let(:pattern) { Pathname("foo.rb") } it { is_expected.to be_a(described_class::PathnamePath) } end - context 'when an regexp string is given' do - let(:pattern) { '^foo.*$' } + context "when an regexp string is given" do + let(:pattern) { "^foo.*$" } it { is_expected.to be_a(described_class::Matcher) } - it 'shows a warning' do + it "shows a warning" do expect(described_class::DeprecatedRegexp) .to receive(:show_deprecation).with(pattern) subject end end - context 'when a regexp is given' do + context "when a regexp is given" do let(:pattern) { /foo\.rb/ } it { is_expected.to be_a(described_class::Matcher) } end - context 'when a custom matcher' do + context "when a custom matcher" do let(:pattern) { Class.new { def match; end } } it { is_expected.to be_a(described_class::Matcher) } end diff --git a/spec/lib/guard/watcher_spec.rb b/spec/lib/guard/watcher_spec.rb index 39cf3ec25..a044f07a9 100644 --- a/spec/lib/guard/watcher_spec.rb +++ b/spec/lib/guard/watcher_spec.rb @@ -1,213 +1,213 @@ # frozen_string_literal: true -require 'guard/watcher' +require "guard/watcher" # TODO: shouldn't be needed -require 'guard/guardfile/evaluator' +require "guard/guardfile/evaluator" RSpec.describe Guard::Watcher do let(:args) { [] } subject { described_class.new(*args) } - describe '#initialize' do - context 'with no arguments' do + describe "#initialize" do + context "with no arguments" do let(:args) { [] } - it 'raises an error' do + it "raises an error" do expect { subject }.to raise_error(ArgumentError) end end - context 'with a pattern parameter' do - let(:pattern) { ['spec_helper.rb'] } + context "with a pattern parameter" do + let(:pattern) { ["spec_helper.rb"] } let(:args) { [pattern] } - it 'creates a matcher' do + it "creates a matcher" do expect(described_class::Pattern).to receive(:create).with(pattern) subject end end end - describe '#action' do - it 'sets the action to nothing by default' do + describe "#action" do + it "sets the action to nothing by default" do expect(described_class.new(/spec_helper\.rb/).action).to be_nil end - it 'sets the action to the supplied block' do + it "sets the action to the supplied block" do action = ->(m) { "spec/#{m[1]}_spec.rb" } expect(described_class.new(%r{^lib/(.*).rb}, action).action).to eq action end end - describe '#==' do - it 'returns true for equal watchers' do + describe "#==" do + it "returns true for equal watchers" do expect(described_class.new(/spec_helper\.rb/)) .to eq(described_class.new(/spec_helper\.rb/)) end - it 'returns false for unequal watchers' do + it "returns false for unequal watchers" do expect(described_class.new(/spec_helper\.rb/)) .not_to eq(described_class.new(/spec_helper\.r/)) end end - describe '.match_files' do - let(:plugin) { instance_double('Guard::Plugin', options: {}) } + describe ".match_files" do + let(:plugin) { instance_double("Guard::Plugin", options: {}) } def matched(files) described_class.match_files(plugin, files) end - context 'without a watcher action' do + context "without a watcher action" do before do allow(plugin).to receive(:watchers) .and_return([described_class.new(pattern)]) end - context 'with a regex pattern' do + context "with a regex pattern" do let(:pattern) { /.*_spec\.rb/ } - it 'returns the paths that matches the regex' do + it "returns the paths that matches the regex" do 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'] + 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"] end end end - context 'with a watcher action without parameter' do - context 'for a watcher that matches file strings' do + context "with a watcher action without parameter" do + context "for a watcher that matches file strings" do before do klass = described_class allow(plugin).to receive(:watchers).and_return( [ - 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('blank.rb', -> { '' }), - klass.new(/^uptime\.rb/, -> { '' }) + 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("blank.rb", -> { "" }), + klass.new(/^uptime\.rb/, -> { "" }) ] ) end - it 'returns a single file specified within the action' do - expect(matched(%w[spec_helper.rb])).to eq ['spec'] + it "returns a single file specified within the action" do + expect(matched(%w[spec_helper.rb])).to eq ["spec"] end - it 'returns multiple files specified within the action' do + it "returns multiple files specified within the action" do expect(matched(%w[hash.rb])).to eq %w[foo bar] end - it 'combines files from results of different actions' do + it "combines files from results of different actions" do 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 + context "when action returns non-string or array of non-strings" do + it "returns nothing" do expect(matched(%w[addition.rb])).to eq [] end end - it 'returns nothing if the action response is empty' do + it "returns nothing if the action response is empty" do expect(matched(%w[blank.rb])).to eq [] end - it 'returns nothing if the action returns nothing' do + it "returns nothing if the action returns nothing" do expect(matched(%w[uptime.rb])).to eq [] end end - context 'for a watcher that matches information objects' do + context "for a watcher that matches information objects" do before do allow(plugin).to receive(:options).and_return(any_return: true) klass = described_class allow(plugin).to receive(:watchers).and_return( [ - 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('blank.rb', -> { '' }), - klass.new(/^uptime\.rb/, -> { '' }) + 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("blank.rb", -> { "" }), + klass.new(/^uptime\.rb/, -> { "" }) ] ) end - it 'returns a single file specified within the action' do + 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 end - it 'returns multiple files specified within the action' do - expect(matched(%w[hash.rb])).to eq [{ foo: 'bar' }] + it "returns multiple files specified within the action" do + expect(matched(%w[hash.rb])).to eq [{ foo: "bar" }] end - it 'combines the results of different actions' do + it "combines the results of different actions" do expect(matched(%w[spec_helper.rb array.rb])) - .to eq ['spec', %w[foo bar]] + .to eq ["spec", %w[foo bar]] end - it 'returns the evaluated addition argument in an array' do + 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 end - it 'returns nothing if the action response is empty string' do - expect(matched(%w[blank.rb])).to eq [''] + it "returns nothing if the action response is empty string" do + 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 [''] + it "returns nothing if the action returns empty string" do + expect(matched(%w[uptime.rb])).to eq [""] end end end - context 'with a watcher action that takes a parameter' do - context 'for a watcher that matches file strings' do + context "with a watcher action that takes a parameter" do + context "for a watcher that matches file strings" do before do klass = described_class allow(plugin).to receive(:watchers).and_return [ 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("hash.rb", ->(_m) { Hash[:foo, "bar"] }), klass.new(/array(.*)\.rb/, ->(_m) { %w[foo bar] }), - klass.new(/blank(.*)\.rb/, ->(_m) { '' }), - klass.new(/^uptime\.rb/, -> { '' }) + 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'] + it "returns a substituted single file specified within the action" do + expect(matched(%w[lib/foo.rb])).to eq ["spec/foo_spec.rb"] end - it 'returns multiple files specified within the action' do + it "returns multiple files specified within the action" do expect(matched(%w[hash.rb])).to eq %w[foo bar] end - it 'combines results of different actions' do + it "combines results of different actions" do 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 + it "returns nothing if action returns non-string or non-string array" do expect(matched(%w[addition.rb])).to eq [] end - it 'returns nothing if the action response is empty' do + it "returns nothing if the action response is empty" do expect(matched(%w[blank.rb])).to eq [] end - it 'returns nothing if the action returns nothing' do + it "returns nothing if the action returns nothing" do expect(matched(%w[uptime.rb])).to eq [] end end - context 'for a watcher that matches information objects' do + context "for a watcher that matches information objects" do before do allow(plugin).to receive(:options).and_return(any_return: true) @@ -216,96 +216,96 @@ def matched(files) [ kl.new(%r{lib/(.*)\.rb}, ->(m) { "spec/#{m[1]}_spec.rb" }), kl.new(/addition(.*)\.rb/, ->(m) { (1 + 1).to_s + m[0] }), - kl.new('hash.rb', ->(m) { { foo: 'bar', file_name: m[0] } }), - kl.new(/array(.*)\.rb/, ->(m) { ['foo', 'bar', m[0]] }), - kl.new(/blank(.*)\.rb/, ->(_m) { '' }), - kl.new(/^uptime\.rb/, -> { '' }) + kl.new("hash.rb", ->(m) { { foo: "bar", file_name: m[0] } }), + kl.new(/array(.*)\.rb/, ->(m) { ["foo", "bar", m[0]] }), + kl.new(/blank(.*)\.rb/, ->(_m) { "" }), + kl.new(/^uptime\.rb/, -> { "" }) ] ) end - it 'returns a substituted single file specified within the action' do + it "returns a substituted single file specified within the action" do expect(matched(%w[lib/foo.rb])).to eq %w[spec/foo_spec.rb] end - it 'returns a hash specified within the action' do + it "returns a hash specified within the action" do expect(matched(%w[hash.rb])).to eq [ - { foo: 'bar', file_name: 'hash.rb' } + { foo: "bar", file_name: "hash.rb" } ] end - it 'combinines results of different actions' do + 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]] + .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'] + it "returns the evaluated addition argument + the path" do + 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 [''] + it "returns nothing if the action response is empty string" do + 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 [''] + it "returns nothing if the action returns is IO::NULL" do + expect(matched(%w[uptime.rb])).to eq [""] end end end - context 'with an exception that is raised' do + context "with an exception that is raised" do before do allow(plugin).to receive(:watchers).and_return( - [described_class.new('evil.rb', -> { fail 'EVIL' })] + [described_class.new("evil.rb", -> { fail "EVIL" })] ) end - it 'displays the error and backtrace' do + it "displays the error and backtrace" do expect(Guard::UI).to receive(:error) do |msg| - expect(msg).to include('Problem with watch action!') - expect(msg).to include('EVIL') + expect(msg).to include("Problem with watch action!") + expect(msg).to include("EVIL") end - described_class.match_files(plugin, ['evil.rb']) + described_class.match_files(plugin, ["evil.rb"]) end end - context 'for ambiguous watchers' do + context "for ambiguous watchers" do before do 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("awesome_helper.rb", -> {}), + described_class.new(/.+some_helper.rb/, -> { "foo.rb" }), + described_class.new(/.+_helper.rb/, -> { "bar.rb" }) ] end - context 'when the :first_match option is turned off' do + context "when the :first_match option is turned off" do before do allow(plugin).to receive(:options).and_return(first_match: false) end - it 'returns multiple files by combining the results of the watchers' do + it "returns multiple files by combining the results of the watchers" do expect(described_class.match_files( - plugin, ['awesome_helper.rb'] - )).to eq(['foo.rb', 'bar.rb']) + plugin, ["awesome_helper.rb"] + )).to eq(["foo.rb", "bar.rb"]) end end - context 'when the :first_match option is turned on' do + context "when the :first_match option is turned on" do before do plugin.options[:first_match] = true end - it 'returns only the files from the first watcher' do + it "returns only the files from the first watcher" do expect(described_class.match_files( - plugin, ['awesome_helper.rb'] - )).to eq(['foo.rb']) + plugin, ["awesome_helper.rb"] + )).to eq(["foo.rb"]) end end end end - describe '#match' do + describe "#match" do subject { described_class.new(pattern).match(file) } let(:matcher) { instance_double(described_class::Pattern::Matcher) } @@ -322,20 +322,20 @@ def matched(files) .with(match_data, file).and_return(match) end - context 'with a valid pattern' do - let(:pattern) { 'foo.rb' } - context 'with a valid file name to match' do - let(:file) { 'foo.rb' } - context 'when matching is successful' do - let(:match_data) { double('match data', to_a: ['foo']) } - it 'returns the match result' do + context "with a valid pattern" do + let(:pattern) { "foo.rb" } + context "with a valid file name to match" do + let(:file) { "foo.rb" } + context "when matching is successful" do + let(:match_data) { double("match data", to_a: ["foo"]) } + it "returns the match result" do expect(subject).to be(match) end end - context 'when matching is not successful' do + context "when matching is not successful" do let(:match_data) { nil } - it 'returns nil' do + it "returns nil" do expect(subject).to be_nil end end @@ -343,20 +343,20 @@ def matched(files) end end - describe 'integration' do - describe '#match' do + describe "integration" do + describe "#match" do subject { described_class.new(pattern) } - context 'with a named regexp pattern' do + context "with a named regexp pattern" do let(:pattern) { /(?.*)_spec\.rb/ } - context 'with a watcher that matches a file' do + context "with a watcher that matches a file" do specify do - expect(subject.match('bar_spec.rb')[0]).to eq('bar_spec.rb') - expect(subject.match('bar_spec.rb')[1]).to eq('bar') + expect(subject.match("bar_spec.rb")[0]).to eq("bar_spec.rb") + expect(subject.match("bar_spec.rb")[1]).to eq("bar") end - it 'provides the match by name' do - expect(subject.match('bar_spec.rb')[:foo]).to eq('bar') + it "provides the match by name" do + expect(subject.match("bar_spec.rb")[:foo]).to eq("bar") end end end diff --git a/spec/lib/guard_spec.rb b/spec/lib/guard_spec.rb index 004874b2c..79ded1c71 100644 --- a/spec/lib/guard_spec.rb +++ b/spec/lib/guard_spec.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true -require 'guard' +require "guard" RSpec.describe Guard do # Initialize before Guard::Interactor const is stubbed - let!(:interactor) { instance_double('Guard::Interactor') } + let!(:interactor) { instance_double("Guard::Interactor") } - let(:guardfile) { File.expand_path('Guardfile') } + let(:guardfile) { File.expand_path("Guardfile") } let(:traps) { Guard::Internals::Traps } - let(:evaluator) { instance_double('Guard::Guardfile::Evaluator') } + let(:evaluator) { instance_double("Guard::Guardfile::Evaluator") } - let(:plugins) { instance_double('Guard::Internals::Plugins') } - let(:scope) { instance_double('Guard::Internals::Scope') } - let(:session) { instance_double('Guard::Internals::Session') } - let(:state) { instance_double('Guard::Internals::State') } - let(:queue) { instance_double('Guard::Internals::Queue') } + let(:plugins) { instance_double("Guard::Internals::Plugins") } + let(:scope) { instance_double("Guard::Internals::Scope") } + let(:session) { instance_double("Guard::Internals::Session") } + let(:state) { instance_double("Guard::Internals::State") } + let(:queue) { instance_double("Guard::Internals::Queue") } before do allow(Guard::Interactor).to receive(:new).and_return(interactor) @@ -30,21 +30,21 @@ end # TODO: setup has too many responsibilities - describe '.setup' do + describe ".setup" do subject { Guard.setup(options) } let(:options) { { my_opts: true, guardfile: guardfile } } - let(:listener) { instance_double('Listen::Listener') } + let(:listener) { instance_double("Listen::Listener") } before do allow(Listen).to receive(:to).with(Dir.pwd, {}) { listener } - stub_guardfile(' ') + stub_guardfile(" ") stub_user_guard_rb - g1 = instance_double('Guard::Group', name: :common, options: {}) - g2 = instance_double('Guard::Group', name: :default, options: {}) + g1 = instance_double("Guard::Group", name: :common, options: {}) + g2 = instance_double("Guard::Group", name: :default, options: {}) allow(Guard::Group).to receive(:new).with(:common).and_return(g1) allow(Guard::Group).to receive(:new).with(:default).and_return(g2) @@ -73,59 +73,59 @@ allow(Guard::Internals::State).to receive(:new).and_return(state) end - it 'returns itself for chaining' do + it "returns itself for chaining" do expect(subject).to be Guard end - it 'initializes the listener' do + it "initializes the listener" do allow(Listen).to receive(:to) - .with('/foo', latency: 2, wait_for_delay: 1).and_return(listener) + .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 }] + [:to, "/foo", { latency: 2, wait_for_delay: 1 }] ) subject end - it 'initializes the interactor' do + it "initializes the interactor" do expect(Guard::Interactor).to receive(:new).with(false) subject end - context 'trapping signals' do + context "trapping signals" do before do allow(traps).to receive(:handle) end - it 'sets up USR1 trap for pausing' do - expect(traps).to receive(:handle).with('USR1') { |_, &b| b.call } + 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(%i[guard_pause paused]) subject end - it 'sets up USR2 trap for unpausing' do - expect(traps).to receive(:handle).with('USR2') { |_, &b| b.call } + 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(%i[guard_pause unpaused]) subject end - it 'sets up INT trap for cancelling or quitting interactor' do - expect(traps).to receive(:handle).with('INT') { |_, &b| b.call } + it "sets up INT trap for cancelling or quitting interactor" do + expect(traps).to receive(:handle).with("INT") { |_, &b| b.call } expect(interactor).to receive(:handle_interrupt) subject end end - it 'evaluates the Guardfile' do + it "evaluates the Guardfile" do expect(evaluator).to receive(:evaluate) allow(Guard::Guardfile::Evaluator).to receive(:new).and_return(evaluator) subject end - describe 'listener' do + describe "listener" do subject { listener } context "with ignores 'ignore(/foo/)' and 'ignore!(/bar/)'" do @@ -142,42 +142,42 @@ it { is_expected.to have_received(:ignore!).with([/bar/]) } end - context 'without ignores' do + context "without ignores" do before { Guard.setup(options) } it { is_expected.to_not have_received(:ignore) } it { is_expected.to_not have_received(:ignore!) } end end - it 'displays an error message when no guard are defined in Guardfile' do + 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.') + .with("No plugins found in Guardfile, please add at least one.") subject end - it 'connects to the notifier' do + it "connects to the notifier" do expect(Guard::Notifier).to receive(:connect).with(notify: true) subject end - context 'with the group option' do + context "with the group option" do let(:options) { { group: %w[frontend backend] } } - it 'passes options to session' do + it "passes options to session" do expect(Guard::Internals::State).to receive(:new).with(options) subject end end - context 'with the plugin option' do + context "with the plugin option" do let(:options) { { plugin: %w[cucumber jasmine] } } - it 'passes options to session' do + it "passes options to session" do expect(Guard::Internals::State).to receive(:new).with(options) subject end end - describe '.interactor' do + describe ".interactor" do subject { Guard::Interactor } before do @@ -185,53 +185,53 @@ Guard.setup(options) end - context 'with interactions enabled' do + context "with interactions enabled" do let(:type) { :pry_wrapper } let(:options) { { no_interactions: false } } it { is_expected.to have_received(:new).with(false) } end - context 'with interactions disabled' do + context "with interactions disabled" do let(:type) { :sleep } let(:options) { { no_interactions: true } } it { is_expected.to have_received(:new).with(true) } end end - describe 'UI' do + describe "UI" do subject { Guard::UI } - context 'when clearing is configured' do + context "when clearing is configured" do before { Guard.setup(options) } it { is_expected.to have_received(:reset_and_clear) } end end end - describe '._relative_pathname' do + describe "._relative_pathname" do subject { Guard.send(:_relative_pathname, raw_path) } - let(:pwd) { Pathname('/project') } + let(:pwd) { Pathname("/project") } before { allow(Pathname).to receive(:pwd).and_return(pwd) } - context 'with file in project directory' do - let(:raw_path) { '/project/foo' } - it { is_expected.to eq(Pathname('foo')) } + context "with file in project directory" do + let(:raw_path) { "/project/foo" } + it { is_expected.to eq(Pathname("foo")) } end - context 'with file within project' do - let(:raw_path) { '/project/spec/models/foo_spec.rb' } - it { is_expected.to eq(Pathname('spec/models/foo_spec.rb')) } + context "with file within project" do + let(:raw_path) { "/project/spec/models/foo_spec.rb" } + it { is_expected.to eq(Pathname("spec/models/foo_spec.rb")) } end - context 'with file in parent directory' do - let(:raw_path) { '/foo' } - it { is_expected.to eq(Pathname('../foo')) } + context "with file in parent directory" do + let(:raw_path) { "/foo" } + it { is_expected.to eq(Pathname("../foo")) } end - context 'with file on another drive (e.g. Windows)' do - let(:raw_path) { 'd:/project/foo' } + context "with file on another drive (e.g. Windows)" do + let(:raw_path) { "d:/project/foo" } let(:pathname) { instance_double(Pathname) } before do @@ -239,11 +239,11 @@ .with(pwd).and_raise(ArgumentError) end - it { is_expected.to eq(Pathname.new('d:/project/foo')) } + it { is_expected.to eq(Pathname.new("d:/project/foo")) } end end - describe '#relevant_changes?' do + describe "#relevant_changes?" do pending end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9a58caec3..2eed73d15 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,12 +18,12 @@ # users commonly want. # -require 'fileutils' +require "fileutils" -require 'simplecov' +require "simplecov" SimpleCov.start -ENV['GUARD_SPECS_RUNNING'] = '1' +ENV["GUARD_SPECS_RUNNING"] = "1" path = "#{File.expand_path(__dir__)}/support/**/*.rb" Dir[path].each { |f| require f } @@ -31,19 +31,19 @@ # TODO: these shouldn't be necessary with proper specs def stub_guardfile(contents = nil, &block) - stub_file(File.expand_path('Guardfile'), contents, &block) + stub_file(File.expand_path("Guardfile"), contents, &block) end def stub_user_guardfile(contents = nil, &block) - stub_file(File.expand_path('~/.Guardfile'), contents, &block) + stub_file(File.expand_path("~/.Guardfile"), contents, &block) end def stub_user_guard_rb(contents = nil, &block) - stub_file(File.expand_path('~/.guard.rb'), contents, &block) + stub_file(File.expand_path("~/.guard.rb"), contents, &block) end def stub_user_project_guardfile(contents = nil, &block) - stub_file(File.expand_path('.Guardfile'), contents, &block) + stub_file(File.expand_path(".Guardfile"), contents, &block) end def stub_mod(mod, excluded) @@ -116,7 +116,7 @@ def stub_file(path, contents = nil, &block) # `:focus` metadata. When nothing is tagged with `:focus`, all examples # get run. # config.filter_run :focus - config.filter_run focus: ENV['CI'] != 'true' + config.filter_run focus: ENV["CI"] != "true" config.run_all_when_everything_filtered = true @@ -170,7 +170,7 @@ def stub_file(path, contents = nil, &block) end config.before(:each) do |example| - stub_const('FileUtils', class_double(FileUtils)) + stub_const("FileUtils", class_double(FileUtils)) excluded = [] excluded += Array(example.metadata[:exclude_stubs]) @@ -213,25 +213,25 @@ def stub_file(path, contents = nil, &block) end # NOTE: call original, so we can run tests depending on this variable - allow(ENV).to receive(:[]).with('GUARD_STRICT').and_call_original + allow(ENV).to receive(:[]).with("GUARD_STRICT").and_call_original # FIXME: instead, properly stub PluginUtil in the evaluator specs! # and remove this! - allow(ENV).to receive(:[]).with('SPEC_OPTS').and_call_original + allow(ENV).to receive(:[]).with("SPEC_OPTS").and_call_original # FIXME: properly stub out Pry instead of this! - allow(ENV).to receive(:[]).with('ANSICON').and_call_original - allow(ENV).to receive(:[]).with('TERM').and_call_original + allow(ENV).to receive(:[]).with("ANSICON").and_call_original + allow(ENV).to receive(:[]).with("TERM").and_call_original # Needed for debugging - allow(ENV).to receive(:[]).with('DISABLE_PRY').and_call_original - allow(ENV).to receive(:[]).with('PRYRC').and_call_original - allow(ENV).to receive(:[]).with('PAGER').and_call_original + allow(ENV).to receive(:[]).with("DISABLE_PRY").and_call_original + allow(ENV).to receive(:[]).with("PRYRC").and_call_original + allow(ENV).to receive(:[]).with("PAGER").and_call_original # Workarounds for Cli inheriting from Thor - allow(ENV).to receive(:[]).with('ANSICON').and_call_original - allow(ENV).to receive(:[]).with('THOR_SHELL').and_call_original - allow(ENV).to receive(:[]).with('GEM_SKIP').and_call_original + allow(ENV).to receive(:[]).with("ANSICON").and_call_original + 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| allow(File).to receive(meth.to_sym).with(anything) do |*args, &_block| @@ -249,7 +249,7 @@ def stub_file(path, contents = nil, &block) allow_any_instance_of(Pathname) .to receive(meth.to_sym) do |*args, &_block| obj = args.first - formatted_args = args[1..-1].map(&:inspect).join(', ') + formatted_args = args[1..-1].map(&:inspect).join(", ") abort "stub me! (#{obj.inspect}##{meth}(#{formatted_args}))" end end @@ -258,7 +258,7 @@ def stub_file(path, contents = nil, &block) abort "stub me! (Dir#exist?(#{args.map(&:inspect) * ', '}))" end - if Guard.const_defined?('UI') && Guard::UI.respond_to?(:info) + if Guard.const_defined?("UI") && Guard::UI.respond_to?(:info) # Stub all UI methods, so no visible output appears for the UI class allow(Guard::UI).to receive(:info) allow(Guard::UI).to receive(:warning) @@ -272,7 +272,7 @@ def stub_file(path, contents = nil, &block) end # TODO: use metadata to stub out all used classes - if Guard.const_defined?('Sheller') + if Guard.const_defined?("Sheller") unless example.metadata[:sheller_specs] allow(Guard::Sheller).to receive(:run) do |*args| fail "stub for Sheller.run() called with: #{args.inspect}" diff --git a/spec/support/gems_helper.rb b/spec/support/gems_helper.rb index 09560a1f0..e196f0b84 100644 --- a/spec/support/gems_helper.rb +++ b/spec/support/gems_helper.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true def growl_installed? - require 'growl' + require "growl" true rescue LoadError false end def libnotify_installed? - require 'libnotify' + require "libnotify" true rescue LoadError false end def rbnotifu_installed? - require 'rb-notifu' + require "rb-notifu" true rescue LoadError false diff --git a/spec/support/platform_helper.rb b/spec/support/platform_helper.rb index ce5f53778..8acad17ca 100644 --- a/spec/support/platform_helper.rb +++ b/spec/support/platform_helper.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true def mac? - RbConfig::CONFIG['target_os'] =~ /darwin/i + RbConfig::CONFIG["target_os"] =~ /darwin/i end def linux? - RbConfig::CONFIG['target_os'] =~ /linux/i + RbConfig::CONFIG["target_os"] =~ /linux/i end def windows? - RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i + RbConfig::CONFIG["target_os"] =~ /mswin|mingw/i end From a804658277c9e98061b2edadb97df2d11f07b4f3 Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Tue, 18 Sep 2018 07:55:32 +0200 Subject: [PATCH 29/30] Trigger Hound NOOP commit because hound hangs. From b972242ee37e53dddf99d3f03fd796842717b23e Mon Sep 17 00:00:00 2001 From: Eduard Thamm Date: Tue, 18 Sep 2018 08:06:48 +0200 Subject: [PATCH 30/30] Auto correct: Style/StringLiterals in top level dir --- Gemfile | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Gemfile b/Gemfile index 3a0ecc728..6fccff982 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" -gemspec unless ENV['USE_INSTALLED_GUARD'] == '1' +gemspec unless ENV["USE_INSTALLED_GUARD"] == "1" -gem 'rake' +gem "rake" # The development group will not be # installed on Travis CI. @@ -17,18 +17,18 @@ group :development do # on HoundCI's side. # # See https://github.com/houndci/hound/issues/1250 - gem 'rubocop', '0.54.0', require: false + gem "rubocop", "0.54.0", require: false - gem 'guard-rubocop', require: false + gem "guard-rubocop", require: false - gem 'guard-ronn', require: false, platform: :mri - gem 'redcarpet', require: false, platform: :mri - gem 'yard', 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 - gem 'netrc', require: false, platform: :mri - gem 'octokit', require: false, platform: :mri + gem "gems", require: false, platform: :mri + gem "netrc", require: false, platform: :mri + gem "octokit", require: false, platform: :mri end # The test group will be @@ -36,22 +36,22 @@ end # group :test do # Both guard-rspec and guard-cucumber are used by cucumber features - gem 'guard-cucumber', '~> 2.1', require: false - gem 'guard-rspec', require: false + gem "guard-cucumber", "~> 2.1", require: false + gem "guard-rspec", 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 + 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 'json' - gem 'psych' - gem 'racc' - gem 'rubinius-coverage' - gem 'rubysl', '~> 2.0' + gem "json" + gem "psych" + gem "racc" + gem "rubinius-coverage" + gem "rubysl", "~> 2.0" end