doc_rspec 0.2.5 → 0.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 +4 -4
- data/lib/doc_rspec/compiler.rb +18 -10
- data/lib/doc_rspec/version.rb +1 -1
- data/lib/doc_rspec.rb +11 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf085449bc26e2d09d22632b684aa0bf3ed785332fb48dec6bc9b2c4d34dc8a7
|
4
|
+
data.tar.gz: 9a2128d91d1bde271e6c3cc466cf1a0dcae7eef7fd9409afc3f62321dec261ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4df3db0c9bd84ef659cc36e244785e0a17c2978149032f3414938a47204548413df52d57e2af8841663dde41d52a6f91b60ff29d8a85268894116dcf4aad309a
|
7
|
+
data.tar.gz: 65407d9582ec987d6ebafd1aed813212d2ea33c79e635ea277d8b3bd41b4ecad6183943ab5232d54a94f6ce43b03d4ec06eacf0a58730e0e2122605ea52c1eaa
|
data/lib/doc_rspec/compiler.rb
CHANGED
@@ -22,10 +22,18 @@ class DocRSpec
|
|
22
22
|
# Inside the block of example_group.context we are not
|
23
23
|
# in this instances context anymore, therefore we need
|
24
24
|
# to access the `compile_example` method via a closure
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
inner_lines =
|
26
|
+
context_spec
|
27
|
+
.examples
|
28
|
+
.flat_map { compile_example it }
|
29
|
+
|
30
|
+
code = [
|
31
|
+
%{context #{context_spec.context_name(path).inspect} do},
|
32
|
+
*inner_lines,
|
33
|
+
'end'
|
34
|
+
]
|
35
|
+
|
36
|
+
example_group.instance_eval(code.join("\n"))
|
29
37
|
end
|
30
38
|
|
31
39
|
def compile_example(example_spec)
|
@@ -33,21 +41,21 @@ class DocRSpec
|
|
33
41
|
# this method as a function into a closure
|
34
42
|
code = example_spec
|
35
43
|
.lines
|
36
|
-
.join("\n")
|
37
44
|
return if code.empty?
|
38
45
|
|
39
46
|
example_name = example_spec.it_name(path)
|
40
47
|
if debug_level > 1
|
41
48
|
puts "Example: #{example_name}"
|
42
|
-
puts
|
49
|
+
puts code.map { "> #{it}" }
|
43
50
|
puts "=" * 72
|
44
51
|
end
|
45
52
|
return if debug_level > 2
|
46
53
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
54
|
+
[
|
55
|
+
%{it #{example_name.inspect} do},
|
56
|
+
code,
|
57
|
+
'end'
|
58
|
+
]
|
51
59
|
end
|
52
60
|
|
53
61
|
def compile_example_line(line, example)
|
data/lib/doc_rspec/version.rb
CHANGED
data/lib/doc_rspec.rb
CHANGED
@@ -8,6 +8,7 @@ require_relative 'doc_rspec/parser'
|
|
8
8
|
RSpec.configure { it.extend DocRSpec::RSpecExampleGroup }
|
9
9
|
|
10
10
|
##
|
11
|
+
#
|
11
12
|
# = Code
|
12
13
|
#
|
13
14
|
# can be found [at Codeberg](https://codeberg.org/lab419/doc_rspec)
|
@@ -102,13 +103,6 @@ RSpec.configure { it.extend DocRSpec::RSpecExampleGroup }
|
|
102
103
|
# expect(1).to eq(1)
|
103
104
|
# # and this ==> too
|
104
105
|
#
|
105
|
-
# === End of Example
|
106
|
-
#
|
107
|
-
# the code does not continue after the rdoc comment
|
108
|
-
|
109
|
-
# # not a problem
|
110
|
-
# raise "This should never happen"
|
111
|
-
#
|
112
106
|
class DocRSpec
|
113
107
|
|
114
108
|
attr_reader :example_group, :lines, :path
|
@@ -126,4 +120,14 @@ class DocRSpec
|
|
126
120
|
end
|
127
121
|
|
128
122
|
end
|
123
|
+
|
124
|
+
##
|
125
|
+
#
|
126
|
+
# === End of Example
|
127
|
+
#
|
128
|
+
# the code does not continue after the rdoc comment
|
129
|
+
|
130
|
+
# # not a problem
|
131
|
+
# raise "This should never happen"
|
132
|
+
#
|
129
133
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|