Matchi::Rspec
Extend Matchi matchers with some RSpec's ones.
Installation
Add this line to your application's Gemfile:
gem "matchi-rspec"And then execute:
bundleOr install it yourself as:
gem install matchi-rspecUsage
To make Matchi::Rspec available:
require "matchi/rspec"All examples here assume that this has been done.
Built-in matchers
Identity matcher:
be = Matchi::Matcher::Be.new(42)
be.matches? { 42 } # => trueType/class matcher:
be_instance_of = Matchi::Matcher::BeInstanceOf.new(String)
be_instance_of.matches? { "foo" } # => trueEquivalence matcher:
eq = Matchi::Matcher::Eq.new("foo")
eq.matches? { "foo" } # => trueHelper methods
For convenience, it is possible to instantiate a matcher with a method rather than with its class.
To do so, the Helper module can be included like this:
require "matchi/helper"
class MatcherCollection
  include ::Matchi::Helper
endThe set of loaded matcher then becomes accessible via a dynamically generated instance method, like these:
matcher = MatcherCollection.new
matcher.be(42).matches? { 44 } # => false
matcher.be_instance_of(String).matches? { "안녕하세요" } # => trueContact
- Home page: https://github.com/fixrb/matchi-rspec
 
Versioning
Matchi::Rspec follows Semantic Versioning 2.0.
License
The gem is available as open source under the terms of the MIT License.
