This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d225ced
commit a0d2c02
Showing
29 changed files
with
438 additions
and
401 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Shanty | ||
# Small mixin providing the DSL style class methods that plugin authors will rely on. This module is expected to be | ||
# mixed into a Plugin class. | ||
module PluginDsl | ||
def provides_projects(*syms) | ||
project_providers.concat(syms.map(&:to_sym)) | ||
end | ||
|
||
def provides_projects_containing(*globs) | ||
project_globs.concat(globs.map(&:to_s)) | ||
end | ||
|
||
def provides_tags(*args) | ||
tags.concat(args.map(&:to_sym)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,33 @@ | ||
require 'spec_helper' | ||
require 'fileutils' | ||
require 'i18n' | ||
require 'tmpdir' | ||
require 'shanty/env' | ||
require 'shenanigans/hash/to_ostruct' | ||
require 'deep_merge' | ||
require 'spec_helper' | ||
require 'tmpdir' | ||
|
||
RSpec.describe(Shanty::Env) do | ||
around do |example| | ||
Dir.mktmpdir('shanty-tests') do |tmp_path| | ||
Dir.chdir(tmp_path) do | ||
FileUtils.touch('.shanty.yml') | ||
FileUtils.touch('Shantyconfig') | ||
example.run | ||
end | ||
end | ||
end | ||
|
||
describe('#logger') do | ||
it('returns a logger object') do | ||
expect(subject.logger).to be_a(Logger) | ||
end | ||
end | ||
|
||
describe('#root') do | ||
it('returns the path to the closest ancestor folder with a .shanty.yml file in it') do | ||
expect(subject.root).to eql(Dir.pwd) | ||
end | ||
|
||
it('throws an exception if no ancestor folders have a .shanty.yml file in them') do | ||
FileUtils.rm('.shanty.yml') | ||
FileUtils.rm('Shantyconfig') | ||
expect { subject.root }.to raise_error(I18n.t('missing_root', config_file: described_class::CONFIG_FILE)) | ||
end | ||
end | ||
|
||
describe('#config') do | ||
before do | ||
ENV['SHANTY_ENV'] = 'stray_cats' | ||
end | ||
|
||
it('handles no config file existing') do | ||
allow(File).to receive(:exist?) { false } | ||
expect(subject.config.nic).to eql(OpenStruct.new) | ||
end | ||
|
||
it('handles no data in the config file') do | ||
allow(YAML).to receive(:load_file) { false } | ||
expect(subject.config) | ||
end | ||
|
||
it('returns nothing if .shanty.yml does not exist') do | ||
FileUtils.rm('.shanty.yml') | ||
expect(subject.config.nic).to eql(OpenStruct.new) | ||
it('returns an empty hash for any missing keys') do | ||
expect(subject.config[:foo]).to eql({}) | ||
end | ||
end | ||
end |
Oops, something went wrong.