Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registry_key_exists? mocked but registry_value_exists? is not #514

Closed
Xoph opened this issue Nov 3, 2014 · 3 comments
Closed

registry_key_exists? mocked but registry_value_exists? is not #514

Xoph opened this issue Nov 3, 2014 · 3 comments

Comments

@Xoph
Copy link

Xoph commented Nov 3, 2014

I have the following guard which ChefSpec tries to evaluate without mocking out the registry_value_exists? method. registry_key_exists? is mocked when I have used it as a guard. Can I mock this somehow?

registry_value_exists?(
            'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp',
            { :name => 'VersionString', :type => :string, :data => '.'}, 
            :machine)}
@sethvargo
Copy link
Contributor

allow_any_instance_of(Chef::Resource)
  .to receive(:registry_value_exists?)
  .with(...)
  .and_return(...)

allow_any_instance_of(Chef::Provider)
  .to receive(:registry_value_exists?)
  .with(...)
  .and_return(...)

@Xoph
Copy link
Author

Xoph commented Nov 3, 2014

Ah right, we can mock it through RSpec. Thank you!

@fghxu
Copy link

fghxu commented May 16, 2016

I am having the same issue.but not sure how to resovle.
can you give a more detailed sample, i.e. without the (...) ?

@lock lock bot locked as resolved and limited conversation to collaborators Aug 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants