highline_wrapper 1.3.0 → 2.0.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.
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highline_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma Sax
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-06 00:00:00.000000000 Z
11
+ date: 2024-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: abbrev
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: highline
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '2.0'
33
+ version: '3.0'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '2.0'
40
+ version: '3.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '2.15'
61
+ version: '3.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '2.15'
68
+ version: '3.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: guard-rspec
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -128,16 +142,12 @@ files:
128
142
  - lib/highline_wrapper/question.rb
129
143
  - lib/highline_wrapper/version.rb
130
144
  - lib/highline_wrapper/yes_no_question.rb
131
- - spec/highline_wrapper/checkbox_question_spec.rb
132
- - spec/highline_wrapper/multiple_choice_question_spec.rb
133
- - spec/highline_wrapper/open_ended_question_spec.rb
134
- - spec/highline_wrapper/question_spec.rb
135
- - spec/highline_wrapper/yes_no_question_spec.rb
136
- - spec/spec_helper.rb
145
+ - renovate.json
137
146
  homepage: https://github.com/emmahsax/highline_wrapper
138
147
  licenses:
139
148
  - BSD-3-Clause
140
- metadata: {}
149
+ metadata:
150
+ rubygems_mfa_required: 'true'
141
151
  post_install_message:
142
152
  rdoc_options: []
143
153
  require_paths:
@@ -153,14 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
163
  - !ruby/object:Gem::Version
154
164
  version: '0'
155
165
  requirements: []
156
- rubygems_version: 3.2.15
166
+ rubygems_version: 3.4.5
157
167
  signing_key:
158
168
  specification_version: 4
159
169
  summary: A little HighLine wrapper
160
- test_files:
161
- - spec/spec_helper.rb
162
- - spec/highline_wrapper/checkbox_question_spec.rb
163
- - spec/highline_wrapper/multiple_choice_question_spec.rb
164
- - spec/highline_wrapper/open_ended_question_spec.rb
165
- - spec/highline_wrapper/question_spec.rb
166
- - spec/highline_wrapper/yes_no_question_spec.rb
170
+ test_files: []
@@ -1,226 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'highline_wrapper'
5
-
6
- describe HighlineWrapper::CheckboxQuestion do
7
- let(:choices) { %w[one two three] }
8
- let(:response) { double(:response, readline: true, to_i: 3) }
9
- let(:highline) { double(:highline_cli, ask: response) }
10
-
11
- before do
12
- allow(HighLine).to receive(:new).and_return(highline)
13
- allow(subject).to receive(:puts)
14
- end
15
-
16
- after do
17
- HighlineWrapper::CheckboxQuestion.instance_variable_set('@highline', nil)
18
- end
19
-
20
- subject { HighlineWrapper::CheckboxQuestion }
21
-
22
- context 'with the options as defaults' do
23
- let(:options) do
24
- {
25
- with_indexes: false,
26
- defaults: [],
27
- required: false
28
- }
29
- end
30
-
31
- it 'should ask the highline client ask' do
32
- expect(highline).to receive(:ask)
33
- subject.ask(Faker::Lorem.sentence, choices, options)
34
- end
35
-
36
- it 'should return the value the user selects' do
37
- allow(highline).to receive(:ask).and_return('1,3')
38
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
39
- expect(resp).to eq([{ value: 'one' }, { value: 'three' }])
40
- end
41
-
42
- it 'should return empty array if the user skips' do
43
- allow(highline).to receive(:ask).and_return('')
44
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
45
- expect(resp).to eq([])
46
- end
47
-
48
- it 'should call the return empty defaults if the user skips' do
49
- allow(highline).to receive(:ask).and_return('')
50
- expect(subject).to receive(:return_empty_defaults)
51
- subject.ask(Faker::Lorem.sentence, choices, options)
52
- end
53
- end
54
-
55
- context 'with required set to true' do
56
- context 'with_indexes set to false' do
57
- let(:options) do
58
- {
59
- with_indexes: false,
60
- defaults: [],
61
- required: true
62
- }
63
- end
64
-
65
- it 'should return the value the user selects' do
66
- allow(highline).to receive(:ask).and_return('1,2')
67
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
68
- expect(resp).to eq([{ value: 'one' }, { value: 'two' }])
69
- end
70
-
71
- it 'should recurse multiple times if the user skips' do
72
- allow(highline).to receive(:ask).and_return('', '', '3')
73
- expect(subject).to receive(:ask).exactly(3).times.and_call_original
74
- subject.ask(Faker::Lorem.sentence, choices, options)
75
- end
76
- end
77
-
78
- context 'with_indexes set to true' do
79
- let(:options) do
80
- {
81
- with_indexes: true,
82
- defaults: [],
83
- required: true
84
- }
85
- end
86
-
87
- it 'should return the value the user selects' do
88
- allow(highline).to receive(:ask).and_return('1, 3')
89
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
90
- expect(resp).to eq([{ value: 'one', index: 0 }, { value: 'three', index: 2 }])
91
- end
92
-
93
- it 'should recurse multiple times if the user skips' do
94
- allow(highline).to receive(:ask).and_return('', '', '3')
95
- expect(subject).to receive(:ask).exactly(3).times.and_call_original
96
- subject.ask(Faker::Lorem.sentence, choices, options)
97
- end
98
- end
99
- end
100
-
101
- context 'with required set to false' do
102
- context 'with_indexes set to false' do
103
- context 'with defaults set' do
104
- let(:options) do
105
- {
106
- indicate_default_message: true,
107
- with_indexes: false,
108
- defaults: ['two'],
109
- required: false
110
- }
111
- end
112
-
113
- it 'should return the value the user selects' do
114
- allow(highline).to receive(:ask).and_return('1, 2')
115
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
116
- expect(resp).to eq([{ value: 'one' }, { value: 'two' }])
117
- end
118
-
119
- it 'should return the default if the user skips' do
120
- allow(highline).to receive(:ask).and_return('')
121
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
122
- expect(resp).to eq([{ value: 'two' }])
123
- end
124
-
125
- it 'should call to return the defaults if the user skips' do
126
- allow(highline).to receive(:ask).and_return('')
127
- expect(subject).to receive(:return_defaults).and_call_original
128
- expect(subject).to receive(:puts)
129
- subject.ask(Faker::Lorem.sentence, choices, options)
130
- end
131
-
132
- context 'when the indicate_default_message is false' do
133
- let(:options) do
134
- {
135
- indicate_default_message: false,
136
- with_indexes: false,
137
- defaults: ['two'],
138
- required: false
139
- }
140
- end
141
-
142
- it 'should call to return the defaults if the user skips' do
143
- allow(highline).to receive(:ask).and_return('')
144
- expect(subject).to receive(:return_defaults)
145
- expect(subject).not_to receive(:puts)
146
- subject.ask(Faker::Lorem.sentence, choices, options)
147
- end
148
- end
149
- end
150
-
151
- context 'with defaults set to []' do
152
- let(:options) do
153
- {
154
- with_indexes: false,
155
- defaults: [],
156
- required: false
157
- }
158
- end
159
-
160
- it 'should return the value the user selects' do
161
- allow(highline).to receive(:ask).and_return('1,3')
162
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
163
- expect(resp).to eq([{ value: 'one' }, { value: 'three' }])
164
- end
165
-
166
- it 'should return nil if the user skips' do
167
- allow(highline).to receive(:ask).and_return('')
168
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
169
- expect(resp).to eq([])
170
- end
171
- end
172
- end
173
-
174
- context 'with_indexes set to true' do
175
- context 'with default set' do
176
- let(:options) do
177
- {
178
- with_indexes: true,
179
- defaults: ['two'],
180
- required: false
181
- }
182
- end
183
-
184
- it 'should return the value the user selects' do
185
- allow(highline).to receive(:ask).and_return('1,2')
186
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
187
- expect(resp).to eq([{ value: 'one', index: 0 }, { value: 'two', index: 1 }])
188
- end
189
-
190
- it 'should return the default if the user skips' do
191
- allow(highline).to receive(:ask).and_return('')
192
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
193
- expect(resp).to eq([{ value: 'two', index: 1 }])
194
- end
195
- end
196
-
197
- context 'with default nil' do
198
- let(:options) do
199
- {
200
- with_indexes: true,
201
- defaults: [],
202
- required: false
203
- }
204
- end
205
-
206
- it 'should return the value the user selects' do
207
- allow(highline).to receive(:ask).and_return('1')
208
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
209
- expect(resp).to eq([{ value: 'one', index: 0 }])
210
- end
211
-
212
- it 'should return [] if the user skips' do
213
- allow(highline).to receive(:ask).and_return('')
214
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
215
- expect(resp).to eq([])
216
- end
217
-
218
- it 'should call the return empty defaults message' do
219
- allow(highline).to receive(:ask).and_return('')
220
- expect(subject).to receive(:return_empty_defaults)
221
- subject.ask(Faker::Lorem.sentence, choices, options)
222
- end
223
- end
224
- end
225
- end
226
- end
@@ -1,226 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'highline_wrapper'
5
-
6
- describe HighlineWrapper::MultipleChoiceQuestion do
7
- let(:choices) { %w[one two three] }
8
- let(:response) { double(:response, readline: true, to_i: 3) }
9
- let(:highline) { double(:highline_cli, ask: response) }
10
-
11
- before do
12
- allow(HighLine).to receive(:new).and_return(highline)
13
- allow(subject).to receive(:puts)
14
- end
15
-
16
- after do
17
- HighlineWrapper::MultipleChoiceQuestion.instance_variable_set('@highline', nil)
18
- end
19
-
20
- subject { HighlineWrapper::MultipleChoiceQuestion }
21
-
22
- context 'with the options as defaults' do
23
- let(:options) do
24
- {
25
- with_index: false,
26
- default: nil,
27
- required: false
28
- }
29
- end
30
-
31
- it 'should ask the highline client ask' do
32
- expect(highline).to receive(:ask)
33
- subject.ask(Faker::Lorem.sentence, choices, options)
34
- end
35
-
36
- it 'should return the value the user selects' do
37
- allow(highline).to receive(:ask).and_return(1)
38
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
39
- expect(resp).to eq({ value: 'one' })
40
- end
41
-
42
- it 'should return nil if the user skips' do
43
- allow(highline).to receive(:ask).and_return(0)
44
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
45
- expect(resp).to eq(nil)
46
- end
47
-
48
- it 'should call the return empty defaults if the user skips' do
49
- allow(highline).to receive(:ask).and_return('')
50
- expect(subject).to receive(:return_empty_defaults)
51
- subject.ask(Faker::Lorem.sentence, choices, options)
52
- end
53
- end
54
-
55
- context 'with required set to true' do
56
- context 'with_index set to false' do
57
- let(:options) do
58
- {
59
- with_index: false,
60
- default: Faker::Lorem.word,
61
- required: true
62
- }
63
- end
64
-
65
- it 'should return the value the user selects' do
66
- allow(highline).to receive(:ask).and_return(1)
67
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
68
- expect(resp).to eq({ value: 'one' })
69
- end
70
-
71
- it 'should recurse multiple times if the user skips' do
72
- allow(highline).to receive(:ask).and_return(0, 0, 3)
73
- expect(subject).to receive(:ask).exactly(3).times.and_call_original
74
- subject.ask(Faker::Lorem.sentence, choices, options)
75
- end
76
- end
77
-
78
- context 'with_index set to true' do
79
- let(:options) do
80
- {
81
- with_index: true,
82
- default: nil,
83
- required: true
84
- }
85
- end
86
-
87
- it 'should return the value the user selects' do
88
- allow(highline).to receive(:ask).and_return(1)
89
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
90
- expect(resp).to eq({ value: 'one', index: 0 })
91
- end
92
-
93
- it 'should recurse multiple times if the user skips' do
94
- allow(highline).to receive(:ask).and_return(0, 0, 3)
95
- expect(subject).to receive(:ask).exactly(3).times.and_call_original
96
- subject.ask(Faker::Lorem.sentence, choices, options)
97
- end
98
- end
99
- end
100
-
101
- context 'with required set to false' do
102
- context 'with_index set to false' do
103
- context 'with default set' do
104
- let(:options) do
105
- {
106
- indicate_default_message: true,
107
- with_index: false,
108
- default: 'two',
109
- required: false
110
- }
111
- end
112
-
113
- it 'should return the value the user selects' do
114
- allow(highline).to receive(:ask).and_return(1)
115
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
116
- expect(resp).to eq({ value: 'one' })
117
- end
118
-
119
- it 'should return the default if the user skips' do
120
- allow(highline).to receive(:ask).and_return(0)
121
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
122
- expect(resp).to eq({ value: 'two' })
123
- end
124
-
125
- it 'should call to return the defaults if the user skips' do
126
- allow(highline).to receive(:ask).and_return(0)
127
- expect(subject).to receive(:return_defaults).and_call_original
128
- expect(subject).to receive(:puts)
129
- subject.ask(Faker::Lorem.sentence, choices, options)
130
- end
131
-
132
- context 'when the indicate_default_message is false' do
133
- let(:options) do
134
- {
135
- indicate_default_message: false,
136
- with_indexes: false,
137
- default: 'two',
138
- required: false
139
- }
140
- end
141
-
142
- it 'should call to return the defaults if the user skips' do
143
- allow(highline).to receive(:ask).and_return(0)
144
- expect(subject).to receive(:return_defaults)
145
- expect(subject).not_to receive(:puts)
146
- subject.ask(Faker::Lorem.sentence, choices, options)
147
- end
148
- end
149
- end
150
-
151
- context 'with default nil' do
152
- let(:options) do
153
- {
154
- with_index: false,
155
- default: nil,
156
- required: false
157
- }
158
- end
159
-
160
- it 'should return the value the user selects' do
161
- allow(highline).to receive(:ask).and_return(1)
162
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
163
- expect(resp).to eq({ value: 'one' })
164
- end
165
-
166
- it 'should return nil if the user skips' do
167
- allow(highline).to receive(:ask).and_return(0)
168
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
169
- expect(resp).to eq(nil)
170
- end
171
- end
172
- end
173
-
174
- context 'with_index set to true' do
175
- context 'with default set' do
176
- let(:options) do
177
- {
178
- with_index: true,
179
- default: 'two',
180
- required: false
181
- }
182
- end
183
-
184
- it 'should return the value the user selects' do
185
- allow(highline).to receive(:ask).and_return(1)
186
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
187
- expect(resp).to eq({ value: 'one', index: 0 })
188
- end
189
-
190
- it 'should return the default if the user skips' do
191
- allow(highline).to receive(:ask).and_return(0)
192
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
193
- expect(resp).to eq({ value: 'two', index: 1 })
194
- end
195
- end
196
-
197
- context 'with default nil' do
198
- let(:options) do
199
- {
200
- with_index: true,
201
- default: nil,
202
- required: false
203
- }
204
- end
205
-
206
- it 'should return the value the user selects' do
207
- allow(highline).to receive(:ask).and_return(1)
208
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
209
- expect(resp).to eq({ value: 'one', index: 0 })
210
- end
211
-
212
- it 'should return nil if the user skips' do
213
- allow(highline).to receive(:ask).and_return(0)
214
- resp = subject.ask(Faker::Lorem.sentence, choices, options)
215
- expect(resp).to eq(nil)
216
- end
217
-
218
- it 'should call the return empty defaults message' do
219
- allow(highline).to receive(:ask).and_return(0)
220
- expect(subject).to receive(:return_empty_defaults)
221
- subject.ask(Faker::Lorem.sentence, choices, options)
222
- end
223
- end
224
- end
225
- end
226
- end
@@ -1,108 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'highline_wrapper'
5
-
6
- describe HighlineWrapper::OpenEndedQuestion do
7
- let(:response) { double(:response, readline: true, to_i: 3) }
8
- let(:highline) { double(:highline_cli, ask: response) }
9
-
10
- before do
11
- allow(HighLine).to receive(:new).and_return(highline)
12
- allow(subject).to receive(:puts)
13
- end
14
-
15
- after do
16
- HighlineWrapper::OpenEndedQuestion.instance_variable_set('@highline', nil)
17
- end
18
-
19
- subject { HighlineWrapper::OpenEndedQuestion }
20
-
21
- context 'with the options as defaults' do
22
- let(:options) do
23
- {
24
- indicate_default_message: true,
25
- secret: false,
26
- default: '',
27
- required: false
28
- }
29
- end
30
-
31
- it 'should ask the highline client ask' do
32
- expect(highline).to receive(:ask)
33
- subject.ask(Faker::Lorem.sentence, options)
34
- end
35
-
36
- it 'should return the value the user selects' do
37
- answer = Faker::Lorem.sentence
38
- allow(highline).to receive(:ask).and_return(answer)
39
- resp = subject.ask(Faker::Lorem.sentence, options)
40
- expect(resp).to eq(answer)
41
- end
42
-
43
- it 'should return empty string if the user skips' do
44
- allow(highline).to receive(:ask).and_return('')
45
- resp = subject.ask(Faker::Lorem.sentence, options)
46
- expect(resp).to eq('')
47
- end
48
-
49
- it 'should call to print the default message' do
50
- allow(highline).to receive(:ask).and_return('')
51
- expect(subject).to receive(:print_default_message)
52
- subject.ask(Faker::Lorem.sentence, options)
53
- end
54
- end
55
-
56
- context 'with required set to true' do
57
- let(:options) do
58
- {
59
- secret: false,
60
- default: 'something-goes-here',
61
- required: true
62
- }
63
- end
64
-
65
- it 'should return the value the user selects' do
66
- answer = Faker::Lorem.sentence
67
- allow(highline).to receive(:ask).and_return(answer)
68
- resp = subject.ask(Faker::Lorem.sentence, options)
69
- expect(resp).to eq(answer)
70
- end
71
-
72
- it 'should recurse multiple times if the user skips' do
73
- allow(highline).to receive(:ask).and_return('', '', Faker::Lorem.sentence)
74
- expect(subject).to receive(:ask).exactly(3).times.and_call_original
75
- subject.ask(Faker::Lorem.sentence, options)
76
- end
77
- end
78
-
79
- context 'with the default set and the required set to false' do
80
- let(:default_string) { Faker::Lorem.sentence }
81
- let(:options) do
82
- {
83
- indicate_default_message: false,
84
- secret: false,
85
- default: default_string,
86
- required: false
87
- }
88
- end
89
-
90
- it 'should return the value the user selects' do
91
- answer = Faker::Lorem.sentence
92
- allow(highline).to receive(:ask).and_return(answer)
93
- resp = subject.ask(Faker::Lorem.sentence, options)
94
- expect(resp).to eq(answer)
95
- end
96
-
97
- it 'should return the default value the user skips' do
98
- allow(highline).to receive(:ask).and_return('')
99
- expect(subject.ask(Faker::Lorem.sentence, options)).to eq(default_string)
100
- end
101
-
102
- it 'should not call to print the default message' do
103
- allow(highline).to receive(:ask).and_return('')
104
- expect(subject).not_to receive(:print_default_message)
105
- subject.ask(Faker::Lorem.sentence, options)
106
- end
107
- end
108
- end