probatio 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +6 -0
- data/lib/probatio/assertions.rb +33 -14
- data/lib/probatio/more.rb +1 -1
- data/lib/probatio.rb +1 -1
- 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: 88b53a81c4bec331c6b85e24b65fc358b6ba97940a0bd143ff16949013d121a5
|
4
|
+
data.tar.gz: 57a1cc597def53023f2802a1a493a035fcfda2ee25b8074a7f430fa4e73857b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51322b38ee2f79751edf9548aa952eee86d78adf8b474f7fecac986d0801a706f6572472abf2f3b6d37b855540359ab901653bed1112c2bd135bf910f576ecbb
|
7
|
+
data.tar.gz: dcfc3956914f0511584021556aa031d2d73f52a9aacfff4ebcec9f3be6aa8860c73db8e9a6ab102d2212f657ed2c7b99ee3bf7b5850599feb50589395be02f4a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
# CHANGELOG.md
|
3
3
|
|
4
4
|
|
5
|
+
## proba 1.1.1 released 2025-05-08
|
6
|
+
|
7
|
+
* Fix .probatio-output.rb string/number alignment
|
8
|
+
* Fix assert_error and assert_no_error
|
9
|
+
|
10
|
+
|
11
|
+
## proba 1.1.0 released 2025-04-16
|
12
|
+
|
13
|
+
* Introduce `assert_no_error { do_this_or_that() }`
|
14
|
+
|
15
|
+
|
5
16
|
## proba 1.0.0 released 2025-02-08
|
6
17
|
|
7
18
|
* Initial release
|
data/README.md
CHANGED
@@ -170,6 +170,12 @@ group 'core' do
|
|
170
170
|
# checks that the given Proc raises an ArgumentError and
|
171
171
|
# the error message == "bad"
|
172
172
|
|
173
|
+
assert_no_error { do_this_or_that() }
|
174
|
+
assert_no_error lambda { do_this_or_that() }
|
175
|
+
assert_not_error { do_this_or_that() }
|
176
|
+
assert_not_error lambda { do_this_or_that() }
|
177
|
+
# checks that the block or Proc does not raise an error
|
178
|
+
|
173
179
|
assert_hashy(
|
174
180
|
this_thing => 1,
|
175
181
|
that_thing => 'two')
|
data/lib/probatio/assertions.rb
CHANGED
@@ -138,25 +138,44 @@ class Probatio::Context
|
|
138
138
|
|
139
139
|
return "no error raised" unless err.is_a?(StandardError)
|
140
140
|
|
141
|
+
s = nil
|
142
|
+
|
141
143
|
as.each do |a|
|
142
144
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
145
|
+
s ||=
|
146
|
+
case a
|
147
|
+
when String
|
148
|
+
if err.message != a
|
149
|
+
msg = err.message.sub(/\s*Did you mean\?.+/, '')
|
150
|
+
"error message #{msg.inspect} is not #{a.inspect}"
|
151
|
+
else
|
152
|
+
nil
|
153
|
+
end
|
154
|
+
when Regexp
|
155
|
+
! err.message.match(a) ?
|
156
|
+
"error message #{err.message} did not match #{a.inspect}" : nil
|
157
|
+
when Module
|
158
|
+
! err.is_a?(a) ?
|
159
|
+
"error is of class #{err.class} not #{a.name}" : nil
|
160
|
+
else
|
161
|
+
fail ArgumentError.new("assert_error cannot fathom #{a.inspect}")
|
162
|
+
end
|
156
163
|
end
|
157
164
|
|
158
|
-
|
165
|
+
do_assert_(as) { s }
|
166
|
+
end
|
167
|
+
|
168
|
+
def assert_not_error(*as, &block)
|
169
|
+
|
170
|
+
block = block || as.find { |a| a.is_a?(Proc) }
|
171
|
+
|
172
|
+
err = nil;
|
173
|
+
begin; block.call; rescue => err; end
|
174
|
+
|
175
|
+
do_assert_([]) {
|
176
|
+
err && "no error expected but returned #{err.class} #{err.name}" }
|
159
177
|
end
|
178
|
+
alias assert_no_error assert_not_error
|
160
179
|
|
161
180
|
# Checks whether its "_assert_something", if that's the case,
|
162
181
|
# just flags the assertion as :pending an moves on
|
data/lib/probatio/more.rb
CHANGED
@@ -136,7 +136,7 @@ module Cerata; class << self
|
|
136
136
|
k, v = kv[0].to_s, kv[1].inspect
|
137
137
|
kl, vl = key_widths[k], val_widths[k]
|
138
138
|
kf = "%#{kl}s"
|
139
|
-
vf = v.start_with?('"') ? "
|
139
|
+
vf = (v.is_a?(String) && v.start_with?('"')) ? "%-#{vl}s" : "%#{vl}s"
|
140
140
|
o << ("#{kf}: #{vf}" % [ k, v ])
|
141
141
|
o << ', ' if kvs.any?
|
142
142
|
end
|
data/lib/probatio.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: probatio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorato
|