Skip to content

Commit

Permalink
Refactor some RSpec Facter test helpers into spec_helper.rb
Browse files Browse the repository at this point in the history
This fixes a minor test regression introduced in voxpupuli#111, wherein Facts defined in
some rspec-puppet were not getting flushed before running the RSpec unit tests
  • Loading branch information
R. Tyler Croy committed Mar 10, 2014
1 parent 26d7d2c commit f930aae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 14 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
# which is a totally piece of garbage mocking library
c.mock_with :rspec

def clear_facts
Facter.clear
Facter.clear_messages
end

c.before(:each, :type => :fact) do
# Need to make sure we clear out our facts at the start to make sure that
# we don't pick up some facts left over from rspec-puppet
clear_facts
end
c.after(:each, :type => :fact) do
clear_facts
end

c.before :each do
if self.respond_to? :pre_condition
if pre_condition.instance_of? Array
Expand Down
6 changes: 0 additions & 6 deletions spec/unit/plugins_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@
Jenkins::Facts.add_facts
end

after :each do
# Make sure we're clearing out Facter every time
Facter.clear
Facter.clear_messages
end

context 'on Linux' do
let(:kernel) { 'Linux' }

Expand Down

0 comments on commit f930aae

Please sign in to comment.