highline_wrapper 1.3.1 → 3.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,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highline_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma Sax
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-12-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: abbrev
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.1'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: highline
15
28
  requirement: !ruby/object:Gem::Requirement
16
29
  requirements:
17
30
  - - "~>"
18
31
  - !ruby/object:Gem::Version
19
- version: '2.0'
32
+ version: '3.0'
20
33
  type: :runtime
21
34
  prerelease: false
22
35
  version_requirements: !ruby/object:Gem::Requirement
23
36
  requirements:
24
37
  - - "~>"
25
38
  - !ruby/object:Gem::Version
26
- version: '2.0'
39
+ version: '3.0'
27
40
  - !ruby/object:Gem::Dependency
28
41
  name: bundler
29
42
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +57,14 @@ dependencies:
44
57
  requirements:
45
58
  - - "~>"
46
59
  - !ruby/object:Gem::Version
47
- version: '2.15'
60
+ version: '3.0'
48
61
  type: :development
49
62
  prerelease: false
50
63
  version_requirements: !ruby/object:Gem::Requirement
51
64
  requirements:
52
65
  - - "~>"
53
66
  - !ruby/object:Gem::Version
54
- version: '2.15'
67
+ version: '3.0'
55
68
  - !ruby/object:Gem::Dependency
56
69
  name: guard-rspec
57
70
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +123,6 @@ dependencies:
110
123
  version: '1.10'
111
124
  description: Making it easier to ask simple questions, such as multiple choice questions,
112
125
  yes/no questions, etc, using HighLine.
113
- email:
114
126
  executables: []
115
127
  extensions: []
116
128
  extra_rdoc_files: []
@@ -128,18 +140,12 @@ files:
128
140
  - lib/highline_wrapper/question.rb
129
141
  - lib/highline_wrapper/version.rb
130
142
  - 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
143
+ - renovate.json
137
144
  homepage: https://github.com/emmahsax/highline_wrapper
138
145
  licenses:
139
146
  - BSD-3-Clause
140
147
  metadata:
141
148
  rubygems_mfa_required: 'true'
142
- post_install_message:
143
149
  rdoc_options: []
144
150
  require_paths:
145
151
  - lib
@@ -154,14 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
160
  - !ruby/object:Gem::Version
155
161
  version: '0'
156
162
  requirements: []
157
- rubygems_version: 3.2.22
158
- signing_key:
163
+ rubygems_version: 3.7.1
159
164
  specification_version: 4
160
165
  summary: A little HighLine wrapper
161
- test_files:
162
- - spec/spec_helper.rb
163
- - spec/highline_wrapper/checkbox_question_spec.rb
164
- - spec/highline_wrapper/multiple_choice_question_spec.rb
165
- - spec/highline_wrapper/open_ended_question_spec.rb
166
- - spec/highline_wrapper/question_spec.rb
167
- - spec/highline_wrapper/yes_no_question_spec.rb
166
+ 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