doctest2-rspec 0.9.0 → 0.9.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 +4 -4
- data/.tool-versions +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +17 -4
- data/Justfile +1 -1
- data/README.md +1 -1
- data/lib/doctest2/rspec/be_a_valid_doctest.rb +9 -0
- data/lib/doctest2/rspec/doctest_helpers.rb +13 -0
- data/lib/doctest2/{minitest → rspec}/version.rb +2 -2
- data/lib/doctest2/rspec.rb +18 -0
- data/sig/doctest2/{minitest.rbs → rspec.rbs} +1 -1
- metadata +15 -13
- data/lib/doctest2/minitest.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ac6495723d91c5649f961e23e4da8179fad01221df7508efb22c88ac73dd5f9
|
4
|
+
data.tar.gz: 61f4870bcd054b409ab3ed94e1f72b21ccbe72599e75db98f4762359b7cc99db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec5f876e9eaaf4822d3442f9103b9759b1742543c2d4d57e57d7e8ecec0faea830b1d565b92bfb5b42c2a92c31dd09e584748a03561376b5b18043595af79c0
|
7
|
+
data.tar.gz: d43fa961e072aa52f6739adc23b2b1321e9242ea4d890689bffed274d1d2ca2da71cffcffd4d975d15ed5df03490be22624296a81cf58f5f73741234a79b8e7e
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.1.2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,14 +8,14 @@ PATH
|
|
8
8
|
specs:
|
9
9
|
doctest2-rspec (0.1.0)
|
10
10
|
doctest2-core (~> 0.1.0)
|
11
|
-
|
11
|
+
rspec (~> 3.0)
|
12
12
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
16
|
ast (2.4.2)
|
17
|
+
diff-lcs (1.5.0)
|
17
18
|
json (2.6.3)
|
18
|
-
minitest (5.18.0)
|
19
19
|
parallel (1.23.0)
|
20
20
|
parser (3.2.2.1)
|
21
21
|
ast (~> 2.4.1)
|
@@ -23,6 +23,19 @@ GEM
|
|
23
23
|
rake (13.0.6)
|
24
24
|
regexp_parser (2.8.0)
|
25
25
|
rexml (3.2.5)
|
26
|
+
rspec (3.12.0)
|
27
|
+
rspec-core (~> 3.12.0)
|
28
|
+
rspec-expectations (~> 3.12.0)
|
29
|
+
rspec-mocks (~> 3.12.0)
|
30
|
+
rspec-core (3.12.2)
|
31
|
+
rspec-support (~> 3.12.0)
|
32
|
+
rspec-expectations (3.12.3)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.12.0)
|
35
|
+
rspec-mocks (3.12.5)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.12.0)
|
38
|
+
rspec-support (3.12.0)
|
26
39
|
rubocop (1.50.2)
|
27
40
|
json (~> 2.3)
|
28
41
|
parallel (~> 1.10)
|
@@ -39,7 +52,7 @@ GEM
|
|
39
52
|
unicode-display_width (2.4.2)
|
40
53
|
|
41
54
|
PLATFORMS
|
42
|
-
arm64-darwin-
|
55
|
+
arm64-darwin-21
|
43
56
|
|
44
57
|
DEPENDENCIES
|
45
58
|
doctest2-core!
|
@@ -48,4 +61,4 @@ DEPENDENCIES
|
|
48
61
|
rubocop (~> 1.21)
|
49
62
|
|
50
63
|
BUNDLED WITH
|
51
|
-
2.
|
64
|
+
2.3.24
|
data/Justfile
CHANGED
data/README.md
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
::RSpec::Matchers.define :be_a_valid_doctest do |expected|
|
2
|
+
match do |actual|
|
3
|
+
actual.code_evaluation == actual.result_evaluation
|
4
|
+
end
|
5
|
+
|
6
|
+
failure_message do |actual|
|
7
|
+
"\nexpected: #{actual.result_evaluation}\n got: #{actual.code_evaluation}\n\n(compared using ==)\n\nWhile running doctest: \n\t#{actual.code_string}\n"
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Doctest2::RSpec::DoctestHelpers
|
2
|
+
def doctest(source)
|
3
|
+
context "doctests for #{source}" do
|
4
|
+
Doctest2::Core.extract_from(source).each do |doctest|
|
5
|
+
file_location = Pathname.new(doctest.original_file).relative_path_from(Pathname.pwd)
|
6
|
+
|
7
|
+
it "at #{file_location}:#{doctest.line}" do
|
8
|
+
expect(doctest).to be_a_valid_doctest
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'doctest2/core'
|
5
|
+
|
6
|
+
|
7
|
+
require_relative "rspec/version"
|
8
|
+
require_relative "rspec/be_a_valid_doctest"
|
9
|
+
require_relative "rspec/doctest_helpers"
|
10
|
+
|
11
|
+
module Doctest2
|
12
|
+
module RSpec
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.configure do |c|
|
17
|
+
c.extend Doctest2::RSpec::DoctestHelpers
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doctest2-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Qqwy/Marten
|
@@ -25,20 +25,20 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
description: Integrates documentation tests with
|
40
|
+
version: '3.0'
|
41
|
+
description: Integrates documentation tests with RSpec.
|
42
42
|
email:
|
43
43
|
- qqwy@gmx.com
|
44
44
|
executables: []
|
@@ -53,15 +53,17 @@ files:
|
|
53
53
|
- LICENSE.txt
|
54
54
|
- README.md
|
55
55
|
- Rakefile
|
56
|
-
- lib/doctest2/
|
57
|
-
- lib/doctest2/
|
58
|
-
-
|
59
|
-
|
56
|
+
- lib/doctest2/rspec.rb
|
57
|
+
- lib/doctest2/rspec/be_a_valid_doctest.rb
|
58
|
+
- lib/doctest2/rspec/doctest_helpers.rb
|
59
|
+
- lib/doctest2/rspec/version.rb
|
60
|
+
- sig/doctest2/rspec.rbs
|
61
|
+
homepage: https://github.com/Qqwy/ruby-doctest2/
|
60
62
|
licenses:
|
61
63
|
- MIT
|
62
64
|
metadata:
|
63
|
-
homepage_uri: https://github.com/Qqwy/ruby-doctest2
|
64
|
-
source_code_uri: https://github.com/Qqwy/ruby-doctest2
|
65
|
+
homepage_uri: https://github.com/Qqwy/ruby-doctest2/
|
66
|
+
source_code_uri: https://github.com/Qqwy/ruby-doctest2/
|
65
67
|
changelog_uri: https://github.com/Qqwy/ruby-doctest2/blob/main/CHANGELOG.md
|
66
68
|
post_install_message:
|
67
69
|
rdoc_options: []
|
@@ -78,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
80
|
- !ruby/object:Gem::Version
|
79
81
|
version: '0'
|
80
82
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.3.7
|
82
84
|
signing_key:
|
83
85
|
specification_version: 4
|
84
|
-
summary: Run doctests in your
|
86
|
+
summary: Run doctests in your RSpec test suite
|
85
87
|
test_files: []
|
data/lib/doctest2/minitest.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'pathname'
|
4
|
-
require_relative "minitest/version"
|
5
|
-
|
6
|
-
module Doctest2
|
7
|
-
module Minitest
|
8
|
-
module DoctestHelpers
|
9
|
-
def self.included(base)
|
10
|
-
base.extend(ClassMethods)
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
##
|
15
|
-
# To be used inside the body of a tests-class
|
16
|
-
# It will automatically create test cases for all
|
17
|
-
# 'documentation test' snippets that exist in the comments
|
18
|
-
# above the methods in `klass`.
|
19
|
-
def doctest(klass)
|
20
|
-
doctests = Doctest2::Core.extract_from(klass)
|
21
|
-
return puts "Note: Attempting to extract doctests for #{klass}, but none were found (at: #{caller_locations.first})" if doctests.empty?
|
22
|
-
|
23
|
-
doctests.each do |doctest|
|
24
|
-
file_location = Pathname.new(doctest.original_file).relative_path_from(Pathname.pwd)
|
25
|
-
define_method("test_ (doctest) #{file_location}:#{doctest.line}") do
|
26
|
-
message = "While running doctest: \n\t#{doctest.code_string}\n"
|
27
|
-
begin
|
28
|
-
assert_equal(doctest.result_evaluation, doctest.code_evaluation, message)
|
29
|
-
rescue StandardError => error
|
30
|
-
error.message << "\n\n#{message}"
|
31
|
-
raise error
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|