Ability to configure globs

This commit is contained in:
Vitalii Elenhaupt 2019-12-28 20:59:41 +02:00
parent 4638f4cdf1
commit bffc46c545
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
3 changed files with 86 additions and 42 deletions

View file

@ -8,6 +8,42 @@ module Ameba
Config::AVAILABLE_FORMATTERS.should_not be_nil
end
describe ".new" do
it "loads default globs when config is empty" do
yml = YAML.parse "{}"
config = Config.new(yml)
config.globs.should eq Config::DEFAULT_GLOBS
end
it "initializes globs as string" do
yml = YAML.parse <<-CONFIG
---
Globs: src/*.cr
CONFIG
config = Config.new(yml)
config.globs.should eq %w(src/*.cr)
end
it "initializes globs as array" do
yml = YAML.parse <<-CONFIG
---
Globs:
- "src/*.cr"
- "!spec"
CONFIG
config = Config.new(yml)
config.globs.should eq %w(src/*.cr !spec)
end
it "raises if Globs has a wrong type" do
yml = YAML.parse <<-CONFIG
---
Globs: 100
CONFIG
expect_raises(Exception, "incorrect 'Globs' section in a config file") { Config.new(yml) }
end
end
describe ".load" do
it "loads custom config" do
config = Config.load config_sample
@ -28,7 +64,7 @@ module Ameba
config = Config.load config_sample
it "holds source globs" do
config.globs.should contain "spec/ameba/config_spec.cr"
config.globs.should eq Config::DEFAULT_GLOBS
end
it "allows to set globs" do