minitest-markdown 0.0.0.pre → 0.0.1.pre
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/.rubocop.yml +4 -1
- data/CHANGELOG.md +7 -0
- data/README.md +12 -10
- data/lib/minitest/assertions_extensions.rb +4 -2
- data/lib/minitest/markdown/test_class.rb +1 -1
- data/lib/minitest/markdown/test_code_block.rb +9 -3
- data/lib/minitest/markdown/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6836d7576d3a208628f401e2660fac20d4288faf95c6513e76dd20a2a402fed2
|
4
|
+
data.tar.gz: 4f38166f7ff54f9a74391daafe8e698a7f0aabc57cf7a3797f292b3b8d85d524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 393bc3aff42df19c5cfd10c2edddb64242798765d30aed3185e44be621547e0ed93f495113cca4082e388ab20f2da213f4f5ad4411b17f6117b1421c531d066a
|
7
|
+
data.tar.gz: a30d096c73f2064311cb2d729305fe5cc1d00cca871575fb75783d8046d28f5fc325d92882ccb886834358ed6a586f36eb397439829fba22f4d875c2f6e61998
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
plugins:
|
3
3
|
- rubocop-minitest
|
4
4
|
- rubocop-performance
|
5
5
|
- rubocop-rake
|
@@ -7,6 +7,9 @@ require:
|
|
7
7
|
AllCops:
|
8
8
|
TargetRubyVersion: 3.1
|
9
9
|
NewCops: enable
|
10
|
+
Exclude:
|
11
|
+
- 'vendor/**/*' # GitLab caching..
|
12
|
+
- test/fixtures/klass.rb
|
10
13
|
|
11
14
|
Lint/InterpolationCheck:
|
12
15
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.0.1.pre] - 2025-04-24
|
4
|
+
|
5
|
+
- Bump minitest dep to >= 5.25.2
|
6
|
+
- Fix 'method redefined' warning in tests
|
7
|
+
- Fix undefined method 'assert' for module 'Minitest::Assertions' in AssertionExtensions
|
8
|
+
- Fix bug with expected value strings with multiple spaces
|
9
|
+
|
3
10
|
## [0.0.0.pre] - 2024-09-26
|
4
11
|
|
5
12
|
- Initial release
|
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[](https://badge.fury.io/rb/minitest-markdown)
|
2
|
+
[](https://github.com/rubocop/rubocop)
|
3
|
+
|
1
4
|
# Minitest extension for testing Ruby code blocks in your README and other Markdown files
|
2
5
|
|
3
6
|
## \_why?
|
@@ -38,24 +41,23 @@ To test Ruby blocks in another Markdown file, create another test file and pass
|
|
38
41
|
|
39
42
|
Each Markdown file is represented by a single test class and each Ruby block in a file becomes a test method with zero or more assertions. The syntax used is `# => ` followed by an assertion keyword. Keywords may be one of the [Minitest "assert_" assertions](https://docs.seattlerb.org/minitest/Minitest/Assertions.html) less the "assert_" prefix (refutations are not implemented at this time). If the keyword is omitted, the default assertion; `assert_equal` is used. The actual value passed to the assertion is the result of the evaluation of the Ruby code above each magic comment. The following block (a single test) includes 3 assertions:
|
40
43
|
```ruby
|
41
|
-
|
42
|
-
class
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
44
|
+
File.read 'test/fixtures/klass.rb'
|
45
|
+
# => "class Klass\n def hello\n 'Hello Markdown!'\n end\nend"
|
46
|
+
|
47
|
+
require 'test/fixtures/klass' # a demonstration
|
48
|
+
# => true
|
47
49
|
|
48
50
|
# ordinary comments are ignored.
|
49
51
|
|
50
|
-
|
52
|
+
Klass.new # inline comments are also ignored
|
51
53
|
# The assertion and expected value are:-
|
52
|
-
# => instance_of
|
54
|
+
# => instance_of Klass
|
53
55
|
|
54
56
|
# No keywword here, so the default assertion is used (assert_equal)
|
55
|
-
|
57
|
+
Klass.new.hello
|
56
58
|
# => 'Hello Markdown!'
|
57
59
|
|
58
|
-
|
60
|
+
Klass.hello
|
59
61
|
# => raises NoMethodError
|
60
62
|
```
|
61
63
|
Plain old `assert` has been aliased as `assert_truthy`, so when expecting a truthy value you should do this:
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'minitest/assertions'
|
4
|
+
|
3
5
|
module Minitest
|
4
6
|
# patch
|
5
7
|
module Assertions
|
@@ -7,11 +9,11 @@ module Minitest
|
|
7
9
|
alias assert_included_in assert_includes
|
8
10
|
|
9
11
|
# extensions
|
10
|
-
module
|
12
|
+
module AssertionsExtensions
|
11
13
|
WITH_BLOCK_EVAL = %i[assert_output assert_pattern assert_raises assert_silent assert_throws refute_pattern].freeze
|
12
14
|
EXPECTED_ACTUAL_REVERSED = %i[assert_includes assert_operator assert_predicate assert_respond_to].freeze
|
13
15
|
end
|
14
16
|
|
15
|
-
Assertions.prepend
|
17
|
+
Assertions.prepend AssertionsExtensions
|
16
18
|
end
|
17
19
|
end
|
@@ -69,7 +69,7 @@ module Minitest
|
|
69
69
|
def evaluation_assertions(assertion_hash, bind)
|
70
70
|
ruby, assertion, args = TestCodeBlock::ASSERTION_KEYS.map { |key| assertion_hash[key] } # order dep
|
71
71
|
|
72
|
-
lmbda = -> { eval(ruby) } # rubocop:disable Security/Eval
|
72
|
+
lmbda = -> { eval(ruby) } # rubocop:disable Security/Eval
|
73
73
|
return unless assertion
|
74
74
|
return eval_with_block(bind, assertion, lmbda, args) if Assertions::WITH_BLOCK_EVAL.include? assertion
|
75
75
|
|
@@ -45,9 +45,15 @@ module Minitest
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def parse(magic_comment_string)
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
assertion = parse_assertion(magic_comment_string)
|
49
|
+
return [DEFAULT_ASSERTION, "[#{magic_comment_string}]"] if assertion.nil?
|
50
|
+
return [assertion, '[]'] if magic_comment_string.split.size == 1
|
51
|
+
|
52
|
+
[assertion, "[#{magic_comment_string.sub(/#{assertion.to_s.sub(ASSERT_, '')}\s+/, '')}]"]
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_assertion(str)
|
56
|
+
self.class.assertions_map[str.split.first.to_sym]
|
51
57
|
end
|
52
58
|
|
53
59
|
def magic_comments
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MatzFan
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: minifyrb
|
@@ -37,6 +36,9 @@ dependencies:
|
|
37
36
|
- - "~>"
|
38
37
|
- !ruby/object:Gem::Version
|
39
38
|
version: '5.25'
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 5.25.2
|
40
42
|
type: :runtime
|
41
43
|
prerelease: false
|
42
44
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,8 +46,10 @@ dependencies:
|
|
44
46
|
- - "~>"
|
45
47
|
- !ruby/object:Gem::Version
|
46
48
|
version: '5.25'
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 5.25.2
|
47
52
|
description: Generates tests for Ruby code blocks in any Markdown file.
|
48
|
-
email:
|
49
53
|
executables: []
|
50
54
|
extensions: []
|
51
55
|
extra_rdoc_files: []
|
@@ -71,7 +75,6 @@ metadata:
|
|
71
75
|
source_code_uri: https://gitlab.com/matzfan/minitest-markdown
|
72
76
|
changelog_uri: https://gitlab.com/matzfan/minitest-markdown/-/blob/master/CHANGELOG.md
|
73
77
|
rubygems_mfa_required: 'true'
|
74
|
-
post_install_message:
|
75
78
|
rdoc_options: []
|
76
79
|
require_paths:
|
77
80
|
- lib
|
@@ -86,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
89
|
- !ruby/object:Gem::Version
|
87
90
|
version: '0'
|
88
91
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
90
|
-
signing_key:
|
92
|
+
rubygems_version: 3.6.7
|
91
93
|
specification_version: 4
|
92
94
|
summary: Turn your README.md Ruby code blocks into testable code.
|
93
95
|
test_files: []
|