probatio 1.1.0 → 1.2.0

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: 341afa67e0fa27ef98742a21d8e5842b132ba812cb9fc702d37793ea702fbeb7
4
- data.tar.gz: fdf5c8a7baface7d2fa2d95ceb2b201364ce0a2c98f5926c5659617a8402cbc2
3
+ metadata.gz: 44efe96384518157bb668fc7ef2969240f04250ebeb861aa27f5a59e6bf9d368
4
+ data.tar.gz: abc011024ad1ae3518cf4882d450f8b38b86f40465ad7b8cec00d35fd23a8a76
5
5
  SHA512:
6
- metadata.gz: 0ec333e78a402d7c77e518bc212c3cb47b40b26e82c807692d924c5d0755d7b460801a527966f0621b06934e66f1961d1db84896b174633bf995135f0c9cca69
7
- data.tar.gz: c8293d3a2d05b726618ab9965ce970841fe82c14d7d35312ce650a8676aaeba873e221bf19dd7a528c690a1575b1558218995ee7ec802359e2fee4092ce541bb
6
+ metadata.gz: 48349c94e1b191132d9285570e4f6f92642c9ce2014e3fc95a13f83d4281a734f48e95a52029b9de2d37eed8119db1f42c13f8b15a1ec3b58347fbd4c6da875d
7
+ data.tar.gz: b1a04070f74486d7201bdea7836b1bd66eae9c981c1bbd0bbcf4da9fc572015c0ef176783943fea9e397bfe3551ee93d1aeb13ec00e8d02f9a63c563544d56cb
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## proba 1.2.0 released 2025-05-19
6
+
7
+ * Introduce Probatio::Context#beep
8
+ * Introduce --beeps {n || 1}
9
+ * Allow for list.rb as 'list'
10
+
11
+
12
+ ## proba 1.1.1 released 2025-05-08
13
+
14
+ * Fix .probatio-output.rb string/number alignment
15
+ * Fix assert_error and assert_no_error
16
+
17
+
5
18
  ## proba 1.1.0 released 2025-04-16
6
19
 
7
20
  * Introduce `assert_no_error { do_this_or_that() }`
data/exe/proba CHANGED
@@ -8,14 +8,29 @@ require 'probatio'
8
8
 
9
9
  args = ARGV.dup
10
10
 
11
- def rework_switch(a)
12
-
13
- case a
14
- when '-n', '--name' then '--name'
15
- when '-e', '--exclude' then '--exclude'
16
- when '-s', '--seed' then '--seed'
17
- when '-d', '--debug' then '--debug'
18
- else nil
11
+ def rework_switch(switches, a, args)
12
+
13
+ arr, k, v =
14
+ case a
15
+ when '-n', '--name'
16
+ [ true, '--name', args.shift ]
17
+ when '-e', '--exclude'
18
+ [ true, '--exclude', args.shift ]
19
+ when '-s', '--seed'
20
+ [ true, '--seed', args.shift ]
21
+ when '-d', '--debug'
22
+ [ true, '--debug', args.shift ]
23
+ when '-b', '--beep', '--beeps'
24
+ [ false, '--beep', (args[0] || '').match?(/^\d+$/) ? args.shift.to_i : 1 ]
25
+ else
26
+ [ false, a, true ]
27
+ end
28
+
29
+ if arr == true
30
+ (switches[k] ||= []) << v
31
+ elsif arr == false
32
+ switches[k] = v
33
+ # else return
19
34
  end
20
35
  end
21
36
 
@@ -31,14 +46,10 @@ dirs, files, lists, strings, environments, integers = [], [], [], [], [], []
31
46
  while a = args.shift
32
47
 
33
48
  if a.match?(/^(-[a-z]|--[a-z0-9][-a-z0-9]+)$/i)
34
- if k = rework_switch(a)
35
- (switches[k] ||= []) << args.shift
36
- else
37
- switches[a] = true
38
- end
49
+ rework_switch(switches, a, args)
39
50
  elsif File.directory?(a) && a != '.'
40
51
  dirs << a
41
- elsif File.file?(a) && (a.match?(/(\.txt|_list\.rb)$/))
52
+ elsif File.file?(a) && (a == 'list.rb' || a.match?(/(\.txt|_list\.rb)$/))
42
53
  lists << a
43
54
  elsif File.file?(a.split(':').first)
44
55
  files << a
@@ -89,6 +100,7 @@ if switches['-h'] || switches['--help']
89
100
  -d, --debug smr 's' for start opts, 'm' for messages, 'r' for $DEBUG
90
101
  -x, --example Outputs an example test file
91
102
  -X, --plugin-example Outputs an example plugin file
103
+ -b, --beeps {n || 1} Beeps n time before exit
92
104
  --mangle Turns the given _spec.rb files into proba _test.rb
93
105
 
94
106
  Dirs:
@@ -168,6 +180,8 @@ opts[:print] = true if switches['-p'] || switches['--print']
168
180
  opts[:dirs] = dirs if dirs.any?
169
181
  opts[:files] = files.any? ? files : []
170
182
 
183
+ opts[:beeps] = switches['--beep']
184
+
171
185
  def read_list(a, item)
172
186
 
173
187
  case item
@@ -210,7 +224,7 @@ integers.each do |i|
210
224
  end
211
225
  lists.each do |li|
212
226
  opts[:files].concat(
213
- li.end_with?('_list.rb') ? read_list([], Kernel.eval(File.read(li))) :
227
+ li.end_with?('.rb') ? read_list([], Kernel.eval(File.read(li))) :
214
228
  read_list([], File.readlines(li)))
215
229
  end
216
230
  #
@@ -138,24 +138,31 @@ 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 }
159
166
  end
160
167
 
161
168
  def assert_not_error(*as, &block)
@@ -165,9 +172,8 @@ class Probatio::Context
165
172
  err = nil;
166
173
  begin; block.call; rescue => err; end
167
174
 
168
- return "no error expected but returned #{err.class} #{err.name}" if err
169
-
170
- true
175
+ do_assert_([]) {
176
+ err && "no error expected but returned #{err.class} #{err.name}" }
171
177
  end
172
178
  alias assert_no_error assert_not_error
173
179
 
@@ -0,0 +1,22 @@
1
+
2
+ #
3
+ # probatio/helpers.rb
4
+
5
+ module Probatio::Helpers
6
+
7
+ def beep(count=1)
8
+
9
+ Probatio.beep(count || 0)
10
+ end
11
+ end
12
+
13
+ class Probatio::Section
14
+
15
+ include Probatio::Helpers
16
+ end
17
+
18
+ class Probatio::Context
19
+
20
+ include Probatio::Helpers
21
+ end
22
+
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
@@ -235,6 +235,29 @@ class Probatio::ProbaOutputter
235
235
  end
236
236
  end
237
237
 
238
+ module Probatio
239
+
240
+ # For easy override...
241
+ #
242
+ def self._beep
243
+
244
+ STDOUT.print("\a")
245
+ end
246
+
247
+ def self.beep(count=1)
248
+
249
+ count.times { Probatio._beep; sleep 0.5 }
250
+ end
251
+ end
252
+
253
+ class Probatio::Beeper
254
+
255
+ def on_exit(ev)
256
+
257
+ Probatio.beep(ev.opts[:beeps])
258
+ end
259
+ end
260
+
238
261
  class Probatio::Exitter
239
262
 
240
263
  def on_exit(ev)
@@ -249,5 +272,6 @@ Probatio.plug(Probatio::Chronometer.new)
249
272
  Probatio.plug(Probatio::DotReporter.new)
250
273
  Probatio.plug(Probatio::VanillaSummarizer.new)
251
274
  Probatio.plug(Probatio::ProbaOutputter.new)
275
+ Probatio.plug(Probatio::Beeper.new)
252
276
  Probatio.plug(Probatio::Exitter.new)
253
277
 
data/lib/probatio.rb CHANGED
@@ -15,7 +15,7 @@ require 'probatio/more'
15
15
 
16
16
  module Probatio
17
17
 
18
- VERSION = '1.1.0'
18
+ VERSION = '1.2.0'
19
19
 
20
20
  class << self
21
21
 
@@ -752,6 +752,10 @@ module Probatio
752
752
  require 'probatio/waiters'
753
753
  #
754
754
  # where wait_* methods are defined...
755
+
756
+ require 'probatio/helpers'
757
+ #
758
+ # where beep and friends are defined...
755
759
  end
756
760
 
757
761
  class AssertionError < StandardError
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.1.0
4
+ version: 1.2.0
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-04-16 00:00:00.000000000 Z
11
+ date: 2025-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorato
@@ -42,6 +42,7 @@ files:
42
42
  - lib/probatio/debug.rb
43
43
  - lib/probatio/examples/a_plugin.rb
44
44
  - lib/probatio/examples/a_test.rb
45
+ - lib/probatio/helpers.rb
45
46
  - lib/probatio/mangle.rb
46
47
  - lib/probatio/more.rb
47
48
  - lib/probatio/plug.rb
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
76
  requirements: []
76
- rubygems_version: 3.5.16
77
+ rubygems_version: 3.5.22
77
78
  signing_key:
78
79
  specification_version: 4
79
80
  summary: test tools for floraison and flor