expect 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -1
- data/VERSION.semver +1 -1
- data/expect.gemspec +3 -3
- data/lib/expect.rb +2 -0
- data/lib/expect/expectation_target.rb +17 -16
- metadata +8 -10
- data/lib/expect/exception/failure.rb +0 -7
- data/lib/expect/matcher.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffa099c977ed5d55292506e72d845fda55dc9bf7
|
4
|
+
data.tar.gz: 26925a6847c0ca076c42cc65eab5d6639ece5363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e529e8db912b1fee5713f663e44217cb0aab3cd66471c8a2aa4782a07118f237c3bd65d69103bab7cff4e9746cb78fceceafaa1c04f677b6109afd14ea37c26
|
7
|
+
data.tar.gz: 2138f50c1647baddc35fc928fdedba3c747a540e4edddd73d921a50f1b3d0ae2f2857d84fb88bc2be7f4ea2fc2c59a47a4c840f2dfd0a4fd9fb25345d7ebd486
|
data/Rakefile
CHANGED
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
data/expect.gemspec
CHANGED
@@ -15,9 +15,9 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.add_dependency 'matchi', '~> 0.0.5'
|
17
17
|
|
18
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
19
|
-
spec.add_development_dependency 'rake', '~> 10.
|
18
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
19
|
+
spec.add_development_dependency 'rake', '~> 10.4'
|
20
20
|
spec.add_development_dependency 'yard', '~> 0.8'
|
21
|
-
spec.add_development_dependency 'simplecov', '~> 0.9.
|
21
|
+
spec.add_development_dependency 'simplecov', '~> 0.9.2'
|
22
22
|
spec.add_development_dependency 'rubocop', '~> 0.29'
|
23
23
|
end
|
data/lib/expect.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
require_relative 'matcher'
|
1
|
+
require 'matchi'
|
3
2
|
|
4
3
|
module Expect
|
5
|
-
# Wraps the target of an expectation.
|
4
|
+
# Wraps the target of an expectation. This class is responsible for reporting
|
5
|
+
# if the expectation is true or false.
|
6
6
|
#
|
7
7
|
# @api private
|
8
8
|
#
|
@@ -12,22 +12,24 @@ module Expect
|
|
12
12
|
# Create a new expection target
|
13
13
|
#
|
14
14
|
# @example
|
15
|
-
#
|
15
|
+
# new { 42 }.to Equal: 42 # => true
|
16
16
|
#
|
17
|
-
# @
|
17
|
+
# @param actual [Proc] the value which is compared with the expected value.
|
18
18
|
def initialize(&actual)
|
19
19
|
@actual = actual
|
20
20
|
end
|
21
21
|
|
22
|
+
attr_reader :actual
|
23
|
+
|
22
24
|
# Evaluate to a positive assertion.
|
23
25
|
#
|
24
26
|
# @api public
|
25
27
|
#
|
26
28
|
# @param [Hash, Symbol] definition
|
27
29
|
#
|
28
|
-
# @return [Boolean]
|
30
|
+
# @return [Boolean] report if the expectation is true or false
|
29
31
|
def to(definition)
|
30
|
-
|
32
|
+
matcher(definition).matches?(&actual)
|
31
33
|
end
|
32
34
|
|
33
35
|
# Evaluate to a negative assertion.
|
@@ -36,22 +38,21 @@ module Expect
|
|
36
38
|
#
|
37
39
|
# @param [Hash, Symbol] definition
|
38
40
|
#
|
39
|
-
# @return [Boolean]
|
41
|
+
# @return [Boolean] report if the expectation is not true or not false
|
40
42
|
def not_to(definition)
|
41
|
-
|
43
|
+
!to(definition)
|
42
44
|
end
|
43
45
|
|
44
46
|
private
|
45
47
|
|
46
|
-
#
|
48
|
+
# Load the matcher.
|
47
49
|
#
|
48
|
-
# @
|
50
|
+
# @param [Array, Hash, Symbol] definition
|
49
51
|
#
|
50
|
-
# @
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
Matcher.pass?(definition, &@actual)
|
52
|
+
# @return [#matches?] the matcher
|
53
|
+
def matcher(definition)
|
54
|
+
params = Array(definition).flatten(1)
|
55
|
+
Matchi.fetch(params.first, *params[1..-1])
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matchi
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.9'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '10.
|
47
|
+
version: '10.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '10.
|
54
|
+
version: '10.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.9.
|
75
|
+
version: 0.9.2
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.9.
|
82
|
+
version: 0.9.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,9 +114,7 @@ files:
|
|
114
114
|
- bin/setup
|
115
115
|
- expect.gemspec
|
116
116
|
- lib/expect.rb
|
117
|
-
- lib/expect/exception/failure.rb
|
118
117
|
- lib/expect/expectation_target.rb
|
119
|
-
- lib/expect/matcher.rb
|
120
118
|
homepage: https://github.com/fixrb/expect
|
121
119
|
licenses:
|
122
120
|
- MIT
|
data/lib/expect/matcher.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'matchi'
|
2
|
-
|
3
|
-
module Expect
|
4
|
-
# This module provides matchers to define expectations.
|
5
|
-
module Matcher
|
6
|
-
# Evaluate the expectation with the passed block.
|
7
|
-
#
|
8
|
-
# @param [Array, Hash, Symbol] definition
|
9
|
-
#
|
10
|
-
# @return [Boolean] report if the expectation is true or false
|
11
|
-
def self.pass?(definition, &actual)
|
12
|
-
params = Array(definition).flatten(1)
|
13
|
-
matcher = Matchi.fetch(params.first, *params[1..-1])
|
14
|
-
|
15
|
-
matcher.matches?(&actual)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|