Skip to content

Instantly share code, notes, and snippets.

@DavidS
Created August 16, 2018 16:24
Show Gist options
  • Save DavidS/b178c2443943c35a53262eeaac94237a to your computer and use it in GitHub Desktop.
Save DavidS/b178c2443943c35a53262eeaac94237a to your computer and use it in GitHub Desktop.
describe 'something' do
let(:route) { instance_double('Net::IP::Route', 'route') }
before(:each) do
allow(Net::IP::Route).to receive(:new).with({ test: 'data' }).and_return(route)
end
it 'doesn't suck' do
expect(Net::IP).to receive(:routes).with(route)
provider.create(context, name, {input: 'foo'})
end
end
@DavidS
Copy link
Author

DavidS commented Aug 16, 2018

I suspect the allows not to match. change them to an expect temporarily?

Also double check, maybe even pry into, that your code is doing the right thing. in long debugging sessions things can get lost

@dhollinger
Copy link

dhollinger commented Aug 16, 2018

Switching to expect results in the same error.

Using pry, I don't see anything out of the ordinary, but seeing as puppet_munge is called by the create method, is allow(provider).to receive(:puppet_munge).with('should').and_return('munged') even the correct way to mock the results of that method?

none of the allows/expects are failing, it's failing specifically on provider.create() in the test. Almost like that line partially ignores the allows

@dhollinger
Copy link

@DavidS
Copy link
Author

DavidS commented Aug 17, 2018

To wrap up this thread, after some online debugging we found a missing stub, causing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment