doc_rspec 0.2.2 → 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 +7 -1
- data/lib/doc_rspec/version.rb +1 -1
- data/lib/doc_rspec.rb +7 -0
- 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
@@ -15,6 +15,7 @@ class DocRSpec
|
|
15
15
|
SHORT_EQUALS = %r{\s \=\=\> \s}x
|
16
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
@@ -85,6 +85,13 @@ RSpec.configure { it.extend DocRSpec::RSpecExampleGroup }
|
|
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
|