infopark-user_io 1.2.1 → 1.3.0

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.
@@ -1,157 +1,156 @@
1
- module Infopark
1
+ # frozen_string_literal: true
2
2
 
3
- RSpec.describe UserIO::Progress do
3
+ module Infopark
4
4
  COLOR_BRIGHT_GREEN = "\e[1;32m"
5
5
  COLOR_NORMAL = "\e[22;39m"
6
6
 
7
- let(:user_io) { UserIO.new }
8
-
9
- subject(:progress) { UserIO::Progress.new("the label", user_io) }
7
+ RSpec.describe(UserIO::Progress) do
8
+ let(:user_io) { UserIO.new }
10
9
 
11
- before { allow($stdout).to receive(:write) }
10
+ subject(:progress) { UserIO::Progress.new("the label", user_io) }
12
11
 
13
- describe "#start" do
14
- subject(:start) { progress.start }
12
+ before { allow($stdout).to(receive(:write)) }
15
13
 
16
- it "starts the progress" do
17
- expect($stdout).to receive(:write).with("the label ")
18
- start
19
- end
20
-
21
- context "if already started" do
22
- before { progress.start }
14
+ describe "#start" do
15
+ subject(:start) { progress.start }
23
16
 
24
- it "does nothing" do
25
- expect($stdout).to_not receive(:write)
17
+ it "starts the progress" do
18
+ expect($stdout).to(receive(:write).with("the label "))
26
19
  start
27
20
  end
28
- end
29
- end
30
-
31
- describe "#increment" do
32
- subject(:increment) { progress.increment }
33
21
 
34
- context "on a started progress" do
35
- before { progress.start }
22
+ context "if already started" do
23
+ before { progress.start }
36
24
 
37
- it "increments" do
38
- expect($stdout).to receive(:write).with(".")
39
- increment
25
+ it "does nothing" do
26
+ expect($stdout).to_not(receive(:write))
27
+ start
28
+ end
40
29
  end
41
30
  end
42
31
 
43
- context "on a not started progress" do
44
- it "fails" do
45
- expect { increment }.to raise_error(/not started/)
46
- end
47
- end
32
+ describe "#increment" do
33
+ subject(:increment) { progress.increment }
48
34
 
49
- context "on a finished progress" do
50
- before do
51
- progress.start
52
- progress.finish
53
- end
35
+ context "on a started progress" do
36
+ before { progress.start }
54
37
 
55
- it "fails" do
56
- expect { increment }.to raise_error(/not started/)
38
+ it "increments" do
39
+ expect($stdout).to(receive(:write).with("."))
40
+ increment
41
+ end
57
42
  end
58
- end
59
- end
60
43
 
61
- describe "#spin" do
62
- subject(:spin) { progress.spin }
63
-
64
-
65
- context "on a started progress" do
66
- before { progress.start }
67
-
68
- it "spins" do
69
- expect($stdout).to receive(:write).with("-\b").ordered
70
- progress.spin
71
- expect($stdout).to receive(:write).with("\\\b").ordered
72
- progress.spin
73
- expect($stdout).to receive(:write).with("|\b").ordered
74
- progress.spin
75
- expect($stdout).to receive(:write).with("/\b").ordered
76
- progress.spin
77
- expect($stdout).to receive(:write).with("-\b").ordered
78
- progress.spin
79
- expect($stdout).to receive(:write).with("\\\b").ordered
80
- progress.spin
81
- expect($stdout).to receive(:write).with("|\b").ordered
82
- progress.spin
83
- expect($stdout).to receive(:write).with("/\b").ordered
84
- progress.spin
44
+ context "on a not started progress" do
45
+ it "fails" do
46
+ expect { increment }.to(raise_error(/not started/))
47
+ end
85
48
  end
86
49
 
87
- it "starts spinning from begin when interrupted by an increment" do
88
- expect($stdout).to receive(:write).with("-\b").ordered
89
- progress.spin
90
- expect($stdout).to receive(:write).with("\\\b").ordered
91
- progress.spin
92
- expect($stdout).to receive(:write).with(".").ordered
93
- progress.increment
94
- expect($stdout).to receive(:write).with("-\b").ordered
95
- progress.spin
96
- expect($stdout).to receive(:write).with("\\\b").ordered
97
- progress.spin
98
- expect($stdout).to receive(:write).with("|\b").ordered
99
- progress.spin
100
- expect($stdout).to receive(:write).with("/\b").ordered
101
- progress.spin
50
+ context "on a finished progress" do
51
+ before do
52
+ progress.start
53
+ progress.finish
54
+ end
55
+
56
+ it "fails" do
57
+ expect { increment }.to(raise_error(/not started/))
58
+ end
102
59
  end
103
60
  end
104
61
 
105
- context "on a not started progress" do
106
- it "fails" do
107
- expect { spin }.to raise_error(/not started/)
62
+ describe "#spin" do
63
+ subject(:spin) { progress.spin }
64
+
65
+ context "on a started progress" do
66
+ before { progress.start }
67
+
68
+ it "spins" do
69
+ expect($stdout).to(receive(:write).with("-\b").ordered)
70
+ progress.spin
71
+ expect($stdout).to(receive(:write).with("\\\b").ordered)
72
+ progress.spin
73
+ expect($stdout).to(receive(:write).with("|\b").ordered)
74
+ progress.spin
75
+ expect($stdout).to(receive(:write).with("/\b").ordered)
76
+ progress.spin
77
+ expect($stdout).to(receive(:write).with("-\b").ordered)
78
+ progress.spin
79
+ expect($stdout).to(receive(:write).with("\\\b").ordered)
80
+ progress.spin
81
+ expect($stdout).to(receive(:write).with("|\b").ordered)
82
+ progress.spin
83
+ expect($stdout).to(receive(:write).with("/\b").ordered)
84
+ progress.spin
85
+ end
86
+
87
+ it "starts spinning from begin when interrupted by an increment" do
88
+ expect($stdout).to(receive(:write).with("-\b").ordered)
89
+ progress.spin
90
+ expect($stdout).to(receive(:write).with("\\\b").ordered)
91
+ progress.spin
92
+ expect($stdout).to(receive(:write).with(".").ordered)
93
+ progress.increment
94
+ expect($stdout).to(receive(:write).with("-\b").ordered)
95
+ progress.spin
96
+ expect($stdout).to(receive(:write).with("\\\b").ordered)
97
+ progress.spin
98
+ expect($stdout).to(receive(:write).with("|\b").ordered)
99
+ progress.spin
100
+ expect($stdout).to(receive(:write).with("/\b").ordered)
101
+ progress.spin
102
+ end
108
103
  end
109
- end
110
104
 
111
- context "on a finished progress" do
112
- before do
113
- progress.start
114
- progress.finish
105
+ context "on a not started progress" do
106
+ it "fails" do
107
+ expect { spin }.to(raise_error(/not started/))
108
+ end
115
109
  end
116
110
 
117
- it "fails" do
118
- expect { spin }.to raise_error(/not started/)
111
+ context "on a finished progress" do
112
+ before do
113
+ progress.start
114
+ progress.finish
115
+ end
116
+
117
+ it "fails" do
118
+ expect { spin }.to(raise_error(/not started/))
119
+ end
119
120
  end
120
121
  end
121
- end
122
122
 
123
- describe "#finish" do
124
- subject(:finish) { progress.finish }
123
+ describe "#finish" do
124
+ subject(:finish) { progress.finish }
125
125
 
126
- context "on a started progress" do
127
- before { progress.start }
126
+ context "on a started progress" do
127
+ before { progress.start }
128
128
 
129
- it "finishes" do
130
- expect($stdout).to receive(:write).with("… ")
131
- expect($stdout).to receive(:write).with("#{COLOR_BRIGHT_GREEN}OK#{COLOR_NORMAL}\n")
132
- finish
129
+ it "finishes" do
130
+ expect($stdout).to(receive(:write).with("… "))
131
+ expect($stdout).to(receive(:write).with("#{COLOR_BRIGHT_GREEN}OK#{COLOR_NORMAL}\n"))
132
+ finish
133
+ end
133
134
  end
134
- end
135
135
 
136
- context "on a not started progress" do
137
- it "does nothing" do
138
- expect($stdout).to_not receive(:write)
139
- finish
136
+ context "on a not started progress" do
137
+ it "does nothing" do
138
+ expect($stdout).to_not(receive(:write))
139
+ finish
140
+ end
140
141
  end
141
- end
142
142
 
143
- context "on a finished progress" do
144
- before do
145
- progress.start
146
- progress.finish
147
- end
143
+ context "on a finished progress" do
144
+ before do
145
+ progress.start
146
+ progress.finish
147
+ end
148
148
 
149
- it "does nothing" do
150
- expect($stdout).to_not receive(:write)
151
- finish
149
+ it "does nothing" do
150
+ expect($stdout).to_not(receive(:write))
151
+ finish
152
+ end
152
153
  end
153
154
  end
154
155
  end
155
156
  end
156
-
157
- end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,13 @@
1
- require_relative '../lib/infopark-user_io'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../lib/infopark-user_io"
2
4
 
3
5
  RSpec.configure do |config|
4
- config.expect_with :rspec do |expectations|
6
+ config.expect_with(:rspec) do |expectations|
5
7
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
6
8
  end
7
9
 
8
- config.mock_with :rspec do |mocks|
10
+ config.mock_with(:rspec) do |mocks|
9
11
  mocks.verify_partial_doubles = true
10
12
  end
11
13
 
@@ -13,52 +15,50 @@ RSpec.configure do |config|
13
15
 
14
16
  config.example_status_persistence_file_path = "spec/examples.txt"
15
17
 
16
- # The settings below are suggested to provide a good initial experience
17
- # with RSpec, but feel free to customize to your heart's content.
18
- =begin
19
- # This allows you to limit a spec run to individual examples or groups
20
- # you care about by tagging them with `:focus` metadata. When nothing
21
- # is tagged with `:focus`, all examples get run. RSpec also provides
22
- # aliases for `it`, `describe`, and `context` that include `:focus`
23
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
24
- config.filter_run_when_matching :focus
25
-
26
- # Limits the available syntax to the non-monkey patched syntax that is
27
- # recommended. For more details, see:
28
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
29
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
30
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
31
- config.disable_monkey_patching!
32
-
33
- # This setting enables warnings. It's recommended, but in some cases may
34
- # be too noisy due to issues in dependencies.
35
- config.warnings = true
36
-
37
- # Many RSpec users commonly either run the entire suite or an individual
38
- # file, and it's useful to allow more verbose output when running an
39
- # individual spec file.
40
- if config.files_to_run.one?
41
- # Use the documentation formatter for detailed output,
42
- # unless a formatter has already been configured
43
- # (e.g. via a command-line flag).
44
- config.default_formatter = "doc"
45
- end
46
-
47
- # Print the 10 slowest examples and example groups at the
48
- # end of the spec run, to help surface which specs are running
49
- # particularly slow.
50
- config.profile_examples = 10
51
-
52
- # Run specs in random order to surface order dependencies. If you find an
53
- # order dependency and want to debug it, you can fix the order by providing
54
- # the seed, which is printed after each run.
55
- # --seed 1234
56
- config.order = :random
57
-
58
- # Seed global randomization in this process using the `--seed` CLI option.
59
- # Setting this allows you to use `--seed` to deterministically reproduce
60
- # test failures related to randomization by passing the same `--seed` value
61
- # as the one that triggered the failure.
62
- Kernel.srand config.seed
63
- =end
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ # # This allows you to limit a spec run to individual examples or groups
21
+ # # you care about by tagging them with `:focus` metadata. When nothing
22
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
23
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
24
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
25
+ # config.filter_run_when_matching :focus
26
+ #
27
+ # # Limits the available syntax to the non-monkey patched syntax that is
28
+ # # recommended. For more details, see:
29
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
30
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
31
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
32
+ # config.disable_monkey_patching!
33
+ #
34
+ # # This setting enables warnings. It's recommended, but in some cases may
35
+ # # be too noisy due to issues in dependencies.
36
+ # config.warnings = true
37
+ #
38
+ # # Many RSpec users commonly either run the entire suite or an individual
39
+ # # file, and it's useful to allow more verbose output when running an
40
+ # # individual spec file.
41
+ # if config.files_to_run.one?
42
+ # # Use the documentation formatter for detailed output,
43
+ # # unless a formatter has already been configured
44
+ # # (e.g. via a command-line flag).
45
+ # config.default_formatter = "doc"
46
+ # end
47
+ #
48
+ # # Print the 10 slowest examples and example groups at the
49
+ # # end of the spec run, to help surface which specs are running
50
+ # # particularly slow.
51
+ # config.profile_examples = 10
52
+ #
53
+ # # Run specs in random order to surface order dependencies. If you find an
54
+ # # order dependency and want to debug it, you can fix the order by providing
55
+ # # the seed, which is printed after each run.
56
+ # # --seed 1234
57
+ # config.order = :random
58
+ #
59
+ # # Seed global randomization in this process using the `--seed` CLI option.
60
+ # # Setting this allows you to use `--seed` to deterministically reproduce
61
+ # # test failures related to randomization by passing the same `--seed` value
62
+ # # as the one that triggered the failure.
63
+ # Kernel.srand config.seed
64
64
  end
@@ -1,8 +1,10 @@
1
- RSpec.describe Infopark::UserIO::Global do
2
- class GlobalTest
3
- include ::Infopark::UserIO::Global
4
- end
1
+ # frozen_string_literal: true
2
+
3
+ class GlobalTest
4
+ include ::Infopark::UserIO::Global
5
+ end
5
6
 
7
+ RSpec.describe(Infopark::UserIO::Global) do
6
8
  subject(:global_included) { GlobalTest.new }
7
9
 
8
10
  let(:user_io) { ::Infopark::UserIO.new }
@@ -14,6 +16,6 @@ RSpec.describe Infopark::UserIO::Global do
14
16
  end
15
17
 
16
18
  it "provides convenience access to UserIO.global" do
17
- expect(global_included.user_io).to be user_io
19
+ expect(global_included.user_io).to(be(user_io))
18
20
  end
19
21
  end