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

Package custom matchers for testing using ChefSpec #329

Closed
WarFox opened this issue Jun 13, 2016 · 5 comments
Closed

Package custom matchers for testing using ChefSpec #329

WarFox opened this issue Jun 13, 2016 · 5 comments

Comments

@WarFox
Copy link

WarFox commented Jun 13, 2016

Firstly, let me thank @johnbellone for creating this cookbook and making it open source.

I have a small proposal.

It will be nice to have matchers for testing resources in this cookbook, so that developers can write tests around it.

https://github.com/sethvargo/chefspec#packaging-custom-matchers

If we provide a matcher like the following,

# libraries/matchers.rb

if defined?(ChefSpec)
  def create_consul_definition(resource_name)
    ChefSpec::Matchers::ResourceMatcher.new(:consul_definiton, :create, resource_name)
  end

then developers will be able to write tests like the following

    it 'should create consul definiton' do
      expect(chef_run).to create_consul_definition(service_name)
        .with_type('servicie')
    end

If you agree, with this proposal, I don't mind raising a pull-request for this

@johnbellone
Copy link
Contributor

You should have matchers automatically since we use the Poise library is that not the case?

@WarFox
Copy link
Author

WarFox commented Jun 20, 2016

Oh didn't know about that. Let me verify!

@WarFox
Copy link
Author

WarFox commented Jun 20, 2016

You are right! Poise has provided matchers for resources. I wasn't looking in the right place.

I just needed the following matchers

  • create_consul_installation
  • create_consul_definition
  • enable_consul_service
  • create_consul_config

@WarFox
Copy link
Author

WarFox commented Jun 20, 2016

Closing this issue, as matchers are already available. Thanks!

@WarFox WarFox closed this as completed Jun 20, 2016
@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
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

2 participants