matchi 4.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +148 -219
- data/lib/matchi/be.rb +58 -16
- data/lib/matchi/be_a_kind_of.rb +87 -34
- data/lib/matchi/be_an_instance_of.rb +74 -62
- data/lib/matchi/be_within.rb +125 -14
- data/lib/matchi/change/by.rb +99 -22
- data/lib/matchi/change/by_at_least.rb +118 -21
- data/lib/matchi/change/by_at_most.rb +132 -22
- data/lib/matchi/change/from/to.rb +92 -25
- data/lib/matchi/change/from.rb +31 -1
- data/lib/matchi/change/to.rb +72 -23
- data/lib/matchi/change.rb +119 -45
- data/lib/matchi/eq.rb +58 -16
- data/lib/matchi/match.rb +56 -16
- data/lib/matchi/predicate.rb +122 -33
- data/lib/matchi/raise_exception.rb +89 -22
- data/lib/matchi/satisfy.rb +87 -16
- data/lib/matchi.rb +51 -297
- metadata +17 -7
- data/lib/matchi/be_within/of.rb +0 -51
metadata
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matchi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date:
|
11
|
+
date: 2025-01-05 00:00:00.000000000 Z
|
11
12
|
dependencies: []
|
12
|
-
description:
|
13
|
+
description: 'Matchi is a framework-agnostic Ruby library that provides a comprehensive
|
14
|
+
set of expectation matchers for elegant and secure testing. Its design focuses on
|
15
|
+
simplicity, security, and extensibility, making it easy to integrate with any testing
|
16
|
+
framework. The library offers a rich collection of built-in matchers for common
|
17
|
+
testing scenarios while maintaining a clear, consistent API that follows Ruby best
|
18
|
+
practices. With minimal setup required and support for custom matchers, Matchi enables
|
19
|
+
developers to write more reliable and maintainable tests.
|
20
|
+
|
21
|
+
'
|
13
22
|
email: contact@cyril.email
|
14
23
|
executables: []
|
15
24
|
extensions: []
|
@@ -22,7 +31,6 @@ files:
|
|
22
31
|
- lib/matchi/be_a_kind_of.rb
|
23
32
|
- lib/matchi/be_an_instance_of.rb
|
24
33
|
- lib/matchi/be_within.rb
|
25
|
-
- lib/matchi/be_within/of.rb
|
26
34
|
- lib/matchi/change.rb
|
27
35
|
- lib/matchi/change/by.rb
|
28
36
|
- lib/matchi/change/by_at_least.rb
|
@@ -40,6 +48,7 @@ licenses:
|
|
40
48
|
- MIT
|
41
49
|
metadata:
|
42
50
|
rubygems_mfa_required: 'true'
|
51
|
+
post_install_message:
|
43
52
|
rdoc_options: []
|
44
53
|
require_paths:
|
45
54
|
- lib
|
@@ -47,14 +56,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
56
|
requirements:
|
48
57
|
- - ">="
|
49
58
|
- !ruby/object:Gem::Version
|
50
|
-
version: 3.
|
59
|
+
version: 3.1.0
|
51
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
61
|
requirements:
|
53
62
|
- - ">="
|
54
63
|
- !ruby/object:Gem::Version
|
55
64
|
version: '0'
|
56
65
|
requirements: []
|
57
|
-
rubygems_version: 3.
|
66
|
+
rubygems_version: 3.3.27
|
67
|
+
signing_key:
|
58
68
|
specification_version: 4
|
59
|
-
summary: "
|
69
|
+
summary: "Framework-agnostic matchers for secure, elegant Ruby testing \U0001F939"
|
60
70
|
test_files: []
|
data/lib/matchi/be_within/of.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Matchi
|
4
|
-
class BeWithin
|
5
|
-
# *BeWithin of* matcher.
|
6
|
-
class Of
|
7
|
-
# Initialize the matcher with a delta and an expected value.
|
8
|
-
#
|
9
|
-
# @example
|
10
|
-
# require "matchi/be_within/of"
|
11
|
-
#
|
12
|
-
# Matchi::BeWithin::Of.new(1, 41)
|
13
|
-
#
|
14
|
-
# @param delta [Numeric] The accepted variation of the actual value.
|
15
|
-
# @param expected [Numeric] The expected value.
|
16
|
-
def initialize(delta, expected)
|
17
|
-
raise ::ArgumentError, "delta must be a Numeric" unless delta.is_a?(::Numeric)
|
18
|
-
raise ::ArgumentError, "expected must be a Numeric" unless expected.is_a?(::Numeric)
|
19
|
-
raise ::ArgumentError, "delta must be non-negative" if delta.negative?
|
20
|
-
|
21
|
-
@delta = delta
|
22
|
-
@expected = expected
|
23
|
-
end
|
24
|
-
|
25
|
-
# Boolean comparison on the expected be_within by comparing the actual
|
26
|
-
# value and the expected value.
|
27
|
-
#
|
28
|
-
# @example
|
29
|
-
# require "matchi/be_within/of"
|
30
|
-
#
|
31
|
-
# matcher = Matchi::BeWithin::Of.new(1, 41)
|
32
|
-
# matcher.match? { 42 } # => true
|
33
|
-
#
|
34
|
-
# @yieldreturn [Numeric] The block of code to execute.
|
35
|
-
#
|
36
|
-
# @return [Boolean] Comparison between the actual and the expected values.
|
37
|
-
def match?
|
38
|
-
raise ::ArgumentError, "a block must be provided" unless block_given?
|
39
|
-
|
40
|
-
(@expected - yield).abs <= @delta
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns a string representing the matcher.
|
44
|
-
#
|
45
|
-
# @return [String] a human-readable description of the matcher
|
46
|
-
def to_s
|
47
|
-
"be within #{@delta} of #{@expected}"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|