Skip to content

Commit

Permalink
Merge pull request #15 from lsst-it/IT-3965/missing-newline
Browse files Browse the repository at this point in the history
fix #verbose_list not appending a new line when items arg is empty
  • Loading branch information
jhoblitt authored Sep 13, 2022
2 parents a023bb8 + aa25a9e commit f3ebfaa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion exe/foreman_envsync
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def verbose_list(msg, items)
return unless @options[:verbose] && !items.nil?

printf(msg, items.count)
puts
return if items.empty?

puts
# do not attempt to sorry Array of Hashes
if items.is_a?(Array) && items.first.is_a?(Hash)
puts "#{YAML.dump(items)}\n"
Expand Down
2 changes: 1 addition & 1 deletion lib/foreman_envsync/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ForemanEnvsync
VERSION = "1.4.0"
VERSION = "1.4.1"
end
15 changes: 13 additions & 2 deletions spec/unit/foreman_envsync_verbose_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
before { @options = { verbose: true } }

context "with array of hash" do
let(:aofh) { [{ a: 1 }, { b: 2 }] }
let(:items) { [{ a: 1 }, { b: 2 }] }
let(:foo_output) do
<<~FOO
foo
Expand All @@ -18,7 +18,18 @@
FOO
end

it { expect { verbose_list("foo", aofh) }.to output(foo_output).to_stdout }
it { expect { verbose_list("foo", items) }.to output(foo_output).to_stdout }
end

context "with empty array" do
let(:items) { [] }
let(:foo_output) do
<<~FOO
foo
FOO
end

it { expect { verbose_list("foo", items) }.to output(foo_output).to_stdout }
end
end
end

0 comments on commit f3ebfaa

Please sign in to comment.