diff --git a/lib/guard/rspec.rb b/lib/guard/rspec.rb index 6c7c8954..afbd0e43 100644 --- a/lib/guard/rspec.rb +++ b/lib/guard/rspec.rb @@ -25,7 +25,7 @@ def initialize(options = {}) end def start - ::Guard::UI.info "Guard::RSpec is running" + Guard::Compat::UI.info "Guard::RSpec is running" run_all if options[:all_on_start] end diff --git a/lib/guard/rspec/deprecator.rb b/lib/guard/rspec/deprecator.rb index 28234216..5a1bc855 100644 --- a/lib/guard/rspec/deprecator.rb +++ b/lib/guard/rspec/deprecator.rb @@ -24,7 +24,7 @@ def warns_about_deprecated_options def _spec_opts_env return if ENV["SPEC_OPTS"].nil? - UI.warning( + Compat::UI.warning( "The SPEC_OPTS environment variable is present." + " This can conflict with guard-rspec." ) @@ -77,7 +77,7 @@ def _focus_on_failed_option end def _deprecated(message) - UI.warning %(Guard::RSpec DEPRECATION WARNING: #{message}) + Compat::UI.warning %(Guard::RSpec DEPRECATION WARNING: #{message}) end end end diff --git a/lib/guard/rspec/notifier.rb b/lib/guard/rspec/notifier.rb index aec0ac83..44d20651 100644 --- a/lib/guard/rspec/notifier.rb +++ b/lib/guard/rspec/notifier.rb @@ -12,7 +12,7 @@ def notify(summary) failure_count, pending_count = _parse_summary(summary) image = _image(failure_count, pending_count) priority = _priority(image) - ::Guard::Notifier.notify(summary, + Guard::Compat::UI.notify(summary, title: @options[:title], image: image, priority: priority) @@ -20,7 +20,7 @@ def notify(summary) def notify_failure return unless options[:notification] - ::Guard::Notifier.notify("Failed", + Guard::Compat::UI.notify("Failed", title: @options[:title], image: :failed, priority: 2) diff --git a/lib/guard/rspec/runner.rb b/lib/guard/rspec/runner.rb index 3e03a7b7..f481a1d3 100644 --- a/lib/guard/rspec/runner.rb +++ b/lib/guard/rspec/runner.rb @@ -20,14 +20,14 @@ def run_all paths = options[:spec_paths] options = @options.merge(@options[:run_all]) return true if paths.empty? - ::Guard::UI.info(options[:message], reset: true) + Compat::UI.info(options[:message], reset: true) _run(true, paths, options) end def run(paths) paths = inspector.paths(paths) return true if paths.empty? - ::Guard::UI.info("Running: #{paths.join(" ")}", reset: true) + Compat::UI.info("Running: #{paths.join(" ")}", reset: true) _run(false, paths, options) end @@ -56,7 +56,7 @@ def _without_bundler_env def _cmd_option_present(options) return true if options[:cmd] - ::Guard::UI.error("No cmd option specified, unable to run specs!") + Compat::UI.error("No cmd option specified, unable to run specs!") notifier.notify_failure false end diff --git a/spec/lib/guard/rspec/deprecator_spec.rb b/spec/lib/guard/rspec/deprecator_spec.rb index bb894d02..6785b5a0 100644 --- a/spec/lib/guard/rspec/deprecator_spec.rb +++ b/spec/lib/guard/rspec/deprecator_spec.rb @@ -10,14 +10,14 @@ describe "handling of environment variable SPEC_OPTS" do it "shows warning if SPEC_OPTS is set" do ENV["SPEC_OPTS"] = "-f p" - expect(Guard::UI).to receive(:warning).with( + expect(Guard::Compat::UI).to receive(:warning).with( "The SPEC_OPTS environment variable is present." + " This can conflict with guard-rspec.") deprecator.warns_about_deprecated_options ENV["SPEC_OPTS"] = nil # otherwise other specs pick it up and fail end it "does not show warning if SPEC_OPTS is unset" do - expect(Guard::UI).to_not receive(:warning).with( + expect(Guard::Compat::UI).to_not receive(:warning).with( "The SPEC_OPTS environment variable is present." + " This can conflict with guard-rspec.") deprecator.warns_about_deprecated_options @@ -28,7 +28,7 @@ let(:options) { { version: 1 } } it "shows deprecation warning" do - expect(Guard::UI).to receive(:warning).with( + expect(Guard::Compat::UI).to receive(:warning).with( "Guard::RSpec DEPRECATION WARNING:" + " The :version option is deprecated." + " Only RSpec ~> 2.14 is now supported.") @@ -40,7 +40,7 @@ let(:options) { { exclude: "**" } } it "shows deprecation warning" do - expect(Guard::UI).to receive(:warning).with( + expect(Guard::Compat::UI).to receive(:warning).with( "Guard::RSpec DEPRECATION WARNING:" + " The :exclude option is deprecated." + " Please Guard ignore method instead." + @@ -55,7 +55,7 @@ let(:options) { { option.to_sym => 1 } } it "shows deprecation warning" do - expect(Guard::UI).to receive(:warning).with( + expect(Guard::Compat::UI).to receive(:warning).with( "Guard::RSpec DEPRECATION WARNING: The :#{option} option is" + " deprecated. Please customize the new :cmd option to" + " fit your need.") @@ -68,7 +68,7 @@ let(:options) { { keep_failed: true } } it "shows deprecation warning" do - expect(Guard::UI).to receive(:warning).with( + expect(Guard::Compat::UI).to receive(:warning).with( "Guard::RSpec DEPRECATION WARNING:" + " The :keep_failed option is deprecated." + " Please set new :failed_mode option value to" + @@ -82,7 +82,7 @@ let(:options) { { focus_on_failed: true } } it "shows deprecation warning" do - expect(Guard::UI).to receive(:warning).with( + expect(Guard::Compat::UI).to receive(:warning).with( "Guard::RSpec DEPRECATION WARNING:" + " The :focus_on_failed option is deprecated." + " Focus mode is the default and can be changed using new" + diff --git a/spec/lib/guard/rspec/notifier_spec.rb b/spec/lib/guard/rspec/notifier_spec.rb index 2e6a625c..8fa1b31f 100644 --- a/spec/lib/guard/rspec/notifier_spec.rb +++ b/spec/lib/guard/rspec/notifier_spec.rb @@ -7,8 +7,7 @@ let(:notifier) { Guard::RSpec::Notifier.new(options) } def expect_notification(title = "RSpec results", message, image, priority) - expect(Guard::Notifier). - to receive(:notify). + expect(Guard::Compat::UI).to receive(:notify). with(message, title: title, image: image, priority: priority) end @@ -76,14 +75,14 @@ def expect_notification(title = "RSpec results", message, image, priority) describe "#notify_failure" do it "keeps quiet" do - expect(Guard::Notifier).not_to receive(:notify) + expect(Guard::Compat::UI).not_to receive(:notify) notifier.notify_failure end end describe "#notify" do it "keeps quiet" do - expect(Guard::Notifier).not_to receive(:notify) + expect(Guard::Compat::UI).not_to receive(:notify) notifier.notify("Summary") end end diff --git a/spec/lib/guard/rspec/runner_spec.rb b/spec/lib/guard/rspec/runner_spec.rb index ebdbb2e8..1f729907 100644 --- a/spec/lib/guard/rspec/runner_spec.rb +++ b/spec/lib/guard/rspec/runner_spec.rb @@ -11,7 +11,7 @@ let(:notifier) { double(Guard::RSpec::Notifier) } before do - allow(Guard::UI).to receive(:info) + allow(Guard::Compat::UI).to receive(:info) allow(Kernel).to receive(:system) { true } allow(Guard::RSpec::Inspectors::Factory).to receive(:create) { inspector } allow(Guard::RSpec::Notifier).to receive(:new) { notifier } @@ -48,7 +48,7 @@ shared_examples "abort" do it "aborts" do - expect(Guard::UI).to_not receive(:info) + expect(Guard::Compat::UI).to_not receive(:info) subject end @@ -78,7 +78,9 @@ end it "prints message" do - expect(Guard::UI).to receive(:info).with("Custom message", reset: true) + expect(Guard::Compat::UI).to receive(:info). + with("Custom message", reset: true) + runner.run_all end @@ -111,7 +113,7 @@ before do options[:cmd] = nil allow(Guard::RSpec::Command).to receive(:new) - allow(Guard::UI).to receive(:error).with(an_instance_of(String)) + allow(Guard::Compat::UI).to receive(:error).with(an_instance_of(String)) allow(notifier).to receive(:notify_failure) runner.run_all end @@ -121,7 +123,8 @@ end it "issues a warning to the user" do - expect(Guard::UI).to have_received(:error).with(an_instance_of(String)) + expect(Guard::Compat::UI).to have_received(:error). + with(an_instance_of(String)) end it "notifies the notifer of failure" do @@ -141,7 +144,7 @@ end it "prints running message" do - expect(Guard::UI).to receive(:info). + expect(Guard::Compat::UI).to receive(:info). with("Running: spec_path1 spec_path2", reset: true) runner.run(paths) end diff --git a/spec/lib/guard/rspec_spec.rb b/spec/lib/guard/rspec_spec.rb index da2f16c4..07d0834b 100644 --- a/spec/lib/guard/rspec_spec.rb +++ b/spec/lib/guard/rspec_spec.rb @@ -8,7 +8,7 @@ let(:runner) { double(Guard::RSpec::Runner) } before do - allow(Guard::UI).to receive(:info) + allow(Guard::Compat::UI).to receive(:info) allow(Guard::RSpec::Deprecator).to receive(:warns_about_deprecated_options) allow(Guard::RSpec::Runner).to receive(:new) { runner } end