easytest 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/easytest/case.rb +2 -6
- data/lib/easytest/hook.rb +1 -1
- data/lib/easytest/matcher/base.rb +2 -0
- data/lib/easytest/matcher/raise.rb +3 -3
- data/lib/easytest/reporter.rb +4 -3
- data/lib/easytest/version.rb +1 -1
- data/sig/easytest.rbs +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baf1f087a7353d74e8aa021313fd2f00c161af6cf5deb96552a5283e368f947f
|
4
|
+
data.tar.gz: 9ccc8f17a4911d3bc77abdd3916e4344e2965047ffe7d47d6794d88e6d8dd754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d907a3edc843501e6d20b408f358ca5cb0ec19b57a6ee7760577bbceff1fa078635209f439c0b5424ee72e2141c4a54ba51a8bb54c6a823406b55fd21246bd3
|
7
|
+
data.tar.gz: 7c01539bb3762b24f27f5483e86837a05844b8495c6bb9450557d610e978a9011e8c9012c39bb8c7288d7fd6296b9257583298e8c2255cf74492d271b9b83012
|
data/CHANGELOG.md
CHANGED
data/lib/easytest/case.rb
CHANGED
@@ -11,22 +11,18 @@ module Easytest
|
|
11
11
|
|
12
12
|
def initialize(name:, skipped: false, only: false, &block)
|
13
13
|
@name = name
|
14
|
-
@file = caller_locations(3, 1)
|
14
|
+
@file = (caller_locations(3, 1)&.first&.absolute_path or raise)
|
15
15
|
@block = block
|
16
16
|
@skipped = skipped
|
17
17
|
@only = only
|
18
18
|
end
|
19
19
|
|
20
|
-
def todo?
|
21
|
-
block.nil?
|
22
|
-
end
|
23
|
-
|
24
20
|
def skip!
|
25
21
|
@skipped = true
|
26
22
|
end
|
27
23
|
|
28
24
|
def run
|
29
|
-
return [:todo, Reporter.new(name).report_todo]
|
25
|
+
return [:todo, Reporter.new(name).report_todo] unless block
|
30
26
|
return [:skipped, Reporter.new(name).report_skip] if skipped?
|
31
27
|
|
32
28
|
block.call
|
data/lib/easytest/hook.rb
CHANGED
@@ -7,7 +7,7 @@ module Easytest
|
|
7
7
|
def initialize(type:, &block)
|
8
8
|
raise ArgumentError, "" unless [:before, :after].include?(type)
|
9
9
|
|
10
|
-
@file = caller_locations(3, 1)
|
10
|
+
@file = (caller_locations(3, 1)&.first&.absolute_path or raise)
|
11
11
|
@type = type
|
12
12
|
@block = block
|
13
13
|
end
|
@@ -3,9 +3,9 @@ module Easytest
|
|
3
3
|
class Raise < Base
|
4
4
|
attr_reader :with_message
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
|
8
|
-
|
6
|
+
def initialize(actual:, expected:, negate:, with_message:)
|
7
|
+
super(actual: actual, expected: expected, negate: negate)
|
8
|
+
@with_message = with_message
|
9
9
|
end
|
10
10
|
|
11
11
|
def match?
|
data/lib/easytest/reporter.rb
CHANGED
@@ -51,14 +51,15 @@ module Easytest
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def find_location(error)
|
54
|
-
location = error.backtrace_locations
|
55
|
-
loc.path
|
54
|
+
location = error.backtrace_locations&.find do |loc|
|
55
|
+
loc.path&.end_with?("_test.rb")
|
56
56
|
end
|
57
57
|
location or raise "Not found test location from #{error.inspect}"
|
58
58
|
end
|
59
59
|
|
60
60
|
def format_location(location)
|
61
|
-
|
61
|
+
absolute_path = location.absolute_path or raise
|
62
|
+
path = Pathname(absolute_path).relative_path_from(Dir.pwd)
|
62
63
|
"# #{path}:#{location.lineno}:in `#{location.label}'"
|
63
64
|
end
|
64
65
|
end
|
data/lib/easytest/version.rb
CHANGED
data/sig/easytest.rbs
CHANGED
@@ -9,8 +9,8 @@ module Easytest
|
|
9
9
|
|
10
10
|
# An expectation in test cases.
|
11
11
|
class Expectation
|
12
|
-
# Negate
|
13
|
-
def not: () ->
|
12
|
+
# Negate this expectation.
|
13
|
+
def not: () -> Expectation
|
14
14
|
|
15
15
|
# Expect to equal the given object.
|
16
16
|
def to_eq: (untyped expected) -> void
|
@@ -56,7 +56,7 @@ module Easytest
|
|
56
56
|
def to_satisfy: () { (untyped actual) -> bool } -> void
|
57
57
|
|
58
58
|
# Expect to raise the given exception or an exception with the given message.
|
59
|
-
def to_raise: (Class expected, ?(String | Regexp) with_message) -> void
|
59
|
+
def to_raise: (Class expected, ?(String | Regexp)? with_message) -> void
|
60
60
|
| ((String | Regexp) expected) -> void
|
61
61
|
|
62
62
|
# Expect to raise nothing.
|
@@ -65,8 +65,8 @@ module Easytest
|
|
65
65
|
|
66
66
|
# A test case.
|
67
67
|
class Case
|
68
|
-
#
|
69
|
-
|
68
|
+
# A test case name.
|
69
|
+
attr_reader name: String
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easytest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Koba
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|