This gem provides some rspec matchers to simplify assertions about the internal state of has hobjects.
Well, this is embarassing. A few hours after I published a blog post about this, I received a comment from @myronmarston. I'd originally written this matcher for RSpec2, and then had to convert my project to use RSpec3. I just blindly converted this matcher over. Myron pointed out that with RSpec3's composable matchers, the functionality of this gem is built-in. It can be done as simply as:
its(:headers) { should include('server' => /nginx\/1\./) }
As such, I've yanked them gem and am leaving the code and blog post here just for posterity. This should probably not be used.
Add this line to your application's Gemfile:
gem 'rspec-matcher-hash-item'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec-matcher-hash-item
In your spec_helper, add a line like:
require 'rspec_matcher_hash_item'
This matcher tests that the given hash has a specified key, with a value matching a regex.
expect(my_hash).to have_hash_item_matching('keyname', /regex/)
- Fork it ( https://github.com/jantman/rspec-matcher-hash-item/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Spec tests are done automatically via Travis CI. They're run using Bundler and rspec.
For manual testing:
bundle install
bundle exec rake spec
- Ensure all tests are passing, coverage is acceptable, etc.
- Increment the version number in
lib/rspec_matcher_hash_item/version.rb
- Update CHANGES.md
- Push those changes to origin.
bundle exec rake build
bundle exec rake release