How to stub_comand in ChefSpec?

I have this condition in my recipe:

install_action = (::Win32::Service.exists?(windows_service['name']) ? :configure : :create)

and a ChefSpec for that in spec file:

#1: not working 
allow_any_instance_of(Win32::Service)
                .to receive(:exists?)
                .with(windows_service[:name])
                .and_return(true)
#2: also not working
stub_command("::Win32::Service.exists?(#{windows_service[:name]})").and_return(true)

Could you please help to find out what have I missed in the ChefSpec test that is not working and mocking the return value.
Thanks