matchi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/VERSION.semver +1 -1
- data/lib/matchi.rb +3 -0
- data/lib/matchi/be_false.rb +4 -0
- data/lib/matchi/be_nil.rb +4 -0
- data/lib/matchi/be_true.rb +4 -0
- data/lib/matchi/eql.rb +4 -0
- data/lib/matchi/equal.rb +4 -0
- data/lib/matchi/match.rb +4 -0
- data/lib/matchi/raise_exception.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5bdd9213799cfeb48e7ecf65f25b19f126c3c12
|
4
|
+
data.tar.gz: 0ac41824d9ba957e356af42d09c19fb87c5269a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
#
|
data/lib/matchi/be_false.rb
CHANGED
@@ -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)
|
data/lib/matchi/be_true.rb
CHANGED
@@ -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
|