probatio 1.2.1 → 1.3.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: cd1f950d5d015ce5c74dea984568661b91aace4fafd7eb7904d6e4ce5a0d378d
4
- data.tar.gz: 0a4b0bfc642e0a4b3e5f1a05b774e75bf9e1abc39c23d44dad0a7198c036ff26
3
+ metadata.gz: f855685ad365c5dfbaa6c719b930f0b5113d35ab47cee5e31dff2c9af994b1f7
4
+ data.tar.gz: be76c4d06ec56b0541bf256b87fede46a30d455bba1c2b55192ebfd3da9fa8e9
5
5
  SHA512:
6
- metadata.gz: 46a775f846dbc48ee13b0626d3dd469e402eee354433e5d7d95ccd1481d6518418e1475afeac0e7cf6c2ebca1df1278c5c1a6f014c2be58e4543f9ac14d3c1ac
7
- data.tar.gz: 33e87186c8baa159a43d1491e3fe580069dd0288337b85a3351380f74a4c2c5a2fc80660efa34b3b48691d4866deb44afcbc7d733d622dd4d7fe6fd4c27b94d8
6
+ metadata.gz: 3192dc95ac4aa5c09e965f25207331ebb8801607c92e9c72fbc6373644be62a2a961ddfce26cdbfc50969aed3e2640b461427ee23896e8c236d946b3908a99a8
7
+ data.tar.gz: 8fb9d38e3a4111d2d968b4a54deb10ce997ac9ea1dd16127d99289ab71789ca825e768d01c770d07e6b23c00fd0945fe80fbe5ce47f3bf97a05cc5cea2718567
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## probatio 1.3.0 released 2025-08-08
6
+
7
+ * Add windows? and jruby? to Probatio::Group
8
+ * Alias `assert_nothing_raised` to `assert_no_error`
9
+
10
+
5
11
  ## probatio 1.2.1 released 2025-05-20
6
12
 
7
13
  * Tighten Probatio.beep and friends
data/README.md CHANGED
@@ -39,6 +39,7 @@ Usage: bundle exec proba [OPTIONS] [DIRS] [FILES] [OTHERS] [ENVS]
39
39
  -d, --debug smr 's' for start opts, 'm' for messages, 'r' for $DEBUG
40
40
  -x, --example Outputs an example test file
41
41
  -X, --plugin-example Outputs an example plugin file
42
+ -b, --beep[s] {n || 1} Beeps n time before exit
42
43
  --mangle Turns the given _spec.rb files into proba _test.rb
43
44
 
44
45
  Dirs:
@@ -174,6 +175,8 @@ group 'core' do
174
175
  assert_no_error lambda { do_this_or_that() }
175
176
  assert_not_error { do_this_or_that() }
176
177
  assert_not_error lambda { do_this_or_that() }
178
+ assert_nothing_raised { do_this_or_that() }
179
+ assert_nothing_raised lambda { do_this_or_that() }
177
180
  # checks that the block or Proc does not raise an error
178
181
 
179
182
  assert_hashy(
@@ -230,6 +233,51 @@ group 'core < sub-core < sub-sub-core' do
230
233
  test 'that' do
231
234
  end
232
235
  end
236
+
237
+
238
+ group 'notcore' do
239
+
240
+ # A section allows for some kind of "inheritance" between groups...
241
+ #
242
+ section 'with db' do
243
+
244
+ setup do
245
+
246
+ prepare_db
247
+ end
248
+
249
+ before do
250
+
251
+ reset_and_load_fixtures
252
+ end
253
+ end
254
+
255
+ group 'alpha' do
256
+
257
+ group 'without db' do
258
+
259
+ # ...
260
+ end
261
+
262
+ group 'with db' do
263
+
264
+ # gets the setup and before from the "with db" section
265
+ end
266
+ end
267
+
268
+ group 'bravo' do
269
+
270
+ group 'without db' do
271
+
272
+ # ...
273
+ end
274
+
275
+ group 'with db' do
276
+
277
+ # gets the setup and before from the "with db" section
278
+ end
279
+ end
280
+ end
233
281
  ```
234
282
 
235
283
 
@@ -276,10 +324,13 @@ some_env:
276
324
  {
277
325
  USER: "jmettraux",
278
326
  HOME: "/home/jmettraux",
279
- PATH: "/home/jmettraux/.gem/ruby/3.3/bin:/home/jmettraux/.pkg_rubies/ruby33:/usr/local/jdk-21/bin:/home/jmettraux/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin",
280
327
  SHELL: "/usr/local/bin/fish",
281
328
  GEM_HOME: "/home/jmettraux/.gem/ruby/3.3",
282
329
  PWD: "/home/jmettraux/w/probatio/test",
330
+ PATH:
331
+ "/home/jmettraux/.gem/ruby/3.3/bin:/home/jmettraux/.pkg_rubies/ruby33:" +
332
+ "/usr/local/jdk-21/bin:/home/jmettraux/bin:/bin:/usr/bin:/sbin:" +
333
+ "/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin",
283
334
  },
284
335
  }
285
336
  ```
@@ -289,6 +340,28 @@ Probatio uses it when servicing `bundle exec proba 0` or `bundle exe proba -1`.
289
340
  It can also be useful to other tools around probatio.
290
341
 
291
342
 
343
+ ## Helpers
344
+
345
+ Built-in helpers:
346
+ ```ruby
347
+ jruby? # => returns true when running on JRuby
348
+ windows? # => returns true when running on Windows
349
+ ```
350
+
351
+ _Waiter_ helpers:
352
+ ```ruby
353
+ wait_for {
354
+ some_condition == true
355
+ }
356
+ wait_for(timeout: 60, frequency: 1) { # wait for 60 seconds, check every sec
357
+ some_condition == true
358
+ }
359
+ wait_until { # wait_until is an alias to wait_for
360
+ some_condition == true
361
+ }
362
+ ```
363
+
364
+
292
365
  ## Warnings
293
366
 
294
367
  ```
data/exe/proba CHANGED
@@ -100,7 +100,7 @@ if switches['-h'] || switches['--help']
100
100
  -d, --debug smr 's' for start opts, 'm' for messages, 'r' for $DEBUG
101
101
  -x, --example Outputs an example test file
102
102
  -X, --plugin-example Outputs an example plugin file
103
- -b, --beeps {n || 1} Beeps n time before exit
103
+ -b, --beep[s] {n || 1} Beeps n time before exit
104
104
  --mangle Turns the given _spec.rb files into proba _test.rb
105
105
 
106
106
  Dirs:
@@ -176,6 +176,7 @@ class Probatio::Context
176
176
  err && "no error expected but returned #{err.class} #{err.name}" }
177
177
  end
178
178
  alias assert_no_error assert_not_error
179
+ alias assert_nothing_raised assert_not_error
179
180
 
180
181
  # Checks whether its "_assert_something", if that's the case,
181
182
  # just flags the assertion as :pending an moves on
@@ -298,13 +299,13 @@ class Probatio::Context
298
299
 
299
300
  def extract_file_and_line(backtrace)
300
301
 
301
- #l = backtrace.find { |l|
302
- # ! l.index('lib/probatio/assertions.rb') &&
303
- # ! l.index('_helper.rb') }
304
- l = backtrace.find { |l| l.index('_test.rb') }
302
+ l =
303
+ backtrace.find { |l| l.index('_test.rb') } ||
304
+ backtrace.find { |l| ! l.index('/lib/probatio/') }
305
+ m =
306
+ l && l.match(/([^:]+):(\d+)/)
305
307
 
306
- m = l && l.match(/([^:]+):(\d+)/)
307
- m && [ m[1], m[2].to_i ]
308
+ m ? [ m[1], m[2].to_i ] : [ nil, -1 ]
308
309
  end
309
310
 
310
311
  def extract_assert_method(backtrace)
@@ -69,6 +69,14 @@ group 'core' do
69
69
  # checks that the given Proc raises an ArgumentError and
70
70
  # the error message == "bad"
71
71
 
72
+ assert_no_error { do_this_or_that() }
73
+ assert_no_error lambda { do_this_or_that() }
74
+ assert_not_error { do_this_or_that() }
75
+ assert_not_error lambda { do_this_or_that() }
76
+ assert_nothing_raised { do_this_or_that() }
77
+ assert_nothing_raised lambda { do_this_or_that() }
78
+ # checks that the block or Proc does not raise an error
79
+
72
80
  assert_hashy(
73
81
  this_thing => 1,
74
82
  that_thing => 'two')
@@ -124,3 +132,48 @@ group 'core < sub-core < sub-sub-core' do
124
132
  end
125
133
  end
126
134
 
135
+
136
+ group 'notcore' do
137
+
138
+ # A section allows for some kind of "inheritance" between groups...
139
+ #
140
+ section 'with db' do
141
+
142
+ setup do
143
+
144
+ prepare_db
145
+ end
146
+
147
+ before do
148
+
149
+ reset_and_load_fixtures
150
+ end
151
+ end
152
+
153
+ group 'alpha' do
154
+
155
+ group 'without db' do
156
+
157
+ # ...
158
+ end
159
+
160
+ group 'with db' do
161
+
162
+ # gets the setup and before from the "with db" section
163
+ end
164
+ end
165
+
166
+ group 'bravo' do
167
+
168
+ group 'without db' do
169
+
170
+ # ...
171
+ end
172
+
173
+ group 'with db' do
174
+
175
+ # gets the setup and before from the "with db" section
176
+ end
177
+ end
178
+ end
179
+
@@ -8,6 +8,22 @@ module Probatio::Helpers
8
8
 
9
9
  Probatio.beep(count || 0)
10
10
  end
11
+
12
+ def jruby?
13
+
14
+ !! RUBY_PLATFORM.match?(/java/)
15
+ end
16
+
17
+ def windows?
18
+
19
+ Gem.win_platform?
20
+ end
21
+ end
22
+
23
+
24
+ class Probatio::Group
25
+
26
+ include Probatio::Helpers
11
27
  end
12
28
 
13
29
  class Probatio::Section
data/lib/probatio.rb CHANGED
@@ -15,7 +15,7 @@ require 'probatio/more'
15
15
 
16
16
  module Probatio
17
17
 
18
- VERSION = '1.2.1'
18
+ VERSION = '1.3.0'
19
19
 
20
20
  class << self
21
21
 
@@ -845,6 +845,8 @@ module Probatio
845
845
 
846
846
  def select_source_lines(path, line)
847
847
 
848
+ return [] unless path
849
+
848
850
  File.readlines(path).each_with_index.to_a[line - 1..-1]
849
851
  .map { |l, i| [ i + 1, l.rstrip ] }
850
852
  .take_while { |_, l|
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.2.1
4
+ version: 1.3.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-05-20 00:00:00.000000000 Z
11
+ date: 2025-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorato