Skip to content

Commit

Permalink
Skip including an empty stanza if one is generated.
Browse files Browse the repository at this point in the history
Also move unit tests down a level to avoid Foodcritic/foodcritic#148
  • Loading branch information
acharlieh committed Jan 12, 2015
1 parent 4edd918 commit a33a601
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libraries/splunk_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.merge_hashes(*hashes)
app_hash.merge!(to_merge, &merger)
end

result[app_name] = app_hash
result[app_name] = app_hash unless app_hash.empty?
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
end

context 'when given different keys' do
let(:one) { { foo: {} } }
let(:two) { { bar: {} } }
let(:one) { { foo: { a: 'foo' } } }
let(:two) { { bar: { a: 'foo' } } }
let(:three) { { baz: {} } }

it { is_expected.to eq(foo: {}, bar: {}, baz: {}) }
it { is_expected.to eq(foo: { a: 'foo' }, bar: { a: 'foo' }) }
end

context 'when given same keys' do
Expand All @@ -27,8 +27,15 @@
it { is_expected.to eq(foo: { a: 'baz' }) }
end

context 'when given different subkeys' do
let(:one) { { foo: { a: 'foo' } } }
let(:two) { { foo: { b: { a: 'foo' } } } }
let(:three) { { foo: { b: { b: 'bar' }, c: 'baz' } } }

it { is_expected.to eq(foo: { a: 'foo', b: { a: 'foo', b: 'bar' }, c: 'baz' }) }
end

context 'when given a key with a non-hash value' do
before { pending 'when issue #36 is fixed' }
let(:one) { { foo: 'bar' } }

it { is_expected.to eq({}) }
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb → spec/unit/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: UTF-8

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'libraries'))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'libraries'))
require 'rspec'

RSpec.configure do |config|
Expand Down

0 comments on commit a33a601

Please sign in to comment.