# Chefspec & jvmargs gem

**URL:** <https://discourse.chef.io/t/chefspec-jvmargs-gem/8680>\
**Category:** Chef Infra (archive)\
**Created:** [June 13, 2016, 1:49pm UTC](https://discourse.chef.io/t/chefspec-jvmargs-gem/8680 "2016-06-13T13:49:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![375gnu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/375gnu/32/1463_2.png) [@375gnu](https://discourse.chef.io/u/375gnu)\
**Post date:** [June 13, 2016, 1:49pm UTC](https://discourse.chef.io/t/chefspec-jvmargs-gem/8680/1 "2016-06-13T13:49:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Steven\_Murawski](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/steven_murawski/32/1450_2.png) [@Steven\_Murawski](https://discourse.chef.io/u/Steven_Murawski)\
**Post date:** [June 13, 2016, 3:43pm UTC](https://discourse.chef.io/t/chefspec-jvmargs-gem/8680/2 "2016-06-13T15:43:37Z")

</div>

Maybe something like:

```auto
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`.

---

<div class="post-metadata">

**Author:** ![375gnu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/375gnu/32/1463_2.png) [@375gnu](https://discourse.chef.io/u/375gnu)\
**Post date:** [June 14, 2016, 11:28am UTC](https://discourse.chef.io/t/chefspec-jvmargs-gem/8680/3 "2016-06-14T11:28:46Z")

</div>

thanks, it works!

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

---

<div class="post-metadata">

**Author:** ![Steven\_Murawski](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/steven_murawski/32/1450_2.png) [@Steven\_Murawski](https://discourse.chef.io/u/Steven_Murawski)\
**Post date:** [June 14, 2016, 2:14pm UTC](https://discourse.chef.io/t/chefspec-jvmargs-gem/8680/4 "2016-06-14T14:14:20Z")

</div>

@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](https://discourse.chef.io/t/check-your-email-settings-on-discourse/8581)
