Skip to content

Commit b70ac2b

Browse files
committed
add specs
1 parent fce3aa6 commit b70ac2b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

spec/completely/completions_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
let(:path) { "spec/fixtures/#{file}.yaml" }
55
let(:file) { 'basic' }
66

7+
describe '::read' do
8+
it 'reads from io' do
9+
io = double :io, read: "cli: [--help, --version]"
10+
expect(described_class.read(io).config.config).to eq({ 'cli' => %w[--help --version] })
11+
end
12+
end
13+
714
describe '#valid?' do
815
context 'when all patterns start with the same word' do
916
it 'returns true' do

spec/completely/config_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33

44
let(:path) { "spec/fixtures/#{file}.yaml" }
55
let(:file) { 'nested' }
6+
let(:config_string) { "cli: [--help, --version]" }
7+
let(:config_hash) { { 'cli' => %w[--help --version] } }
8+
9+
describe '::parse' do
10+
it 'loads config from string' do
11+
expect(described_class.parse(config_string).config).to eq config_hash
12+
end
13+
14+
context 'when the string is not a valid YAML' do
15+
it 'raises ParseError' do
16+
expect { described_class.parse("not: a: yaml") }.to raise_error(Completely::ParseError)
17+
end
18+
end
19+
end
20+
21+
describe '::read' do
22+
it 'loads config from io' do
23+
io = double :io, read: config_string
24+
expect(described_class.read(io).config).to eq config_hash
25+
end
26+
end
627

728
describe '#flat_config' do
829
it 'returns a flat pattern => completions hash' do

0 commit comments

Comments
 (0)