Skip to content
Snippets Groups Projects
Commit 4a77fded authored by Eduard Thamm's avatar Eduard Thamm
Browse files

Auto correct: Style/StringLiterals

parent 215f8917
No related branches found
No related tags found
No related merge requests found
Showing
with 482 additions and 482 deletions
# frozen_string_literal: true
 
path = File.expand_path('../../../bin/guard', __dir__)
path = File.expand_path("../../../bin/guard", __dir__)
load path
 
RSpec.describe GuardReloader do
Loading
Loading
@@ -8,7 +8,7 @@ RSpec.describe GuardReloader do
 
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)
Loading
Loading
@@ -24,111 +24,111 @@ RSpec.describe GuardReloader do
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
Loading
Loading
# 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
Loading
Loading
# 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)
Loading
Loading
@@ -20,23 +20,23 @@ RSpec.describe Guard::Cli::Environments::EvaluateOnly do
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)
 
Loading
Loading
@@ -58,11 +58,11 @@ RSpec.describe Guard::Cli::Environments::EvaluateOnly do
.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
Loading
Loading
# 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)
Loading
Loading
@@ -22,7 +22,7 @@ RSpec.describe Guard::Cli::Environments::Valid do
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)
 
Loading
Loading
@@ -30,18 +30,18 @@ RSpec.describe Guard::Cli::Environments::Valid do
.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
Loading
Loading
@@ -58,11 +58,11 @@ RSpec.describe Guard::Cli::Environments::Valid do
.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
Loading
Loading
@@ -73,20 +73,20 @@ RSpec.describe Guard::Cli::Environments::Valid do
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
Loading
Loading
@@ -97,42 +97,42 @@ RSpec.describe Guard::Cli::Environments::Valid do
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)
Loading
Loading
@@ -146,16 +146,16 @@ RSpec.describe Guard::Cli::Environments::Valid do
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)
Loading
Loading
@@ -163,23 +163,23 @@ RSpec.describe Guard::Cli::Environments::Valid do
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)
Loading
Loading
@@ -191,58 +191,58 @@ RSpec.describe Guard::Cli::Environments::Valid do
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"
Loading
Loading
# 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 = {}
Loading
Loading
@@ -23,13 +23,13 @@ RSpec.describe Guard::CLI do
.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
Loading
Loading
@@ -38,8 +38,8 @@ RSpec.describe Guard::CLI do
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|
Loading
Loading
@@ -48,8 +48,8 @@ RSpec.describe Guard::CLI do
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)
Loading
Loading
@@ -60,67 +60,67 @@ RSpec.describe Guard::CLI do
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
Loading
Loading
@@ -129,8 +129,8 @@ RSpec.describe Guard::CLI do
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)
Loading
Loading
@@ -139,18 +139,18 @@ RSpec.describe Guard::CLI do
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
Loading
Loading
# 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)
Loading
Loading
@@ -21,15 +21,15 @@ RSpec.describe Guard::Commander do
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()
Loading
Loading
@@ -45,48 +45,48 @@ RSpec.describe Guard::Commander do
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)
Loading
Loading
@@ -98,52 +98,52 @@ RSpec.describe Guard::Commander do
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)
Loading
Loading
@@ -151,16 +151,16 @@ RSpec.describe Guard::Commander do
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
Loading
Loading
@@ -168,9 +168,9 @@ RSpec.describe Guard::Commander do
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)
Loading
Loading
@@ -184,12 +184,12 @@ RSpec.describe Guard::Commander do
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)
Loading
Loading
@@ -197,24 +197,24 @@ RSpec.describe Guard::Commander do
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)
Loading
Loading
@@ -228,12 +228,12 @@ RSpec.describe Guard::Commander do
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)
Loading
Loading
@@ -241,32 +241,32 @@ RSpec.describe Guard::Commander do
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
Loading
Loading
# 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
Loading
Loading
@@ -27,18 +27,18 @@ RSpec.describe Guard::Commands::All do
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: []])
 
Loading
Loading
@@ -46,39 +46,39 @@ RSpec.describe Guard::Commands::All do
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
# frozen_string_literal: true
 
require 'guard/commands/change'
require "guard/commands/change"
 
RSpec.describe Guard::Commands::Change do
let(:output) { instance_double(Pry::Output) }
Loading
Loading
@@ -11,35 +11,35 @@ RSpec.describe Guard::Commands::Change do
 
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
Loading
Loading
# frozen_string_literal: true
 
require 'guard/commands/notification'
require "guard/commands/notification"
 
RSpec.describe Guard::Commands::Notification do
let(:output) { instance_double(Pry::Output) }
Loading
Loading
@@ -12,14 +12,14 @@ RSpec.describe Guard::Commands::Notification do
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
Loading
Loading
# frozen_string_literal: true
 
require 'guard/commands/pause'
require "guard/commands/pause"
 
RSpec.describe Guard::Commands::Pause do
class FakePry < Pry::Command
Loading
Loading
@@ -9,14 +9,14 @@ RSpec.describe Guard::Commands::Pause do
 
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
Loading
Loading
# 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) }
Loading
Loading
@@ -26,54 +26,54 @@ RSpec.describe Guard::Commands::Reload do
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
# 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) }
Loading
Loading
@@ -27,7 +27,7 @@ RSpec.describe Guard::Commands::Scope do
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
 
Loading
Loading
@@ -37,47 +37,47 @@ RSpec.describe Guard::Commands::Scope do
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 <scope>')
it "does not call :scope= and shows usage" do
expect(output).to receive(:puts).with("Usage: scope <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
# 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) }
Loading
Loading
@@ -14,14 +14,14 @@ RSpec.describe Guard::Commands::Show do
 
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
Loading
Loading
# 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
Loading
Loading
# 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)
Loading
Loading
@@ -39,20 +39,20 @@ unless Guard::Config.new.strict?
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
Loading
Loading
# 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
Loading
Loading
@@ -16,32 +16,32 @@ unless Guard::Config.new.strict?
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
Loading
Loading
# 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
Loading
Loading
@@ -40,113 +40,113 @@ unless Guard::Config.new.strict?
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)
 
Loading
Loading
@@ -154,8 +154,8 @@ unless Guard::Config.new.strict?
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)
 
Loading
Loading
@@ -163,41 +163,41 @@ unless Guard::Config.new.strict?
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)
Loading
Loading
@@ -205,19 +205,19 @@ unless Guard::Config.new.strict?
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?)
Loading
Loading
@@ -226,43 +226,43 @@ unless Guard::Config.new.strict?
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
Loading
Loading
@@ -272,43 +272,43 @@ unless Guard::Config.new.strict?
# 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
Loading
Loading
@@ -316,105 +316,105 @@ unless Guard::Config.new.strict?
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
Loading
Loading
# 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)
Loading
Loading
@@ -29,24 +29,24 @@ unless Guard::Config.new.strict?
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
Loading
Loading
@@ -55,21 +55,21 @@ unless Guard::Config.new.strict?
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
Loading
Loading
@@ -78,14 +78,14 @@ unless Guard::Config.new.strict?
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
Loading
Loading
# 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)
Loading
Loading
@@ -25,7 +25,7 @@ unless Guard::Config.new.strict?
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)
Loading
Loading
@@ -33,8 +33,8 @@ unless Guard::Config.new.strict?
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)
 
Loading
Loading
@@ -42,7 +42,7 @@ unless Guard::Config.new.strict?
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
Loading
Loading
# 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)
Loading
Loading
@@ -19,15 +19,15 @@ RSpec.describe Guard::DslDescriber do
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
Loading
Loading
@@ -42,7 +42,7 @@ RSpec.describe Guard::DslDescriber do
end
end
 
describe '#list' do
describe "#list" do
let(:result) do
<<-OUTPUT
+---------+-----------+
Loading
Loading
@@ -56,27 +56,27 @@ RSpec.describe Guard::DslDescriber do
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
+---------+---------+--------+-------+
Loading
Loading
@@ -95,33 +95,33 @@ RSpec.describe Guard::DslDescriber do
 
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
+----------------+-----------+------+--------+-------+
Loading
Loading
@@ -147,7 +147,7 @@ RSpec.describe Guard::DslDescriber do
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 } }
Loading
Loading
@@ -158,7 +158,7 @@ RSpec.describe Guard::DslDescriber do
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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment