Skip to content

Commit b76a839

Browse files
committed
use Guard::Compat::UI
1 parent 8ded467 commit b76a839

File tree

8 files changed

+28
-26
lines changed

8 files changed

+28
-26
lines changed

lib/guard/rspec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def initialize(options = {})
2525
end
2626

2727
def start
28-
::Guard::UI.info "Guard::RSpec is running"
28+
Guard::Compat::UI.info "Guard::RSpec is running"
2929
run_all if options[:all_on_start]
3030
end
3131

lib/guard/rspec/deprecator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def warns_about_deprecated_options
2424

2525
def _spec_opts_env
2626
return if ENV["SPEC_OPTS"].nil?
27-
UI.warning(
27+
Compat::UI.warning(
2828
"The SPEC_OPTS environment variable is present." +
2929
" This can conflict with guard-rspec."
3030
)
@@ -77,7 +77,7 @@ def _focus_on_failed_option
7777
end
7878

7979
def _deprecated(message)
80-
UI.warning %(Guard::RSpec DEPRECATION WARNING: #{message})
80+
Compat::UI.warning %(Guard::RSpec DEPRECATION WARNING: #{message})
8181
end
8282
end
8383
end

lib/guard/rspec/notifier.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ def notify(summary)
1212
failure_count, pending_count = _parse_summary(summary)
1313
image = _image(failure_count, pending_count)
1414
priority = _priority(image)
15-
::Guard::Notifier.notify(summary,
15+
Guard::Compat::UI.notify(summary,
1616
title: @options[:title],
1717
image: image,
1818
priority: priority)
1919
end
2020

2121
def notify_failure
2222
return unless options[:notification]
23-
::Guard::Notifier.notify("Failed",
23+
Guard::Compat::UI.notify("Failed",
2424
title: @options[:title],
2525
image: :failed,
2626
priority: 2)

lib/guard/rspec/runner.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ def run_all
2020
paths = options[:spec_paths]
2121
options = @options.merge(@options[:run_all])
2222
return true if paths.empty?
23-
::Guard::UI.info(options[:message], reset: true)
23+
Compat::UI.info(options[:message], reset: true)
2424
_run(true, paths, options)
2525
end
2626

2727
def run(paths)
2828
paths = inspector.paths(paths)
2929
return true if paths.empty?
30-
::Guard::UI.info("Running: #{paths.join(" ")}", reset: true)
30+
Compat::UI.info("Running: #{paths.join(" ")}", reset: true)
3131
_run(false, paths, options)
3232
end
3333

@@ -56,7 +56,7 @@ def _without_bundler_env
5656

5757
def _cmd_option_present(options)
5858
return true if options[:cmd]
59-
::Guard::UI.error("No cmd option specified, unable to run specs!")
59+
Compat::UI.error("No cmd option specified, unable to run specs!")
6060
notifier.notify_failure
6161
false
6262
end

spec/lib/guard/rspec/deprecator_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
describe "handling of environment variable SPEC_OPTS" do
1111
it "shows warning if SPEC_OPTS is set" do
1212
ENV["SPEC_OPTS"] = "-f p"
13-
expect(Guard::UI).to receive(:warning).with(
13+
expect(Guard::Compat::UI).to receive(:warning).with(
1414
"The SPEC_OPTS environment variable is present." +
1515
" This can conflict with guard-rspec.")
1616
deprecator.warns_about_deprecated_options
1717
ENV["SPEC_OPTS"] = nil # otherwise other specs pick it up and fail
1818
end
1919
it "does not show warning if SPEC_OPTS is unset" do
20-
expect(Guard::UI).to_not receive(:warning).with(
20+
expect(Guard::Compat::UI).to_not receive(:warning).with(
2121
"The SPEC_OPTS environment variable is present." +
2222
" This can conflict with guard-rspec.")
2323
deprecator.warns_about_deprecated_options
@@ -28,7 +28,7 @@
2828
let(:options) { { version: 1 } }
2929

3030
it "shows deprecation warning" do
31-
expect(Guard::UI).to receive(:warning).with(
31+
expect(Guard::Compat::UI).to receive(:warning).with(
3232
"Guard::RSpec DEPRECATION WARNING:" +
3333
" The :version option is deprecated." +
3434
" Only RSpec ~> 2.14 is now supported.")
@@ -40,7 +40,7 @@
4040
let(:options) { { exclude: "**" } }
4141

4242
it "shows deprecation warning" do
43-
expect(Guard::UI).to receive(:warning).with(
43+
expect(Guard::Compat::UI).to receive(:warning).with(
4444
"Guard::RSpec DEPRECATION WARNING:" +
4545
" The :exclude option is deprecated." +
4646
" Please Guard ignore method instead." +
@@ -55,7 +55,7 @@
5555
let(:options) { { option.to_sym => 1 } }
5656

5757
it "shows deprecation warning" do
58-
expect(Guard::UI).to receive(:warning).with(
58+
expect(Guard::Compat::UI).to receive(:warning).with(
5959
"Guard::RSpec DEPRECATION WARNING: The :#{option} option is" +
6060
" deprecated. Please customize the new :cmd option to" +
6161
" fit your need.")
@@ -68,7 +68,7 @@
6868
let(:options) { { keep_failed: true } }
6969

7070
it "shows deprecation warning" do
71-
expect(Guard::UI).to receive(:warning).with(
71+
expect(Guard::Compat::UI).to receive(:warning).with(
7272
"Guard::RSpec DEPRECATION WARNING:" +
7373
" The :keep_failed option is deprecated." +
7474
" Please set new :failed_mode option value to" +
@@ -82,7 +82,7 @@
8282
let(:options) { { focus_on_failed: true } }
8383

8484
it "shows deprecation warning" do
85-
expect(Guard::UI).to receive(:warning).with(
85+
expect(Guard::Compat::UI).to receive(:warning).with(
8686
"Guard::RSpec DEPRECATION WARNING:" +
8787
" The :focus_on_failed option is deprecated." +
8888
" Focus mode is the default and can be changed using new" +

spec/lib/guard/rspec/notifier_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
let(:notifier) { Guard::RSpec::Notifier.new(options) }
88

99
def expect_notification(title = "RSpec results", message, image, priority)
10-
expect(Guard::Notifier).
11-
to receive(:notify).
10+
expect(Guard::Compat::UI).to receive(:notify).
1211
with(message, title: title, image: image, priority: priority)
1312
end
1413

@@ -76,14 +75,14 @@ def expect_notification(title = "RSpec results", message, image, priority)
7675

7776
describe "#notify_failure" do
7877
it "keeps quiet" do
79-
expect(Guard::Notifier).not_to receive(:notify)
78+
expect(Guard::Compat::UI).not_to receive(:notify)
8079
notifier.notify_failure
8180
end
8281
end
8382

8483
describe "#notify" do
8584
it "keeps quiet" do
86-
expect(Guard::Notifier).not_to receive(:notify)
85+
expect(Guard::Compat::UI).not_to receive(:notify)
8786
notifier.notify("Summary")
8887
end
8988
end

spec/lib/guard/rspec/runner_spec.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
let(:notifier) { double(Guard::RSpec::Notifier) }
1212

1313
before do
14-
allow(Guard::UI).to receive(:info)
14+
allow(Guard::Compat::UI).to receive(:info)
1515
allow(Kernel).to receive(:system) { true }
1616
allow(Guard::RSpec::Inspectors::Factory).to receive(:create) { inspector }
1717
allow(Guard::RSpec::Notifier).to receive(:new) { notifier }
@@ -48,7 +48,7 @@
4848

4949
shared_examples "abort" do
5050
it "aborts" do
51-
expect(Guard::UI).to_not receive(:info)
51+
expect(Guard::Compat::UI).to_not receive(:info)
5252
subject
5353
end
5454

@@ -78,7 +78,9 @@
7878
end
7979

8080
it "prints message" do
81-
expect(Guard::UI).to receive(:info).with("Custom message", reset: true)
81+
expect(Guard::Compat::UI).to receive(:info).
82+
with("Custom message", reset: true)
83+
8284
runner.run_all
8385
end
8486

@@ -111,7 +113,7 @@
111113
before do
112114
options[:cmd] = nil
113115
allow(Guard::RSpec::Command).to receive(:new)
114-
allow(Guard::UI).to receive(:error).with(an_instance_of(String))
116+
allow(Guard::Compat::UI).to receive(:error).with(an_instance_of(String))
115117
allow(notifier).to receive(:notify_failure)
116118
runner.run_all
117119
end
@@ -121,7 +123,8 @@
121123
end
122124

123125
it "issues a warning to the user" do
124-
expect(Guard::UI).to have_received(:error).with(an_instance_of(String))
126+
expect(Guard::Compat::UI).to have_received(:error).
127+
with(an_instance_of(String))
125128
end
126129

127130
it "notifies the notifer of failure" do
@@ -141,7 +144,7 @@
141144
end
142145

143146
it "prints running message" do
144-
expect(Guard::UI).to receive(:info).
147+
expect(Guard::Compat::UI).to receive(:info).
145148
with("Running: spec_path1 spec_path2", reset: true)
146149
runner.run(paths)
147150
end

spec/lib/guard/rspec_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
let(:runner) { double(Guard::RSpec::Runner) }
99

1010
before do
11-
allow(Guard::UI).to receive(:info)
11+
allow(Guard::Compat::UI).to receive(:info)
1212
allow(Guard::RSpec::Deprecator).to receive(:warns_about_deprecated_options)
1313
allow(Guard::RSpec::Runner).to receive(:new) { runner }
1414
end

0 commit comments

Comments
 (0)