Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print correct values in debug_configuration_variables task #706

Merged
merged 2 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions spec/support/outputs/debug_configuration_variables.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
========== Configuration variables ==========
(.|\n)*
:bundle_bin => "bundle"
(.|\n)*
:releases_path => ".*/releases"
(.|\n)*
:keep_releases => "1234"
(.|\n)*
:migration_dirs => \["db/migrate"\]
(.|\n)*
========== Configuration variables ==========
14 changes: 12 additions & 2 deletions spec/tasks/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,20 @@
end

describe 'debug_configuration_variables' do
it 'prints configrtion variables' do
before do
Mina::Configuration.instance.set(:debug_configuration_variables, true)
expect { invoke_all }.to output(/------- Printing current config variables -------/).to_stdout
ENV['keep_releases'] = '1234'
end

after do
Mina::Configuration.instance.remove(:debug_configuration_variables)
ENV.delete('keep_releases')
end

it 'prints configuration variables' do
expect do
invoke_all
end.to output(output_file('debug_configuration_variables')).to_stdout
end
end
end
9 changes: 5 additions & 4 deletions tasks/mina/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@

task :debug_configuration_variables do
if fetch(:debug_configuration_variables)
puts
puts '------- Printing current config variables -------'
configuration.variables.each do |key, value|
puts "#{key.inspect} => #{(value.respond_to?(:call) ? value.call : value).inspect}"
puts '========== Configuration variables =========='
configuration.variables.each_key do |key|
puts "#{key.inspect} => #{fetch(key).inspect}"
end
puts '========== Configuration variables =========='
puts
end
end

Expand Down