Skip to content
This repository has been archived by the owner on Dec 25, 2017. It is now read-only.

Rspec matchers for dealing with hashes and their content

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

jantman/rspec-matcher-hash-item

Repository files navigation

RspecMatcherHashItem

Build Status Code Coverage Code Climate Gem Version Total Downloads Github Issues Project Status: Abandoned - Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.

This gem provides some rspec matchers to simplify assertions about the internal state of has hobjects.

Do Not Use This

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.

Installation

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

Usage

In your spec_helper, add a line like:

require 'rspec_matcher_hash_item'

Matchers

have_hash_item_matching

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/)

Contributing

  1. Fork it ( https://github.com/jantman/rspec-matcher-hash-item/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Testing

Spec tests are done automatically via Travis CI. They're run using Bundler and rspec.

For manual testing:

bundle install
bundle exec rake spec

Releasing

  1. Ensure all tests are passing, coverage is acceptable, etc.
  2. Increment the version number in lib/rspec_matcher_hash_item/version.rb
  3. Update CHANGES.md
  4. Push those changes to origin.
  5. bundle exec rake build
  6. bundle exec rake release

About

Rspec matchers for dealing with hashes and their content

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published

Languages