expect 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION.semver +1 -1
- data/lib/expect.rb +4 -1
- data/lib/expect/expectation_target.rb +6 -2
- data/lib/expect/matcher.rb +5 -14
- 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: edc3cd88e9d05092903a37838fc4d788a0c060ed
|
4
|
+
data.tar.gz: 461f336b1737e23b37c009bc412c9ae69e617326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f25544ad61c275a1333db030c42c8b30f36387c966ee98f49e30d6f3eca6c0c5ee478c7a3051b498861b6ac620975ef1fd16346deeb87171449fb27af4dc3e98
|
7
|
+
data.tar.gz: 23084bb45623b3a53aaedb056868f2556297c44b01b8834a3a8581b6ecd3dc4f2d08eef877d962fd853f0821ccf9a3d9fd60de0ed0bf39e0a9aaf00d179320ef
|
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/expect.rb
CHANGED
@@ -2,7 +2,10 @@ require_relative File.join 'expect', 'expectation_target'
|
|
2
2
|
|
3
3
|
# Namespace for the Expect library.
|
4
4
|
#
|
5
|
-
# @api
|
5
|
+
# @api public
|
6
|
+
#
|
7
|
+
# @example Expect 42 to be equal to 42
|
8
|
+
# Expect.this { 42 }.to equal: 42 # => true
|
6
9
|
module Expect
|
7
10
|
# Expectations are built with this method.
|
8
11
|
#
|
@@ -14,7 +14,9 @@ module Expect
|
|
14
14
|
#
|
15
15
|
# @api public
|
16
16
|
#
|
17
|
-
# @
|
17
|
+
# @param [Hash, Symbol] definition
|
18
|
+
#
|
19
|
+
# @return [Boolean] report if the expectation is true or false
|
18
20
|
def to(definition)
|
19
21
|
Matcher.pass?(definition, &@actual)
|
20
22
|
end
|
@@ -23,7 +25,9 @@ module Expect
|
|
23
25
|
#
|
24
26
|
# @api public
|
25
27
|
#
|
26
|
-
# @
|
28
|
+
# @param [Hash, Symbol] definition
|
29
|
+
#
|
30
|
+
# @return [Boolean] report if the expectation is true or false
|
27
31
|
def not_to(definition)
|
28
32
|
to(definition).equal?(false)
|
29
33
|
end
|
data/lib/expect/matcher.rb
CHANGED
@@ -5,25 +5,16 @@ module Expect
|
|
5
5
|
module Matcher
|
6
6
|
# Evaluate the expectation with the passed block.
|
7
7
|
#
|
8
|
-
# @param [Hash] definition
|
8
|
+
# @param [Hash, Symbol] definition
|
9
9
|
#
|
10
|
-
# @return [Boolean]
|
10
|
+
# @return [Boolean] report if the expectation is true or false
|
11
11
|
def self.pass?(definition, &actual)
|
12
|
-
params = Array(definition).flatten
|
13
|
-
name = params.first
|
12
|
+
params = Array(definition).flatten(1)
|
13
|
+
name = params.first.to_s.split('_').map(&:capitalize).join.to_sym
|
14
14
|
expected_args = params[1..-1]
|
15
|
-
matcher =
|
15
|
+
matcher = Matchi.const_get(name).new(*expected_args)
|
16
16
|
|
17
17
|
matcher.matches?(&actual)
|
18
18
|
end
|
19
|
-
|
20
|
-
# Get the class of a matcher from its symbol.
|
21
|
-
#
|
22
|
-
# @example
|
23
|
-
#
|
24
|
-
# Matcher.get(:eql) # => Eql
|
25
|
-
def self.get(name)
|
26
|
-
Matchi.const_get name.to_s.split('_').map(&:capitalize).join.to_sym
|
27
|
-
end
|
28
19
|
end
|
29
20
|
end
|