Skip to content

Commit

Permalink
use Guard::Compat::UI
Browse files Browse the repository at this point in the history
  • Loading branch information
e2 committed Dec 12, 2014
1 parent 8ded467 commit b76a839
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/guard/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/guard/rspec/deprecator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/guard/rspec/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ 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)
end

def notify_failure
return unless options[:notification]
::Guard::Notifier.notify("Failed",
Guard::Compat::UI.notify("Failed",
title: @options[:title],
image: :failed,
priority: 2)
Expand Down
6 changes: 3 additions & 3 deletions lib/guard/rspec/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/guard/rspec/deprecator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")
Expand All @@ -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." +
Expand All @@ -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.")
Expand All @@ -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" +
Expand All @@ -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" +
Expand Down
7 changes: 3 additions & 4 deletions spec/lib/guard/rspec/notifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions spec/lib/guard/rspec/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/guard/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b76a839

Please sign in to comment.