Skip to content

Commit 8e98c75

Browse files
committed
update library specs
1 parent aad37b6 commit 8e98c75

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

lib/bashly/library.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Bashly
22
class Library
3-
include AssetHelper
43
attr_reader :path, :config
54
attr_accessor :args
65

lib/bashly/library_source.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ def initialize(path = nil)
77
end
88

99
def config
10-
@config ||= YAML.properly_load_file config_path
11-
end
12-
13-
def config_path
14-
@config_path ||= "#{path}/libraries.yml"
10+
@config ||= YAML.properly_load_file("#{path}/libraries.yml")
1511
end
1612

1713
def libraries

spec/bashly/library_source_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require 'spec_helper'
2+
3+
describe LibrarySource do
4+
describe '#config' do
5+
it 'returns the contents of the libraries.yml file' do
6+
expect(subject.config).to be_a Hash
7+
expect(subject.config.keys.first).to eq 'colors'
8+
end
9+
end
10+
11+
describe '#libraries' do
12+
it 'returns a hash' do
13+
expect(subject.libraries).to be_a Hash
14+
end
15+
16+
it 'returns all libraries as keys' do
17+
expect(subject.libraries.keys).to match_array %i[
18+
colors completions completions_script completions_yaml config
19+
help lib settings strings test validations yaml
20+
]
21+
end
22+
23+
it 'returns Library objects as values' do
24+
expect(subject.libraries.values.map { |a| a.class }.uniq ).to eq [Library]
25+
end
26+
end
27+
end

spec/bashly/library_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@
5858
end
5959
end
6060
end
61+
62+
describe '#find_file' do
63+
let(:path) { "#{Settings.target_dir}/src/lib/colors.sh" }
64+
65+
it 'returns a file from the library' do
66+
expect(subject.find_file path).to be_a Hash
67+
end
68+
end
6169
end

0 commit comments

Comments
 (0)