I have this wonderful module that calls various custom functions that I've written that I'm trying to adopt RSpec testing for. After seeing it crash and burn with "function unknown" errors I took a rather meandering path and arrived here:
https://github.com/TomPoulton/rspec-puppet-unit-testing
So I attempted to follow the instructions given and I ended up with a result like this:
------------- 8< snip! file: spec/classes/init_spec.rb --------------------------------------------
require 'spec_helper'
describe 'ourbind' do
let!(:ipdot2dash) { MockFunction.new('ipdot2dash') { |f|
f.stubbed.with('10.1.2.3').returns('10-1-2-3')
}
}
context 'with defaults for all parameters' do
it do
ipdot2dash.stubs(:call).with('10.1.2.3').returns('10-1-2-3')
should compile
should contain_class('ourbind')
end
end
end
------------------ 8< snip! 8< ----------------------------------------------------------------
I run "rake spec" and I get this (at least to me) undecipherable message:
--------------8< error spew 8<---------------------------------------------------------------
Failure/Error: should compile
Mocha::ExpectationError:
unexpected invocation: #<RSpecPuppetUtils::MockFunction:0x2b67950>.call(['', '21'])
satisfied expectations:
- allowed any number of times, not yet invoked: #<Puppet::Util::Feature:0x214fc38>.root?(any_parameters)
- allowed any number of times, not yet invoked: #<RSpecPuppetUtils::MockFunction:0x2b67950>.call('10.1.2.3')
- allowed any number of times, not yet invoked: #<RSpecPuppetUtils::MockFunction:0x2b67950>.execute('10.1.2.3')
-----------------8< snip! 8< ----------------------------------------------------------------------
Apparently I'm missing something here, what's it trying to tell me and how do I fix it?