matchi 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1580f1d31d1d682c906abafebc1ef9b19580940
4
- data.tar.gz: 43036c78b950d882b82419bec640b6dc3ffb1953
3
+ metadata.gz: f5bdd9213799cfeb48e7ecf65f25b19f126c3c12
4
+ data.tar.gz: 0ac41824d9ba957e356af42d09c19fb87c5269a8
5
5
  SHA512:
6
- metadata.gz: 5769d1b7cfcaaaf032bfbd72430414ccd77c9feb9f5cab17b3ae6da1bfe097cf17182f6f2f0dae089191ab2695c30a94750a3fd23dd3440bb371332ba67190b9
7
- data.tar.gz: a54b61bf4c92e8ec79557864bb72be5cf0e0ccc39eafe65d20300175957ea4ac5ee3fe628ae74de6a5566b5b10e5d8cb892a5fa0ef69e0297915ffac3f711b31
6
+ metadata.gz: 7f6d64db6e7fdb44b2aeaca890f427420ad1ff4b7f678ea18f57f4d96d97a4a0e8f8c4287ad5562d63e09017de537bc64b09b70c97556f652169097c3732a5a6
7
+ data.tar.gz: c23052d210261ef309e1d13c785ae5b8adaf92795e82a5fbf435ccc5261f99436f18177ff120ce04b0a4503f303960a606b05eadfaf7c79031d0b7c87dd237dd
data/README.md CHANGED
@@ -68,6 +68,27 @@ raise_exception = Matchi::RaiseException.new(NameError)
68
68
  raise_exception.matches? { Boom } # => true
69
69
  ```
70
70
 
71
+ **Truth** matcher:
72
+
73
+ ```ruby
74
+ be_true = Matchi::BeTrue.new
75
+ be_true.matches? { true } # => true
76
+ ```
77
+
78
+ **Untruth** matcher:
79
+
80
+ ```ruby
81
+ be_false = Matchi::BeFalse.new
82
+ be_false.matches? { false } # => true
83
+ ```
84
+
85
+ **Nil** matcher:
86
+
87
+ ```ruby
88
+ be_nil = Matchi::BeNil.new
89
+ be_nil.matches? { nil } # => true
90
+ ```
91
+
71
92
  ### Custom matchers
72
93
 
73
94
  Custom matchers can easily be defined for expressing expectations.
data/VERSION.semver CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/lib/matchi.rb CHANGED
@@ -2,6 +2,9 @@ require_relative File.join 'matchi', 'eql'
2
2
  require_relative File.join 'matchi', 'equal'
3
3
  require_relative File.join 'matchi', 'match'
4
4
  require_relative File.join 'matchi', 'raise_exception'
5
+ require_relative File.join 'matchi', 'be_true'
6
+ require_relative File.join 'matchi', 'be_false'
7
+ require_relative File.join 'matchi', 'be_nil'
5
8
 
6
9
  # Namespace for the Matchi library.
7
10
  #
@@ -1,6 +1,10 @@
1
1
  module Matchi
2
2
  # **Untruth** matcher.
3
3
  class BeFalse < BasicObject
4
+ # @example Is it false?
5
+ # be_false = Matchi::BeFalse.new
6
+ # be_false.matches? { false } # => true
7
+ #
4
8
  # @return [Boolean] Comparison between actual and expected values.
5
9
  def matches?
6
10
  false.equal?(yield)
data/lib/matchi/be_nil.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  module Matchi
2
2
  # **Nil** matcher.
3
3
  class BeNil < BasicObject
4
+ # @example Is it nil?
5
+ # be_nil = Matchi::BeNil.new
6
+ # be_nil.matches? { nil } # => true
7
+ #
4
8
  # @return [Boolean] Comparison between actual and expected values.
5
9
  def matches?
6
10
  nil.equal?(yield)
@@ -1,6 +1,10 @@
1
1
  module Matchi
2
2
  # **Truth** matcher.
3
3
  class BeTrue < BasicObject
4
+ # @example Is it true?
5
+ # be_true = Matchi::BeTrue.new
6
+ # be_true.matches? { true } # => true
7
+ #
4
8
  # @return [Boolean] Comparison between actual and expected values.
5
9
  def matches?
6
10
  true.equal?(yield)
data/lib/matchi/eql.rb CHANGED
@@ -5,6 +5,10 @@ module Matchi
5
5
  @expected = expected
6
6
  end
7
7
 
8
+ # @example Is it equivalent to 'foo'?
9
+ # eql = Matchi::Eql.new('foo')
10
+ # eql.matches? { 'foo' } # => true
11
+ #
8
12
  # @return [Boolean] Comparison between actual and expected values.
9
13
  def matches?
10
14
  @expected.eql?(yield)
data/lib/matchi/equal.rb CHANGED
@@ -5,6 +5,10 @@ module Matchi
5
5
  @expected = expected
6
6
  end
7
7
 
8
+ # @example Is it equal to :foo?
9
+ # equal = Matchi::Equal.new(:foo)
10
+ # equal.matches? { :foo } # => true
11
+ #
8
12
  # @return [Boolean] Comparison between actual and expected values.
9
13
  def matches?
10
14
  @expected.equal?(yield)
data/lib/matchi/match.rb CHANGED
@@ -5,6 +5,10 @@ module Matchi
5
5
  @expected = expected
6
6
  end
7
7
 
8
+ # @example Is it matching /^foo$/ regex?
9
+ # match = Matchi::Match.new(/^foo$/)
10
+ # match.matches? { 'foo' } # => true
11
+ #
8
12
  # @return [Boolean] Comparison between actual and expected values.
9
13
  def matches?
10
14
  @expected.match(yield).nil?.equal?(false)
@@ -5,6 +5,10 @@ module Matchi
5
5
  @expected = expected
6
6
  end
7
7
 
8
+ # @example Is it raising NameError?
9
+ # raise_exception = Matchi::RaiseException.new(NameError)
10
+ # raise_exception.matches? { Boom } # => true
11
+ #
8
12
  # @return [Boolean] Comparison between actual and expected values.
9
13
  def matches?
10
14
  yield
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Wack