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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fb556df1f9e8f00edb81eb6fc6db4c0d86d7864dbaedda0a9e559625df7fe98
4
- data.tar.gz: 69296b360896f5a2258884bc59dc26b115648b107242f8f877eecca507b3b371
3
+ metadata.gz: b3ea3a68b2a618eeac53b5988fcf7bef4c767b43899fa158ea5171af5e2b9866
4
+ data.tar.gz: a95753a22dd8b00590b733b9774823a722b883dff39b7e79f60a018386278905
5
5
  SHA512:
6
- metadata.gz: 641237f09a349ea510b93a562d3548e8398409af64c58f03be21499ce42eee8053f0b2fa4d596befdb6ac035747ba761f3e6e494de5c317966554756c74921cc
7
- data.tar.gz: b7100cb9cf8d8b016c4466409fd4a608d569f022e62e20a30bacf90031e65f7047fad2d7d3e758504db4fb64d732a072c4cbb1a8fef853a40e8588a4a17b0230
6
+ metadata.gz: 15dfea09b23cf93667f6b7b2845a60b98e8346ae64b539040e4d17c4562c000035dc391e70258e2d39847e4f591c08cd724dcedd3b053aee38d49d6b37f9cb1d
7
+ data.tar.gz: 51d041f6637b3aa8069511f08ff014fbf610e07c6678604c7e4b5324e6c63daf5d5161a5ffe54b00a1b9391c0123cb958df7cb61c320674f61cc3b0b3eb272e0
@@ -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 eq\! \s}x
16
- SHORT_MATCHES = %r{\s \= \~ \s}x
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
- ast.last.add_example_line(code)
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  class DocRSpec
4
4
  module Version
5
- VERSION = '0.2.1'
5
+ VERSION = '0.2.3'
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: AGPL-3.0-or-later
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) eq! 44
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
- # # example: eq! shorthand for eq
66
+ # === +==>+ equality
68
67
  #
69
- # answer = 42
68
+ # # example: ==> shorthand for eq
70
69
  #
71
- # answer eq! 42
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
- # === +=~+ for match
75
+ # === +~>+ for match
76
76
  #
77
- # # example: =~ shorthand for match
77
+ # # example: ~> shorthand for match
78
78
  #
79
- # "alpha" =~ /\Aa.+a\z/
79
+ # "alpha" ~> /\Aa.+a\z/
80
80
  #
81
81
  # === +is!+ for be_
82
82
  #
83
- # # example: =~ shorthand for be
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
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.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober