Popularity
0.8
Declining
Activity
0.0
Stable
0
2
0

Programming language: Crystal
License: MIT License
Tags: Testing    
Latest version: v0.1.0

matchi alternatives and similar shards

Based on the "Testing" category.
Alternatively, view matchi alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of matchi or a related project?

Add another 'Testing' Shard

README

Matchi

Build Status

Collection of expectation matchers for Crystal.

Contact

Installation

Add this to your application's shard.yml:

dependencies:
  matchi:
    github: fixcr/matchi

Usage

require "matchi"

Built-in matchers

Untruth matcher:

be_false = Matchi::BeFalse.new
be_false.matches? { false } # => true

Nil matcher:

be_nil = Matchi::BeNil.new
be_nil.matches? { nil } # => true

Truth matcher:

be_true = Matchi::BeTrue.new
be_true.matches? { true } # => true

Regular expressions matcher:

match = Matchi::Match.new(/^[a-z0-9_-]{3,16}$/)
match.matches? { "bob" } # => true

Expecting errors matcher:

raise_exception = Matchi::RaiseException.new(DivisionByZero)
raise_exception.matches? { 0 / 0 } # => true

Equivalence matcher:

same = Matchi::Same.new("foo")
same.matches? { "foo" } # => true

Custom matchers

Custom matchers can easily be defined for expressing expectations.

Be the answer matcher:

module Matchi
  class BeTheAnswer
    def matches?
      42 === yield
    end
  end
end

be_the_answer = Matchi::BeTheAnswer.new
be_the_answer.matches? { 42 } # => true

Start with matcher:

module Matchi
  class StartWith
    def initialize(expected)
      @expected = expected
    end

    def matches?
      !Regex.new("^#{@expected}").match(yield).nil?
    end
  end
end

start_with = Matchi::StartWith.new("foo")
start_with.matches? { "foobar" } # => true

Versioning

Matchi follows Semantic Versioning 2.0.

Contributing

  1. Fork it
  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

License

See LICENSE.md file.


*Note that all licence references and agreements mentioned in the matchi README section above are relevant to that project's source code only.