mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Ability to configure globs
This commit is contained in:
parent
4638f4cdf1
commit
bffc46c545
3 changed files with 86 additions and 42 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue