infopark-user_io 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/infopark/user_io.rb +1 -0
- data/lib/infopark/user_io/version.rb +1 -1
- data/spec/user_io_spec.rb +42 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39d30f92b42ed2149337706f32322f71832689c3
|
4
|
+
data.tar.gz: f3eb6d817c52e53f46ba1dec4cc415567f8d338b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c5da88e52369a968929f62c5c905c3e127d8cb61333563c98a1e44b59863f44010bee1627102ff5578f25995d29d7bc0cff79f9594d4b72d0baeb57f3f2983b
|
7
|
+
data.tar.gz: 99c9f21e6354bd58fec634460fedb79105f4c901ccbab5750bb71473fadf0685ff6b3310e807fafa921f5b916b8db88c943a59dc2b112be034e6ba89e8b12ff2
|
data/lib/infopark/user_io.rb
CHANGED
data/spec/user_io_spec.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
1
|
+
module Infopark
|
2
|
+
|
3
|
+
RSpec.describe UserIO do
|
2
4
|
let(:options) { {} }
|
3
5
|
|
4
|
-
subject(:user_io) {
|
6
|
+
subject(:user_io) { UserIO.new(**options) }
|
5
7
|
|
6
8
|
before do
|
7
9
|
allow($stdout).to receive(:puts)
|
@@ -11,19 +13,19 @@ RSpec.describe ::Infopark::UserIO do
|
|
11
13
|
end
|
12
14
|
|
13
15
|
describe ".global" do
|
14
|
-
subject(:global) {
|
16
|
+
subject(:global) { UserIO.global }
|
15
17
|
|
16
18
|
it { is_expected.to be_nil }
|
17
19
|
end
|
18
20
|
|
19
21
|
describe ".global=" do
|
20
|
-
subject(:assign_global) {
|
22
|
+
subject(:assign_global) { UserIO.global = user_io }
|
21
23
|
|
22
24
|
it "assigns the global UserIO" do
|
23
25
|
expect {
|
24
26
|
assign_global
|
25
27
|
}.to change {
|
26
|
-
|
28
|
+
UserIO.global
|
27
29
|
}.to(user_io)
|
28
30
|
end
|
29
31
|
end
|
@@ -131,6 +133,39 @@ RSpec.describe ::Infopark::UserIO do
|
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
136
|
+
describe "#tell_error" do
|
137
|
+
let(:error) { {my: :error} }
|
138
|
+
let(:tell_options) { {} }
|
139
|
+
|
140
|
+
subject(:tell_error) { user_io.tell_error(error, **tell_options) }
|
141
|
+
|
142
|
+
it "tells the given thing in bright red" do
|
143
|
+
expect(user_io).to receive(:tell).with(error, color: :red, bright: true)
|
144
|
+
tell_error
|
145
|
+
end
|
146
|
+
|
147
|
+
context "with options" do
|
148
|
+
let(:tell_options) { {newline: false} }
|
149
|
+
|
150
|
+
it "delegates them to #tell" do
|
151
|
+
expect(user_io).to receive(:tell).with(error, newline: false, color: :red, bright: true)
|
152
|
+
tell_error
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context "when error is a kind of an exception" do
|
157
|
+
let(:error) { UserIO::Aborted.new }
|
158
|
+
|
159
|
+
before { allow(error).to receive(:backtrace).and_return(%w(a b c)) }
|
160
|
+
|
161
|
+
it "tells the error and the whole backtrace" do
|
162
|
+
expect(user_io).to receive(:tell).with(error, color: :red, bright: true)
|
163
|
+
expect(user_io).to receive(:tell).with(%w(a b c), color: :red)
|
164
|
+
tell_error
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
134
169
|
describe "#tell_pty_stream" do
|
135
170
|
let(:color_options) { {} }
|
136
171
|
let(:stream) { instance_double(IO) }
|
@@ -351,3 +386,5 @@ RSpec.describe ::Infopark::UserIO do
|
|
351
386
|
end
|
352
387
|
end
|
353
388
|
end
|
389
|
+
|
390
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark-user_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilo Prütz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|