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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf6d07083021c42a5695d160c5de95cb18cef70ed2cf58fb958498cbc33a3c9c
4
- data.tar.gz: 9c9a5c712f92568e05e1986be11e505b3fd3863023cc2d797b0a964a7e5da2e5
3
+ metadata.gz: 88b53a81c4bec331c6b85e24b65fc358b6ba97940a0bd143ff16949013d121a5
4
+ data.tar.gz: 57a1cc597def53023f2802a1a493a035fcfda2ee25b8074a7f430fa4e73857b8
5
5
  SHA512:
6
- metadata.gz: a4521e7b2c50ddcdc08fe1a064e8aea1580a01a623fe666933892ee8f099b8bf9f6f90bfc18231e00b669f9b6b0be630ada8f413084bd93d7f0daf25c92cde1d
7
- data.tar.gz: 0e9f61a0222ceb65692a17ce532bb8e2684f7b31c49cb918894a02923a23aab51954001d186905423ba30e6e2ce2c7225a335d42c7f6bfd061f988dc033c382b
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')
@@ -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
- case a
144
- when String
145
- return "error message #{err.message} is not #{a.inspect}" \
146
- unless err.message == a
147
- when Regexp
148
- return "error message #{err.message} did not match #{a.inspect}" \
149
- unless err.message.match(a)
150
- when Module
151
- return "error is of class #{err.class} not #{a.name}" \
152
- unless err.is_a?(a)
153
- else
154
- fail ArgumentError.new("assert_error cannot fathom #{a.inspect}")
155
- end
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
- true
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?('"') ? "%#{vl}s" : "%-#{vl}s"
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
@@ -15,7 +15,7 @@ require 'probatio/more'
15
15
 
16
16
  module Probatio
17
17
 
18
- VERSION = '1.0.0'
18
+ VERSION = '1.1.1'
19
19
 
20
20
  class << self
21
21
 
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.0.0
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-02-08 00:00:00.000000000 Z
11
+ date: 2025-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorato