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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a723c208d08faafcf16ab1a69f3d1a0258626a2
4
- data.tar.gz: 18a653156ce1b8bbbcff53bdc7808924951d813a
3
+ metadata.gz: 39d30f92b42ed2149337706f32322f71832689c3
4
+ data.tar.gz: f3eb6d817c52e53f46ba1dec4cc415567f8d338b
5
5
  SHA512:
6
- metadata.gz: f8d775c13cdca54d5dcfaf57fea54c6c7384df57297a48025548ef4209ebfc7c4e2b1bf0e6020a4a2e121eb471137973b4612de0d33bcea57585eb9fb954ab8f
7
- data.tar.gz: e9977f5ff38901242d98fe5c84ef2ee18c321c8bf1d20d6d6d21d8ad5741dda401c045d1a0f82df15d508ad0528ea42a48b1e88c80cfda89bb843219e0528fb9
6
+ metadata.gz: 9c5da88e52369a968929f62c5c905c3e127d8cb61333563c98a1e44b59863f44010bee1627102ff5578f25995d29d7bc0cff79f9594d4b72d0baeb57f3f2983b
7
+ data.tar.gz: 99c9f21e6354bd58fec634460fedb79105f4c901ccbab5750bb71473fadf0685ff6b3310e807fafa921f5b916b8db88c943a59dc2b112be034e6ba89e8b12ff2
@@ -90,6 +90,7 @@ class UserIO
90
90
 
91
91
  def tell_error(e, **options)
92
92
  tell(e, **options, color: :red, bright: true)
93
+ tell(e.backtrace, **options, color: :red) if Exception === e
93
94
  end
94
95
 
95
96
  def acknowledge(*text)
@@ -1,5 +1,5 @@
1
1
  module Infopark
2
2
  class UserIO
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
data/spec/user_io_spec.rb CHANGED
@@ -1,7 +1,9 @@
1
- RSpec.describe ::Infopark::UserIO do
1
+ module Infopark
2
+
3
+ RSpec.describe UserIO do
2
4
  let(:options) { {} }
3
5
 
4
- subject(:user_io) { ::Infopark::UserIO.new(**options) }
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) { ::Infopark::UserIO.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) { ::Infopark::UserIO.global = user_io }
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
- ::Infopark::UserIO.global
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.0
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-15 00:00:00.000000000 Z
11
+ date: 2017-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler