lab42_literate 0.1.0 → 0.1.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/README.md +34 -0
- data/lib/lab42/literate/extractor.rb +0 -1
- data/lib/lab42/literate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af148dabdc4777ca8d0e99ddb16853ceafd4ca5
|
4
|
+
data.tar.gz: e431c6f0d2aa762843140ae80f73fd09ceb3d39b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25db3aefd339b3016e646894321c29503633a77db4924581fbcc4d8f2946df5d4d23640a040b372e086b7deeeb1d2c34a9f8885d06027d11b336ded6d0d7ab6e
|
7
|
+
data.tar.gz: 2d390a643c3a1ce311f456ed0e0d41449db276ee2973368d5dcfae2555ce8fa8a08b5cbf5d6eaa8aa97859dccbd46bd7be09e89d6d6f843dc3e6dde414338069
|
data/README.md
CHANGED
@@ -11,3 +11,37 @@
|
|
11
11
|
|
12
12
|
Just extract code blocks from any file, and run them as specs with a simple `doctest file` in an RSpec example group.
|
13
13
|
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
gem install lab42_literate
|
17
|
+
|
18
|
+
or in Gemfile
|
19
|
+
|
20
|
+
gem 'lab42_literate'
|
21
|
+
|
22
|
+
Then in your `spec_helper`
|
23
|
+
|
24
|
+
require 'lab42/literate'
|
25
|
+
|
26
|
+
which makes the `doctest` method available in all example groupes of type `literate`.
|
27
|
+
|
28
|
+
### Example
|
29
|
+
|
30
|
+
You can write RSpec example code inside a ` ```ruby literate ` block.
|
31
|
+
|
32
|
+
```ruby literate
|
33
|
+
expect(%w{a b c}).not_to be_empty
|
34
|
+
```
|
35
|
+
|
36
|
+
There is an easy way to express `expect(...).to eq(...)` with the following special form...
|
37
|
+
|
38
|
+
```ruby literate
|
39
|
+
1 + 41 #=> 42
|
40
|
+
```
|
41
|
+
|
42
|
+
Then, assuming the above text being inside a file `some_literate.md` one can execute the two examples above
|
43
|
+
with
|
44
|
+
|
45
|
+
RSpec.describe 'example', type: :literate do
|
46
|
+
doctest 'some_literate.md'
|
47
|
+
end
|
@@ -19,7 +19,6 @@ module Lab42::Literate::Extractor extend self
|
|
19
19
|
# Potentially convert alternate equality syntax to class equality synatx, meaning that
|
20
20
|
# \A(.*)\s+#=>\s+(.*)\z => expect(strip($1)).to eq(strip($2))
|
21
21
|
def convert line
|
22
|
-
p line
|
23
22
|
line.chomp.sub(ALTERNATE_EQ_FORM){ |*|
|
24
23
|
%W{#{$1}expect(#{$2}).to eq(#{$3.strip})}.join(' ') }
|
25
24
|
end
|