Skip to content

Commit

Permalink
Add appropriate RSpec mocks to ensure Factor lookups do what we expec…
Browse files Browse the repository at this point in the history
…t in Jenkins::Plugins

This is required since Facter#value is going to ultimately start using the File
module to dig through the directory structure on disk looking for facts. With
the OpenBSD support this is suddenly a problem as we weren't previously looking
up facts within these unit tests

See also: <https://github.com/jenkinsci/puppet-jenkins/pull/658/files#r85852243>
  • Loading branch information
R. Tyler Croy committed Nov 1, 2016
1 parent ef9cf4e commit cc49b02
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spec/unit/jenkins_plugins_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

before :each do
Puppet::Jenkins.stub(:home_dir).and_return(home)
File.should_receive(:directory?).with(File.join(home, 'plugins')).and_return(dir_exists)
plugin_dir = File.join(home, 'plugins')
expect(File).to receive(:directory).with(plugin_dir).and_return(dir_exists)
expect(Facter).to receive(:value).with(:osfamily).and_return('RedHat').at_least(:once)
end

context 'and the directory exists' do
Expand All @@ -33,7 +35,7 @@
end

context 'and the directory does not exist' do
it { should be false}
it { should be false }
end
end
end
Expand Down

0 comments on commit cc49b02

Please sign in to comment.