spec/rake/funnel/tasks/environments_spec.rb in rake-funnel-0.18.0 vs spec/rake/funnel/tasks/environments_spec.rb in rake-funnel-0.19.0
- old
+ new
@@ -5,28 +5,28 @@
include Rake::Funnel::Tasks
describe Rake::Funnel::Tasks::Environments do
include Rake::DSL
- before {
+ before do
Task.clear
- }
+ end
let(:files) { [] }
- before {
+ before do
allow(Dir).to receive(:[]).and_return(files)
- }
+ end
def disable_default_env_setup
- allow_any_instance_of(described_class).to receive(:default_environment_setup)
+ allow_any_instance_of(described_class).to receive(:default_environment_setup) # rubocop:disable RSpec/AnyInstance
end
describe 'defaults' do
- before {
+ before do
disable_default_env_setup
- }
+ end
its(:store) { should == configatron }
its(:base_dir) { should == 'config' }
its(:default_env) { should be_nil }
its(:default_config) { should == 'default' }
@@ -34,20 +34,20 @@
its(:customizer) { should be_nil }
describe 'overriding defaults' do
let(:store) { OpenStruct.new }
- subject {
+ subject do
described_class.new do |t|
t.store = store
t.base_dir = 'custom base_dir'
t.default_env = 'custom default_env'
t.default_config = 'custom default_config'
t.local_config = 'custom local_config'
t.customizer = proc {}
end
- }
+ end
its(:store) { should == store }
its(:base_dir) { should == subject.base_dir }
its(:default_env) { should == subject.default_env }
its(:default_config) { should == subject.default_config }
@@ -55,21 +55,21 @@
its(:customizer) { should be_instance_of(Proc) }
end
end
describe 'definition' do
- before {
+ before do
disable_default_env_setup
- }
+ end
- before {
- allow_any_instance_of(described_class).to receive(:task)
- }
+ before do
+ allow_any_instance_of(described_class).to receive(:task) # rubocop:disable RSpec/AnyInstance
+ end
- let(:files) {
+ let(:files) do
%w(config/default.yaml config/local.yaml config/dev.yaml config/production.yaml)
- }
+ end
it 'should define a task for each config file' do
expect(subject).to have_received(:task).with('dev')
expect(subject).to have_received(:task).with('production')
end
@@ -83,32 +83,32 @@
end
end
describe 'config files to load' do
let(:optional) { nil }
- let(:files) {
+ let(:files) do
%w(config/dev.yaml)
- }
+ end
- before {
+ before do
allow(Loader).to receive(:load_configuration)
- }
+ end
- before {
+ before do
allow(File).to receive(:exist?).and_return(true)
allow(File).to receive(:exist?).with(optional).and_return(false)
- }
+ end
- subject! {
+ subject! do
described_class.new do |t|
t.default_env = 'dev'
end
- }
+ end
- before {
+ before do
Task['dev'].invoke
- }
+ end
it 'should store configuration in configatron singleton' do
expect(Loader).to have_received(:load_configuration).with(anything, configatron, any_args)
end
@@ -116,75 +116,77 @@
let(:optional) { nil }
it 'should load all files' do
expect(Loader)
.to have_received(:load_configuration)
- .with(hash_including({ config_files: %w(config/default.yaml config/dev.yaml config/local.yaml) }), any_args)
+ .with(hash_including(config_files: %w(config/default.yaml config/dev.yaml config/local.yaml)), any_args)
end
end
context 'default config file does not exist' do
let(:optional) { 'config/default.yaml' }
it 'should load environment file and local file' do
expect(Loader)
.to have_received(:load_configuration)
- .with(hash_including({ config_files: %w(config/dev.yaml config/local.yaml) }), any_args)
+ .with(hash_including(config_files: %w(config/dev.yaml config/local.yaml)), any_args)
end
end
context 'local config file does not exist' do
let(:optional) { 'config/local.yaml' }
it 'should load default file and environment file' do
- expect(Loader)
- .to have_received(:load_configuration).with(hash_including({ config_files: %w(config/default.yaml config/dev.yaml) }), any_args)
+ expect(Loader).to \
+ have_received(:load_configuration)
+ .with(hash_including(config_files: %w(config/default.yaml config/dev.yaml)),
+ any_args)
end
end
end
describe 'customization' do
let(:customizer) { proc {} }
- let(:files) {
+ let(:files) do
%w(config/dev.yaml)
- }
+ end
- subject! {
+ subject! do
described_class.new do |t|
t.customizer = customizer
end
- }
+ end
- before {
+ before do
allow(Loader).to receive(:load_configuration)
- }
+ end
- before {
+ before do
Task['dev'].invoke
- }
+ end
it 'should pass customizer to loader' do
expect(Loader).to have_received(:load_configuration).with(anything, anything, customizer)
end
end
describe 'automatic environment setup' do
- let(:files) {
+ let(:files) do
%w(config/dev.yaml config/production.yaml)
- }
+ end
- before {
+ before do
Rake.application.top_level_tasks.clear
Rake.application.top_level_tasks.push(*top_level_tasks)
- }
+ end
context 'environment task defined in top-level Rake namespace' do
- subject! {
+ subject! do
described_class.new do |t|
t.default_env = default_env
end
- }
+ end
context 'no default environment configured' do
let(:default_env) { nil }
let(:top_level_tasks) { [] }
@@ -213,18 +215,18 @@
end
end
end
context 'environment task defined in Rake namespace' do
- subject! {
+ subject! do
namespace :foo do
namespace :bar do
described_class.new do |t|
t.default_env = default_env
end
end
end
- }
+ end
context 'default environment configured' do
let(:default_env) { 'dev' }
context 'no top-level environment task' do