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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e2ea270de14b4a37fd648bde29d59a4f0a2244159d22a06e798c2387faa96f8
4
- data.tar.gz: b3588a664c869b921e789c778be7508f8189628281d2c65796be3c3b31c1d060
3
+ metadata.gz: bf085449bc26e2d09d22632b684aa0bf3ed785332fb48dec6bc9b2c4d34dc8a7
4
+ data.tar.gz: 9a2128d91d1bde271e6c3cc466cf1a0dcae7eef7fd9409afc3f62321dec261ba
5
5
  SHA512:
6
- metadata.gz: 90a3129c0e172feaaae26d3d15cee20df6199d43d9d76676eab7b579038fbbd97c5f129fd4e72ac3ece19be2a4a01b260b60e255d765aa5f5b60478808ef2bfa
7
- data.tar.gz: 31d6850d1534204007cf3953800c9d5a9f1cdf4e2f7e4450e93ca4dbfa44af7ea76fd8bf2e1fc03697f50a248c21eefe1f5d3d2693f76c30b9f564d18cbd59cc
6
+ metadata.gz: 4df3db0c9bd84ef659cc36e244785e0a17c2978149032f3414938a47204548413df52d57e2af8841663dde41d52a6f91b60ff29d8a85268894116dcf4aad309a
7
+ data.tar.gz: 65407d9582ec987d6ebafd1aed813212d2ea33c79e635ea277d8b3bd41b4ecad6183943ab5232d54a94f6ce43b03d4ec06eacf0a58730e0e2122605ea52c1eaa
@@ -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
- compile_example = method(:compile_example)
26
- example_group.context context_spec.context_name(path) do
27
- context_spec.examples.each { compile_example.(it) }
28
- end
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 example_spec.lines.map { "> #{it}" }
49
+ puts code.map { "> #{it}" }
43
50
  puts "=" * 72
44
51
  end
45
52
  return if debug_level > 2
46
53
 
47
- example_group.it example_name do
48
- example = self
49
- eval(code)
50
- end
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)
@@ -2,7 +2,7 @@
2
2
 
3
3
  class DocRSpec
4
4
  module Version
5
- VERSION = '0.2.5'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: AGPL-3.0-or-later
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doc_rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober