minitest-markdown 0.0.0 → 0.0.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: 9d404e86afc3911d3c33f3c6db07e8895fcba5dca70490ceebe23d7e419f18fd
4
- data.tar.gz: 6943203dde54269f4c4b4932d0aca354fc6a90b9531ca587956cdc6f90bb4686
3
+ metadata.gz: 497033589078efbc020edf7c16075dc2c72af705ef81b947ef9e3f9532abdae3
4
+ data.tar.gz: c2919ce835a3dd9326cf66efdabd6fa2a739459cb236b3ac4b4dd5d1102784e1
5
5
  SHA512:
6
- metadata.gz: 8975c4e35527de62d85c8e92298fe67789ae74e1dcec8b39f2d3edf0527d78ea40ab995b8a08c6e5c303acb2b9bcb2957986a24d225a0f6003e438efdee46671
7
- data.tar.gz: 92578fe079a4cf4d90e5b74a3dc629b0517dbae6bdd0a08c236d9ce0f2b6ddb7fa36f380a315165006e2a3e5637b3d8bca5604d52124b0a2275c44bc26880695
6
+ metadata.gz: 152b82cbb368756281c6da8523de466e35a4a546c748282769282bfcf5cf799b66e8ba380246dda6e4c700589d2fbe5708d0d150de21c201b1d76254029721ee
7
+ data.tar.gz: bc042b387c85a1e1a57372a825064b54665fe1e541933b1e74d3c2932ee765477b334c4bbb7d2272fac6bfb5fbbfe6df0c2c1a6c7202ff1e2544a8cf8f2c6a99
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.1] - 2025-05-22
4
+
5
+ - Fix bug with Minitest::Hooks method definitions
6
+
3
7
  ## [0.0.0] - 2025-05-10
4
8
 
5
9
  - Fix bug in TestCodeBlock error message
data/README.md CHANGED
@@ -41,8 +41,11 @@ To test the Ruby blocks in your README file, create file `test_readme.rb` (for e
41
41
  ```ruby
42
42
  require 'minitest/autorun' # or in your test_helper
43
43
  require 'minitest/markdown' # ditto
44
+ require 'minitest/hooks/test' # optional, see 'State' section below
44
45
 
45
46
  class ReadmeTest < Minitest::Test # or your own subclass of Minitest::Test
47
+ include Minitest::Hooks # optional, see 'State' section below
48
+
46
49
  Markdown.generate_markdown_tests(self)
47
50
  end
48
51
  # => truthy
@@ -114,6 +117,9 @@ Instance vars are shared across test methods within a class, but as Minitest's d
114
117
  ```ruby
115
118
  @instance_var
116
119
  # => 7
120
+
121
+ @before_all_instance_var # see hook methods below
122
+ # => 'foo'
117
123
  ```
118
124
  Minitest's `setup` and `teardown` methods are generated by using the appropriate comment on the first line of a code block. Assertion magic comments are ignored in such blocks, as these are not tests. E.g.
119
125
 
@@ -122,15 +128,19 @@ Minitest's `setup` and `teardown` methods are generated by using the appropriate
122
128
 
123
129
  # do some setup task - or:-
124
130
  @instance_var = 7 # now available in all test method blocks, including the one above
125
- # => ignored
131
+ # => IGNORED
126
132
  ```
127
133
  ```ruby
128
134
  # teardown
129
135
 
130
136
  # do some teardown task
131
137
  ```
132
- The hook methods defined in the [minitest-hooks](https://github.com/jeremyevans/minitest-hooks?tab=readme-ov-file#in-tests-minitesttest-) extension (`before_all`, `after_all`, `around` & `around_all`)are also available in this way if `minitest-hooks` is installed and `Minitest::Hooks` is included in your test class.
138
+ The hook methods defined in the [minitest-hooks](https://github.com/jeremyevans/minitest-hooks?tab=readme-ov-file#in-tests-minitesttest-) extension (`before_all`, `after_all`, `around` & `around_all`)are also available in this way if `minitest-hooks` is installed and `Minitest::Hooks` is included in your markdown test class. See the 'In your test class' section above for an example. You can now do this:
133
139
 
140
+ ```ruby
141
+ # before_all
142
+ @before_all_instance_var = 'foo'
143
+ ```
134
144
 
135
145
  Everything in the Ruby code blocks above and below here runs as test code. [minitest-proveit](https://github.com/seattlerb/minitest-proveit) would complain otherwise ;-)
136
146
 
@@ -9,16 +9,13 @@ module Minitest
9
9
  module Markdown
10
10
  # A Ruby code block representing test code, with 0 or more assertions or a 'state' block
11
11
  class RubyCodeBlock
12
- ASSERT_ = 'assert_'
13
- ASSERT_REGEXP = /\A#{ASSERT_}/
14
- SKIP = { skip: :skip }.freeze
12
+ ASSERT_ = 'assert_'
13
+ ASSERT_REGEXP = /\A#{ASSERT_}/
14
+ SKIP = { skip: :skip }.freeze
15
15
  DEFAULT_ASSERTION = :assert_equal
16
16
 
17
- ASSERTION_KEYS = %i[ruby assertion test_args].freeze
18
-
19
- HOOK_METHODS = %i[before_all after_all around around_all].freeze # minitest-hooks extension
20
- STATE_METHODS = %i[setup teardown].freeze
21
- STATE_BLOCK_TYPES = Minitest.const_defined?(:Hooks) ? STATE_METHODS + HOOK_METHODS : STATE_METHODS
17
+ ASSERTION_KEYS = %i[ruby assertion test_args].freeze
18
+ STATE_BLOCK_TYPES = %i[setup teardown before_all after_all around around_all].freeze
22
19
 
23
20
  MAGIC_COMMENT_REGEXP = /^\s*#\s*=>.*$/
24
21
  MAGIC_COMMENT_SCAN_REGEXP = /^\s*#\s*=>\s*(.*)$/ # strips delimiter prefix
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minitest
4
4
  module Markdown
5
- VERSION = '0.0.0'
5
+ VERSION = '0.0.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MatzFan
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.6.8
107
+ rubygems_version: 3.7.0.dev
108
108
  specification_version: 4
109
109
  summary: Turn your README.md Ruby code blocks into testable code.
110
110
  test_files: []