blob: 23a7670dd1de0b22995a58cf30757f4c08e6f888 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# frozen_string_literal: true
RSpec.describe Bundler::UI::Shell do
subject { described_class.new }
before { subject.level = "debug" }
describe "#info" do
before { subject.level = "info" }
it "prints to stdout" do
expect { subject.info("info") }.to output("info\n").to_stdout
end
end
describe "#confirm" do
before { subject.level = "confirm" }
it "prints to stdout" do
expect { subject.confirm("confirm") }.to output("confirm\n").to_stdout
end
end
describe "#warn" do
before { subject.level = "warn" }
it "prints to stderr" do
expect { subject.warn("warning") }.to output("warning\n").to_stderr
end
context "when stderr flag is enabled" do
before { Bundler.settings.temporary(:error_on_stderr => true) }
it "prints to stderr" do
expect { subject.warn("warning!") }.to output("warning!\n").to_stderr
end
end
end
describe "#debug" do
it "prints to stdout" do
expect { subject.debug("debug") }.to output("debug\n").to_stdout
end
end
describe "#error" do
before { subject.level = "error" }
it "prints to stderr" do
expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr
end
context "when stderr flag is enabled" do
before { Bundler.settings.temporary(:error_on_stderr => true) }
it "prints to stderr" do
expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr
end
context "when stderr is closed" do
it "doesn't report anything" do
output = capture(:stderr, :closed => true) do
subject.error("Something went wrong")
end
expect(output).to_not eq("Something went wrong\n")
end
end
end
end
end
|