-
-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathargument_spec.rb
More file actions
69 lines (55 loc) · 1.78 KB
/
argument_spec.rb
File metadata and controls
69 lines (55 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
describe Script::Argument do
subject do
options = load_fixture('script/arguments')[fixture]
described_class.new options
end
let(:fixture) { :basic_argument }
describe 'composition' do
it 'includes the necessary modules' do
modules = [Script::Introspection::Validate]
expect(described_class.ancestors).to include(*modules)
end
end
describe '#default_string' do
context 'when default is an array' do
let(:fixture) { :default_array }
it 'returns a shell-escaped string suitable to be shell array source' do
expect(subject.default_string).to eq 'spaced\\ one two'
end
end
context 'when default is string and repeatable is false' do
let(:fixture) { :default_string }
it 'returns it as is' do
expect(subject.default_string).to eq 'spaced one'
end
end
context 'when default is string and repeatable is true' do
let(:fixture) { :default_string_with_repeatable }
it 'returns a single string' do
expect(subject.default_string).to eq 'spaced\\ one'
end
end
end
describe '#usage_string' do
it 'returns a string suitable to be used as a usage pattern' do
expect(subject.usage_string).to eq '[FILE]'
end
context 'when the argument is required' do
let(:fixture) { :required }
it 'returns a string suitable to be used as a usage pattern' do
expect(subject.usage_string).to eq 'FILE'
end
end
end
describe '#label' do
it 'returns a string suitable to be used as a compact usage pattern' do
expect(subject.label).to eq 'FILE'
end
context 'with a repeatable arg' do
let(:fixture) { :repeatable }
it 'adds a ... suffix' do
expect(subject.label).to eq 'FILE...'
end
end
end
end