easytest 0.6.0 → 0.7.0

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: b604c00c58f93e811ba779e0581b57b8eed7df6ef57504bea9239083663af42c
4
- data.tar.gz: 8912feb299336ea7e242d1f7349fca2cb089af40f751f6c4478c535594eb6269
3
+ metadata.gz: 5f45ff0adb716aa609a9fce9fd5eaefab60b8d56e4b2708a26b56d63189c3b78
4
+ data.tar.gz: 93b56e1770e0cd3a7d233580eddbd72737e56de4c5ebe405f244c6ca300f1ab9
5
5
  SHA512:
6
- metadata.gz: 0f423c20fe3812b906a37498275cd46c5fe5ac9996b8296f0c3ae7e8889d8a73f643310a82d2e2ffbaee48c393f5a94debe3c2e20b71c1d0710fe1f16491009c
7
- data.tar.gz: 267b8496e9faea80de95d311bb5d1abb48959499b9765ff37cf588e600950f6a8a5e20b13a21af90818180ad8509d5d7ca74cd1962dc3b3e5eb0fe541f43e8f5
6
+ metadata.gz: 14fe72a70136f6aeca4f044bee8c4616d6b3ac8ee32f43bb46b1c888dd70823e73574204c32a91dd48b5df73233e217adfc9b19d6a05c2181a4df2974a4cdb1b
7
+ data.tar.gz: 90bd1e9e0c2e30905e1c2b4875c29fdc93b861da2ae26cd3df8441bdd5b5bb973b27a9830fe9c5597593ca398362ebeb2b26e96dcb65d0f4a93c1ae76a56e7ac
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.7.0
6
+
7
+ - Add `to_be_empty` matcher.
8
+ - Avoid unstable `Enumerable#sort_by` method.
9
+
5
10
  ## 0.6.0
6
11
 
7
12
  - Add `to_contain_exactly` matcher.
@@ -14,15 +14,15 @@ module Easytest
14
14
  end
15
15
 
16
16
  def to_be_nil
17
- Matcher::Nil.new(actual: actual, negate: negate).match!
17
+ Matcher::Nil.new(actual: actual, expected: nil, negate: negate).match!
18
18
  end
19
19
 
20
20
  def to_be_true
21
- Matcher::True.new(actual: actual, negate: negate).match!
21
+ Matcher::True.new(actual: actual, expected: true, negate: negate).match!
22
22
  end
23
23
 
24
24
  def to_be_false
25
- Matcher::False.new(actual: actual, negate: negate).match!
25
+ Matcher::False.new(actual: actual, expected: false, negate: negate).match!
26
26
  end
27
27
 
28
28
  def to_be_a(expected)
@@ -37,6 +37,10 @@ module Easytest
37
37
  Matcher::InstanceOf.new(actual: actual, expected: expected, negate: negate).match!
38
38
  end
39
39
 
40
+ def to_be_empty
41
+ Matcher::Empty.new(actual: actual, expected: nil, negate: negate).match!
42
+ end
43
+
40
44
  def to_include(expected)
41
45
  Matcher::Include.new(actual: actual, expected: expected, negate: negate).match!
42
46
  end
@@ -0,0 +1,13 @@
1
+ module Easytest
2
+ module Matcher
3
+ class Empty < Base
4
+ def match?
5
+ actual.empty?
6
+ end
7
+
8
+ def message
9
+ "empty"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,10 +1,6 @@
1
1
  module Easytest
2
2
  module Matcher
3
3
  class False < Base
4
- def initialize(actual:, negate:)
5
- super(actual: actual, expected: false, negate: negate)
6
- end
7
-
8
4
  def match?
9
5
  actual == expected
10
6
  end
@@ -1,10 +1,6 @@
1
1
  module Easytest
2
2
  module Matcher
3
3
  class Nil < Base
4
- def initialize(actual:, negate:)
5
- super(actual: actual, expected: nil, negate: negate)
6
- end
7
-
8
4
  def match?
9
5
  actual.nil?
10
6
  end
@@ -1,10 +1,6 @@
1
1
  module Easytest
2
2
  module Matcher
3
3
  class True < Base
4
- def initialize(actual:, negate:)
5
- super(actual: actual, expected: true, negate: negate)
6
- end
7
-
8
4
  def match?
9
5
  actual == expected
10
6
  end
@@ -24,7 +24,6 @@ module Easytest
24
24
 
25
25
  reports = []
26
26
 
27
-
28
27
  cases_per_file.each do |c|
29
28
  if include_only_case && !c.only?
30
29
  c.skip!
@@ -56,19 +55,7 @@ module Easytest
56
55
  puts "#{Rainbow(" FAIL ").bright.bg(:red)} #{link}"
57
56
  end
58
57
 
59
- reports
60
- .sort_by do |result, _|
61
- case result
62
- when :skipped, :todo
63
- 0
64
- else
65
- 1
66
- end
67
- end
68
- .each do |result, report|
69
- puts report.gsub(/^/, " ").gsub(/^\s+$/, "")
70
- puts "" if result == :failed
71
- end
58
+ print_reports(reports)
72
59
  end
73
60
 
74
61
  if no_tests?
@@ -109,6 +96,20 @@ module Easytest
109
96
  total_count == 0
110
97
  end
111
98
 
99
+ def print_reports(reports)
100
+ unexecuted = [:skipped, :todo]
101
+ indent = " "
102
+
103
+ reports.each do |result, report|
104
+ puts Utils.indent_text(report, indent) if unexecuted.include?(result)
105
+ end
106
+
107
+ reports.each do |result, report|
108
+ puts Utils.indent_text(report, indent) unless unexecuted.include?(result)
109
+ puts "" if result == :failed
110
+ end
111
+ end
112
+
112
113
  def elapsed_time
113
114
  Time.now - start_time
114
115
  end
@@ -20,5 +20,9 @@ module Easytest
20
20
  def pluralize(singular, count)
21
21
  count == 1 ? singular : "#{singular}s"
22
22
  end
23
+
24
+ def indent_text(text, indent_string)
25
+ text.gsub(/^(.+)/, "#{indent_string}\\1")
26
+ end
23
27
  end
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module Easytest
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/easytest.rb CHANGED
@@ -16,6 +16,7 @@ require_relative "easytest/matcher/base"
16
16
  require_relative "easytest/matcher/be"
17
17
  require_relative "easytest/matcher/be_a"
18
18
  require_relative "easytest/matcher/contain_exactly"
19
+ require_relative "easytest/matcher/empty"
19
20
  require_relative "easytest/matcher/equal"
20
21
  require_relative "easytest/matcher/false"
21
22
  require_relative "easytest/matcher/include"
data/sig/easytest.rbs CHANGED
@@ -37,6 +37,9 @@ module Easytest
37
37
  # Expect to be an instance of the given class (module).
38
38
  def to_be_instance_of: (Module expected) -> void
39
39
 
40
+ # Expect to be empty.
41
+ def to_be_empty: () -> void
42
+
40
43
  # Expect to include the given object.
41
44
  def to_include: (untyped expected) -> void
42
45
 
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.6.0
4
+ version: 0.7.0
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-07 00:00:00.000000000 Z
11
+ date: 2022-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -46,6 +46,7 @@ files:
46
46
  - lib/easytest/matcher/be.rb
47
47
  - lib/easytest/matcher/be_a.rb
48
48
  - lib/easytest/matcher/contain_exactly.rb
49
+ - lib/easytest/matcher/empty.rb
49
50
  - lib/easytest/matcher/equal.rb
50
51
  - lib/easytest/matcher/false.rb
51
52
  - lib/easytest/matcher/include.rb