easytest 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/easytest/expectation.rb +6 -2
- data/lib/easytest/matcher/contain_exactly.rb +13 -0
- data/lib/easytest/matcher/raise.rb +17 -5
- data/lib/easytest/version.rb +1 -1
- data/lib/easytest.rb +1 -0
- data/sig/easytest.rbs +5 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b604c00c58f93e811ba779e0581b57b8eed7df6ef57504bea9239083663af42c
|
4
|
+
data.tar.gz: 8912feb299336ea7e242d1f7349fca2cb089af40f751f6c4478c535594eb6269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f423c20fe3812b906a37498275cd46c5fe5ac9996b8296f0c3ae7e8889d8a73f643310a82d2e2ffbaee48c393f5a94debe3c2e20b71c1d0710fe1f16491009c
|
7
|
+
data.tar.gz: 267b8496e9faea80de95d311bb5d1abb48959499b9765ff37cf588e600950f6a8a5e20b13a21af90818180ad8509d5d7ca74cd1962dc3b3e5eb0fe541f43e8f5
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## 0.6.0
|
6
|
+
|
7
|
+
- Add `to_contain_exactly` matcher.
|
8
|
+
- Allow `to_raise` to receive the second argument.
|
9
|
+
|
10
|
+
## 0.5.2
|
11
|
+
|
12
|
+
- Fix `homepage` in gemspec.
|
13
|
+
|
5
14
|
## 0.5.1
|
6
15
|
|
7
16
|
- Add RDoc to RBS.
|
data/lib/easytest/expectation.rb
CHANGED
@@ -45,12 +45,16 @@ module Easytest
|
|
45
45
|
Matcher::Match.new(actual: actual, expected: expected, negate: negate).match!
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def to_contain_exactly(*expected_items)
|
49
|
+
Matcher::ContainExactly.new(actual: actual, expected: expected_items, negate: negate).match!
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_raise(expected, with_message = nil)
|
49
53
|
raise FatalError, "`to_raise` requires a block like `expect { ... }.to_raise`" unless block
|
50
54
|
raise FatalError, "`not.to_raise` can cause a false positive, so use `to_raise_nothing` instead" if negate?
|
51
55
|
raise FatalError, "`to_raise` requires a Class, String, or Regexp" unless [Class, String, Regexp].any? { expected.is_a? _1 }
|
52
56
|
|
53
|
-
Matcher::Raise.new(actual: block, expected: expected, negate: negate).match!
|
57
|
+
Matcher::Raise.new(actual: block, expected: expected, negate: negate, with_message: with_message).match!
|
54
58
|
end
|
55
59
|
|
56
60
|
def to_raise_nothing
|
@@ -1,13 +1,20 @@
|
|
1
1
|
module Easytest
|
2
2
|
module Matcher
|
3
3
|
class Raise < Base
|
4
|
+
attr_reader :with_message
|
5
|
+
|
6
|
+
def initialize(**kwargs)
|
7
|
+
@with_message = kwargs.delete(:with_message)
|
8
|
+
super(**kwargs)
|
9
|
+
end
|
10
|
+
|
4
11
|
def match?
|
5
12
|
begin
|
6
13
|
actual.call
|
7
14
|
false
|
8
15
|
rescue => error
|
9
16
|
@raised_error = error
|
10
|
-
match_error?(
|
17
|
+
match_error?(error)
|
11
18
|
end
|
12
19
|
end
|
13
20
|
|
@@ -21,14 +28,19 @@ module Easytest
|
|
21
28
|
|
22
29
|
private
|
23
30
|
|
24
|
-
def match_error?(
|
31
|
+
def match_error?(error)
|
25
32
|
case expected
|
26
33
|
when Class
|
27
|
-
|
34
|
+
matched = error.class == expected
|
35
|
+
if with_message
|
36
|
+
matched && error.message.match?(with_message)
|
37
|
+
else
|
38
|
+
matched
|
39
|
+
end
|
28
40
|
when String
|
29
|
-
|
41
|
+
error.message == expected
|
30
42
|
when Regexp
|
31
|
-
|
43
|
+
error.message.match? expected
|
32
44
|
else
|
33
45
|
false
|
34
46
|
end
|
data/lib/easytest/version.rb
CHANGED
data/lib/easytest.rb
CHANGED
@@ -15,6 +15,7 @@ require_relative "easytest/utils"
|
|
15
15
|
require_relative "easytest/matcher/base"
|
16
16
|
require_relative "easytest/matcher/be"
|
17
17
|
require_relative "easytest/matcher/be_a"
|
18
|
+
require_relative "easytest/matcher/contain_exactly"
|
18
19
|
require_relative "easytest/matcher/equal"
|
19
20
|
require_relative "easytest/matcher/false"
|
20
21
|
require_relative "easytest/matcher/include"
|
data/sig/easytest.rbs
CHANGED
@@ -43,8 +43,12 @@ module Easytest
|
|
43
43
|
# Expect to match the given object.
|
44
44
|
def to_match: (untyped expected) -> void
|
45
45
|
|
46
|
+
# Expect to contain all the given items regardless of order.
|
47
|
+
def to_contain_exactly: (*untyped expected_items) -> void
|
48
|
+
|
46
49
|
# Expect to raise the given exception or an exception with the given message.
|
47
|
-
def to_raise: (
|
50
|
+
def to_raise: (Class expected, ?(String | Regexp) with_message) -> void
|
51
|
+
| ((String | Regexp) expected) -> void
|
48
52
|
|
49
53
|
# Expect to raise nothing.
|
50
54
|
def to_raise_nothing: () -> void
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easytest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Koba
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/easytest/matcher/base.rb
|
46
46
|
- lib/easytest/matcher/be.rb
|
47
47
|
- lib/easytest/matcher/be_a.rb
|
48
|
+
- lib/easytest/matcher/contain_exactly.rb
|
48
49
|
- lib/easytest/matcher/equal.rb
|
49
50
|
- lib/easytest/matcher/false.rb
|
50
51
|
- lib/easytest/matcher/include.rb
|
@@ -60,11 +61,11 @@ files:
|
|
60
61
|
- lib/easytest/utils.rb
|
61
62
|
- lib/easytest/version.rb
|
62
63
|
- sig/easytest.rbs
|
63
|
-
homepage: https://github.
|
64
|
+
homepage: https://ybiquitous.github.io/easytest/
|
64
65
|
licenses:
|
65
66
|
- MIT
|
66
67
|
metadata:
|
67
|
-
homepage_uri: https://github.
|
68
|
+
homepage_uri: https://ybiquitous.github.io/easytest/
|
68
69
|
source_code_uri: https://github.com/ybiquitous/easytest
|
69
70
|
changelog_uri: https://github.com/ybiquitous/easytest/blob/main/CHANGELOG.md
|
70
71
|
rubygems_mfa_required: 'true'
|