Chefspec & jvmargs gem


#1

Hi!

I’m using jvmargs gem in my recipe:
java_opts = JVMArgs::Args.new(…)

java_opts.heap_size(value)

When I run chefspec it says that nil has no method heap_size.

I created a workaround for this:
before do
allow_message_expectations_on_nil
allow(nil).to receive(:heap_size).and_return(nil)
end

But I don’t think this is a proper way. How to fix this problem properly?


#2

Maybe something like:

allow(JVMArgs::Args).to receive(:new).and_return(some_test_double)
expect(some_test_double.to receive(:heap_size).with(value_you_are_expecting)

You’ll need to create a mock or stub for the some_test_double.


#3

thanks, it works!

(if it’s a maillist why I don’t see you reply in my mail?)


#4

@375gnu You may want to check your email notification preferences - there was a bug a while back with Discourse that changed some defaults unintentionally - Check your email settings on Discourse