I am running a Chef spec unit test using the command below. The relevant code is shown further below. I expected some_test_data to be used in the unit test instead of method_name actually getting called. But what is happening is that the stub is not used. Instead method_name does actually get called, which in this case is not appropriate in the unit test. What am I mis-understanding or doing wrong here? Thank you.
# Code from Chef Spec mytest_spec.rb unit test
# Code unit test is testing
my_variable = method_name(node)
# Method that gets called above
# Do something
Actually you're passing a parameter to
method_name but in the stubbed method, you're not stubbing out the parameters. That is why the stubbed method doesn't get called when you run the tests.
It should be
[I am not sure about the following because you didn't post the actual code. You can ignore it if my assumption is wrong]
You're testing a class method, but you're not calling it on the class. ie.
my_variable = method_name(node) be
my_variable = Classname.method_name(node) ?