doc_rspec 0.2.1 → 0.2.3
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/parser.rb +9 -3
- data/lib/doc_rspec/version.rb +1 -1
- data/lib/doc_rspec.rb +17 -10
- 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: b3ea3a68b2a618eeac53b5988fcf7bef4c767b43899fa158ea5171af5e2b9866
|
4
|
+
data.tar.gz: a95753a22dd8b00590b733b9774823a722b883dff39b7e79f60a018386278905
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15dfea09b23cf93667f6b7b2845a60b98e8346ae64b539040e4d17c4562c000035dc391e70258e2d39847e4f591c08cd724dcedd3b053aee38d49d6b37f9cb1d
|
7
|
+
data.tar.gz: 51d041f6637b3aa8069511f08ff014fbf610e07c6678604c7e4b5324e6c63daf5d5161a5ffe54b00a1b9391c0123cb958df7cb61c320674f61cc3b0b3eb272e0
|
data/lib/doc_rspec/parser.rb
CHANGED
@@ -12,9 +12,10 @@ class DocRSpec
|
|
12
12
|
|
13
13
|
EXAMPLE_LINE = %r{\A \s* \# \s{4,} (.*)}x
|
14
14
|
|
15
|
-
SHORT_EQUALS = %r{\s
|
16
|
-
SHORT_MATCHES = %r{\s
|
15
|
+
SHORT_EQUALS = %r{\s \=\=\> \s}x
|
16
|
+
SHORT_MATCHES = %r{\s \~\> \s}x
|
17
17
|
SHORT_PREDICATE = %r{\s is\! \s}x
|
18
|
+
SHORT_ANTIPREDICATE = %r{\s not\! \s}x
|
18
19
|
START_EXAMPLE = %r{\A \s* \# \s{4,} \# \s example: \s (.*)}x
|
19
20
|
|
20
21
|
attr_reader :ast, :lines, :state
|
@@ -64,7 +65,12 @@ class DocRSpec
|
|
64
65
|
in [lhs, rhs]
|
65
66
|
ast.last.add_example_line("expect(#{lhs}).to be_#{rhs}")
|
66
67
|
else
|
67
|
-
|
68
|
+
case code.split(SHORT_ANTIPREDICATE)
|
69
|
+
in [lhs, rhs]
|
70
|
+
ast.last.add_example_line("expect(#{lhs}).not_to be_#{rhs}")
|
71
|
+
else
|
72
|
+
ast.last.add_example_line(code)
|
73
|
+
end
|
68
74
|
end
|
69
75
|
end
|
70
76
|
end
|
data/lib/doc_rspec/version.rb
CHANGED
data/lib/doc_rspec.rb
CHANGED
@@ -44,7 +44,7 @@ RSpec.configure { it.extend DocRSpec::RSpecExampleGroup }
|
|
44
44
|
#
|
45
45
|
# # example: We have access to the wrapping context
|
46
46
|
#
|
47
|
-
# this_is_available(22)
|
47
|
+
# this_is_available(22) ==> 44
|
48
48
|
#
|
49
49
|
# This implies two thing
|
50
50
|
#
|
@@ -62,29 +62,36 @@ RSpec.configure { it.extend DocRSpec::RSpecExampleGroup }
|
|
62
62
|
#
|
63
63
|
# In addition to _standard_ +RSpec+ code, one can use 3 shorthand forms that are compiled as follows
|
64
64
|
#
|
65
|
-
# === +eq!+
|
66
65
|
#
|
67
|
-
#
|
66
|
+
# === +==>+ equality
|
68
67
|
#
|
69
|
-
#
|
68
|
+
# # example: ==> shorthand for eq
|
70
69
|
#
|
71
|
-
#
|
70
|
+
# true => true
|
71
|
+
# answer = 42
|
72
|
+
# answer ==> 42
|
72
73
|
#
|
73
|
-
# this was compiled to <tt>expect(answer).to eq(42)</tt>
|
74
74
|
#
|
75
|
-
# ===
|
75
|
+
# === +~>+ for match
|
76
76
|
#
|
77
|
-
# # example:
|
77
|
+
# # example: ~> shorthand for match
|
78
78
|
#
|
79
|
-
# "alpha"
|
79
|
+
# "alpha" ~> /\Aa.+a\z/
|
80
80
|
#
|
81
81
|
# === +is!+ for be_
|
82
82
|
#
|
83
|
-
# # example:
|
83
|
+
# # example: is! shorthand for be
|
84
84
|
#
|
85
85
|
# require 'ostruct'
|
86
86
|
# OpenStruct.new(ok?: true) is! ok
|
87
87
|
#
|
88
|
+
# === +not!+ for not be_
|
89
|
+
#
|
90
|
+
# # example: is! shorthand for be
|
91
|
+
#
|
92
|
+
# require 'ostruct'
|
93
|
+
# OpenStruct.new(ok?: false) not! ok
|
94
|
+
#
|
88
95
|
class DocRSpec
|
89
96
|
|
90
97
|
attr_reader :example_group, :lines, :path
|