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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a0b3705ffc7039bfb7ac442d22bce3abf4f6cbb4a100b2f88a637b658d462e3
4
- data.tar.gz: f578262b1621be8e67811a048c3ce0b6c1fb592a82c482a0a945d7b97e221f0c
3
+ metadata.gz: baf1f087a7353d74e8aa021313fd2f00c161af6cf5deb96552a5283e368f947f
4
+ data.tar.gz: 9ccc8f17a4911d3bc77abdd3916e4344e2965047ffe7d47d6794d88e6d8dd754
5
5
  SHA512:
6
- metadata.gz: fe5a6d95407ebccecd912cc2ef7624f449e304662004db4b361be58ccd0ec0a758ed380c8af5efc6632a1172e7acac8e6361274274fa33d6daa0a835e592affb
7
- data.tar.gz: 406ab02728e1d3b58fa18bae5122f5af0691a72c8aaa5568b4d3d572d750419aaea8af9e2b18b15ab03aa24097b75370d1c16bd5bc220af5956820fb399ada3d
6
+ metadata.gz: 7d907a3edc843501e6d20b408f358ca5cb0ec19b57a6ee7760577bbceff1fa078635209f439c0b5424ee72e2141c4a54ba51a8bb54c6a823406b55fd21246bd3
7
+ data.tar.gz: 7c01539bb3762b24f27f5483e86837a05844b8495c6bb9450557d610e978a9011e8c9012c39bb8c7288d7fd6296b9257583298e8c2255cf74492d271b9b83012
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.8.1
6
+
7
+ - Improve type-checking.
8
+
5
9
  ## 0.8.0
6
10
 
7
11
  - Add `before` and `after` hooks.
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).first.absolute_path
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] if 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).first.absolute_path
10
+ @file = (caller_locations(3, 1)&.first&.absolute_path or raise)
11
11
  @type = type
12
12
  @block = block
13
13
  end
@@ -22,6 +22,8 @@ module Easytest
22
22
  raise_match_error unless matched
23
23
  end
24
24
 
25
+ private
26
+
25
27
  def message
26
28
  raise NotImplementedError
27
29
  end
@@ -3,9 +3,9 @@ module Easytest
3
3
  class Raise < Base
4
4
  attr_reader :with_message
5
5
 
6
- def initialize(**kwargs)
7
- @with_message = kwargs.delete(:with_message)
8
- super(**kwargs)
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?
@@ -51,14 +51,15 @@ module Easytest
51
51
  end
52
52
 
53
53
  def find_location(error)
54
- location = error.backtrace_locations.find do |loc|
55
- loc.path.end_with?("_test.rb")
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
- path = Pathname(location.absolute_path).relative_path_from(Dir.pwd)
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
@@ -1,3 +1,3 @@
1
1
  module Easytest
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
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 an expectation.
13
- def not: () -> instance
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
- # Return a test case name.
69
- def name: () -> String
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.0
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-12 00:00:00.000000000 Z
11
+ date: 2022-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow