rspec-documentation 0.0.4 → 0.0.5

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: a33d3b35a6feaea6cdb730424eabca522ee5592f7e944b9c751713b12c3c35d5
4
- data.tar.gz: 90be4151f65ecb8e0e4a74f70c85cdae67df5d78ed31acd0cc2fa2c7da72a2f2
3
+ metadata.gz: 283bdf52a7ed9f190175ab2d12dc9e1d206a90b0cfdb439713e506921efb2853
4
+ data.tar.gz: acab855a9d1ce848cf6d11fd5662a99b61d7ac1349ac49edb46519c59e327463
5
5
  SHA512:
6
- metadata.gz: f357c76176c0f5cc9a2061a51dfa3fceb59f05d75fe5173ed211dee64e1e4c07bb6309448757f1172f7b79f4b80f0c55c8fca99ca430eb17bb2b1766390ca1de
7
- data.tar.gz: b5598da557e010fb880dd001297d5d7796f46b7f2f2e7bf39847eec33073402f852f14f8113474c3ba00f950ee5b53b20af2d259b584a0bd5fe23cac707591bb
6
+ metadata.gz: ca29bcf6ad430a865f329586db18807a8d5b2f07f545051b803ed936d4c4bf606d2b1cc554b09db575cc813b48ba6538aac000a01b047a2a76d75daafe7444f2
7
+ data.tar.gz: 38d5455b372da3ea5798acdd10e28c86bfec33bc4ab697417122edc3a0d7912d257b16af3c245601fdba7a20c2aad185ec15160ee2fb9b821dd6e938a6a94ce5
data/Gemfile CHANGED
@@ -8,10 +8,11 @@ gemspec
8
8
  gem 'rake', '~> 13.0'
9
9
 
10
10
  gem 'devpack', '~> 0.4.1'
11
+ gem 'nokogiri', '~> 1.15'
11
12
  gem 'rspec', '~> 3.0'
12
13
  gem 'rspec-file_fixtures', '~> 0.1.6'
13
14
  gem 'rspec-its', '~> 1.3'
14
- gem 'rubocop', '~> 1.51'
15
+ gem 'rubocop', '~> 1.52'
15
16
  gem 'rubocop-rake', '~> 0.6.0'
16
17
  gem 'rubocop-rspec', '~> 2.22'
17
18
  gem 'strong_versions', '~> 0.4.5'
data/Gemfile.lock CHANGED
@@ -5,6 +5,7 @@ PATH
5
5
  htmlbeautifier (~> 1.4)
6
6
  kramdown (~> 2.4)
7
7
  kramdown-parser-gfm (~> 1.1)
8
+ nokogiri (~> 1.15)
8
9
  paintbrush (~> 0.1.3)
9
10
  redcarpet (~> 3.6)
10
11
  rouge (~> 4.1)
@@ -25,11 +26,14 @@ GEM
25
26
  rexml
26
27
  kramdown-parser-gfm (1.1.0)
27
28
  kramdown (~> 2.0)
29
+ nokogiri (1.15.2-x86_64-linux)
30
+ racc (~> 1.4)
28
31
  paint (2.3.0)
29
32
  paintbrush (0.1.3)
30
33
  parallel (1.23.0)
31
34
  parser (3.2.2.1)
32
35
  ast (~> 2.4.1)
36
+ racc (1.6.2)
33
37
  rainbow (3.1.1)
34
38
  rake (13.0.6)
35
39
  redcarpet (3.6.0)
@@ -54,7 +58,7 @@ GEM
54
58
  diff-lcs (>= 1.2.0, < 2.0)
55
59
  rspec-support (~> 3.12.0)
56
60
  rspec-support (3.12.0)
57
- rubocop (1.51.0)
61
+ rubocop (1.52.0)
58
62
  json (~> 2.3)
59
63
  parallel (~> 1.10)
60
64
  parser (>= 3.2.0.0)
@@ -64,7 +68,7 @@ GEM
64
68
  rubocop-ast (>= 1.28.0, < 2.0)
65
69
  ruby-progressbar (~> 1.7)
66
70
  unicode-display_width (>= 2.4.0, < 3.0)
67
- rubocop-ast (1.28.1)
71
+ rubocop-ast (1.29.0)
68
72
  parser (>= 3.2.1.0)
69
73
  rubocop-capybara (2.18.0)
70
74
  rubocop (~> 1.41)
@@ -87,12 +91,13 @@ PLATFORMS
87
91
 
88
92
  DEPENDENCIES
89
93
  devpack (~> 0.4.1)
94
+ nokogiri (~> 1.15)
90
95
  rake (~> 13.0)
91
96
  rspec (~> 3.0)
92
97
  rspec-documentation!
93
98
  rspec-file_fixtures (~> 0.1.6)
94
99
  rspec-its (~> 1.3)
95
- rubocop (~> 1.51)
100
+ rubocop (~> 1.52)
96
101
  rubocop-rake (~> 0.6.0)
97
102
  rubocop-rspec (~> 2.22)
98
103
  strong_versions (~> 0.4.5)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Documentation
5
- VERSION = '0.0.4'
5
+ VERSION = '0.0.5'
6
6
  end
7
7
  end
@@ -16,7 +16,9 @@ module RSpecDocumentation
16
16
  def rendered_output
17
17
  formatter = Rouge::Formatters::HTML.new
18
18
  lexer = Rouge::Lexers::Ruby.new
19
- formatter.format(lexer.lex(subject.inspect))
19
+ io = StringIO.new
20
+ PP.pp(subject, io)
21
+ formatter.format(lexer.lex(io.string))
20
22
  end
21
23
 
22
24
  def render_raw?
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpecDocumentation
4
+ module Formatters
5
+ # Produces prettified XML to from an RSpec `subject` value.
6
+ class Xml
7
+ def initialize(subject:)
8
+ @subject = subject
9
+ end
10
+
11
+ def prettified_output
12
+ nil
13
+ end
14
+
15
+ def rendered_output
16
+ formatter = Rouge::Formatters::HTML.new
17
+ lexer = Rouge::Lexers::XML.new
18
+ formatter.format(lexer.lex(Nokogiri::XML.parse(subject).to_xml))
19
+ end
20
+
21
+ def render_raw?
22
+ false
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :subject
28
+ end
29
+ end
30
+ end
@@ -5,6 +5,7 @@ require_relative 'formatters/html'
5
5
  require_relative 'formatters/ansi'
6
6
  require_relative 'formatters/json'
7
7
  require_relative 'formatters/yaml'
8
+ require_relative 'formatters/xml'
8
9
 
9
10
  module RSpecDocumentation
10
11
  # Provides a set of formatters for rendering the value of a `subject` in an RSpec example into
@@ -47,7 +47,8 @@ module RSpecDocumentation
47
47
  html: Formatters::Html,
48
48
  ansi: Formatters::Ansi,
49
49
  json: Formatters::Json,
50
- yaml: Formatters::Yaml
50
+ yaml: Formatters::Yaml,
51
+ xml: Formatters::Xml
51
52
  }.fetch(spec.format, Formatters::Ruby).new(subject: spec.subject)
52
53
  end
53
54
 
@@ -7,7 +7,7 @@ module RSpecDocumentation
7
7
  attr_reader :failures, :page_paths
8
8
 
9
9
  def initialize(page_paths:)
10
- @page_paths = page_paths.sort
10
+ @page_paths = page_paths.sort_by(&:to_s)
11
11
  @buffer = {}
12
12
  @failures = []
13
13
  end
@@ -24,7 +24,6 @@ module RSpecDocumentation
24
24
  def subject
25
25
  raise Error, "Code block did not define an example (e.g. with `it`).\n#{spec}" if examples.empty?
26
26
  raise Error, "Code block did not define a subject:\n#{spec}" if subjects.empty?
27
- raise Error, "Cannot define more than one example per code block:\n#{spec}" if subjects.size > 1
28
27
 
29
28
  subjects.last
30
29
  end
@@ -74,7 +73,7 @@ module RSpecDocumentation
74
73
  @example_group ||= binding.eval(
75
74
  <<-SPEC, __FILE__, __LINE__.to_i
76
75
  ::RSpec::Core::ExampleGroup.describe do
77
- after { RSpecDocumentation::Spec.subjects << subject }
76
+ after { RSpecDocumentation::Spec.subjects << subject if RSpecDocumentation::Spec.subjects.empty? }
78
77
  include_context '__rspec_documentation' do
79
78
  #{spec}
80
79
  end
@@ -17,6 +17,8 @@ require 'json'
17
17
  require 'yaml'
18
18
  require 'date'
19
19
  require 'time'
20
+ require 'pp' # rubocop:disable Lint/RedundantRequireStatement
21
+ require 'stringio'
20
22
 
21
23
  require_relative 'rspec_documentation/rspec'
22
24
  require_relative 'rspec_documentation/util'
@@ -18,6 +18,6 @@ it { is_expected.to eql 'my subject' }
18
18
  ```
19
19
  ````
20
20
 
21
- See the [Quickstart](introduction/quickstart.html) setup guide to build your first _RSpec Documentation_ project.
21
+ See the [Quickstart](quickstart.html) setup guide to build your first _RSpec Documentation_ project.
22
22
 
23
23
  Browse the [Examples](examples.html) to get a better idea of the typical usage patterns.
@@ -6,7 +6,7 @@ This example uses a regular ```` ```rspec ```` code block.
6
6
 
7
7
  The spec defines a `subject`, a simple comparison is made on its value to satisfy the test, and the value of `subject` is viewable on the _Output_ tab.
8
8
 
9
- Any _RSpec_ test is valid, including one-liner syntax like this:
9
+ Any _RSpec_ test that defines a `subject` is valid, including one-liner syntax like this:
10
10
 
11
11
  ### Markdown
12
12
 
@@ -25,27 +25,3 @@ subject { 'my value' }
25
25
 
26
26
  it { is_expected.to eql 'my value' }
27
27
  ```
28
-
29
- ## Regular `it` blocks
30
-
31
- ### Markdown
32
-
33
- ````markdown
34
- ```rspec
35
- subject { 'my value' }
36
-
37
- it 'contains some expected text' do
38
- expect(subject).to eql 'my value'
39
- end
40
- ```
41
- ````
42
-
43
- ### Output
44
-
45
- ```rspec
46
- subject { 'my other value' }
47
-
48
- it 'contains some expected text' do
49
- expect(subject).to include 'other value'
50
- end
51
- ```
@@ -0,0 +1,23 @@
1
+ # Multiple Expectations
2
+
3
+ Add as many expectations as you like:
4
+
5
+ ## Markdown
6
+
7
+ ````markdown
8
+ ```rspec
9
+ subject { 'my value' }
10
+
11
+ it { is_expected.to eql 'my value' }
12
+ it { is_expected.to be_a String }
13
+ ```
14
+ ````
15
+
16
+ ## Output
17
+
18
+ ```rspec
19
+ subject { 'my value' }
20
+
21
+ it { is_expected.to eql 'my value' }
22
+ it { is_expected.to be_a String }
23
+ ```
@@ -0,0 +1,23 @@
1
+ ## Regular `it` blocks
2
+
3
+ ### Markdown
4
+
5
+ ````markdown
6
+ ```rspec
7
+ subject { 'my value' }
8
+
9
+ it 'contains some expected text' do
10
+ expect(subject).to eql 'my value'
11
+ end
12
+ ```
13
+ ````
14
+
15
+ ### Output
16
+
17
+ ```rspec
18
+ subject { 'my other value' }
19
+
20
+ it 'contains some expected text' do
21
+ expect(subject).to include 'other value'
22
+ end
23
+ ```
@@ -1,6 +1,6 @@
1
1
  # JSON
2
2
 
3
- If your code outputs _JSON_, use the ```` ```rspec:json``` ```` formatter to prettify your _JSON_ output. Note that your code must produce a raw _JSON_ string in order to use this formatter, it does not convert _Ruby_ objects into _JSON_.
3
+ If your code outputs _JSON_, use the ```` ```rspec:json ```` formatter to prettify your _JSON_ output. Note that your code must produce a raw _JSON_ string in order to use this formatter, it does not convert _Ruby_ objects into _JSON_.
4
4
 
5
5
  ## Markdown
6
6
 
@@ -1,7 +1,6 @@
1
1
  # YAML
2
2
 
3
-
4
- If your code outputs _YAML_, use the ```` ```rspec:yaml``` ```` formatter to prettify your _YAML_ output. Note that your code must produce a raw _YAML_ string in order to use this formatter, it does not convert _Ruby_ objects into _YAML_.
3
+ If your code outputs _YAML_, use the ```` ```rspec:yaml ```` formatter to prettify your _YAML_ output. Note that your code must produce a raw _YAML_ string in order to use this formatter, it does not convert _Ruby_ objects into _YAML_.
5
4
 
6
5
  ## Markdown
7
6
 
@@ -0,0 +1,25 @@
1
+ # XML
2
+
3
+ If your code outputs _XML_, use the ```` ```rspec:xml ```` formatter to prettify your _XML_ output. Note that your code must produce a raw _XML_ string in order to use this formatter, it does not convert _Ruby_ objects into _XML_.
4
+
5
+ ## Markdown
6
+
7
+ ````markdown
8
+ ```rspec:xml
9
+ subject { '<?xml version="1.0" encoding="UTF-8"?><foo><bar>baz</bar></foo>' }
10
+
11
+ it 'has expected key/value' do
12
+ expect(Nokogiri::XML.parse(subject).xpath('//foo/bar').text).to eql 'baz'
13
+ end
14
+ ```
15
+ ````
16
+
17
+ ## Output
18
+
19
+ ```rspec:xml
20
+ subject { '<?xml version="1.0" encoding="UTF-8"?><foo><bar>baz</bar></foo>' }
21
+
22
+ it 'has expected key/value' do
23
+ expect(Nokogiri::XML.parse(subject).xpath('//foo/bar').text).to eql 'baz'
24
+ end
25
+ ```
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'nokogiri'
4
+
3
5
  RSpec::Documentation.configure do |config|
4
6
  config.context do
5
7
  let(:foo) { 'baz' }
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_runtime_dependency 'htmlbeautifier', '~> 1.4'
32
32
  spec.add_runtime_dependency 'kramdown', '~> 2.4'
33
33
  spec.add_runtime_dependency 'kramdown-parser-gfm', '~> 1.1'
34
+ spec.add_runtime_dependency 'nokogiri', '~> 1.15'
34
35
  spec.add_runtime_dependency 'paintbrush', '~> 0.1.3'
35
36
  spec.add_runtime_dependency 'redcarpet', '~> 3.6'
36
37
  spec.add_runtime_dependency 'rouge', '~> 4.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-documentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-04 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlbeautifier
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.15'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.15'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: paintbrush
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +150,7 @@ files:
136
150
  - lib/rspec_documentation/formatters/html.rb
137
151
  - lib/rspec_documentation/formatters/json.rb
138
152
  - lib/rspec_documentation/formatters/ruby.rb
153
+ - lib/rspec_documentation/formatters/xml.rb
139
154
  - lib/rspec_documentation/formatters/yaml.rb
140
155
  - lib/rspec_documentation/html_element.rb
141
156
  - lib/rspec_documentation/javascript_bundle.rb
@@ -196,17 +211,20 @@ files:
196
211
  - rspec-documentation-0.1.0.gem
197
212
  - rspec-documentation.gemspec
198
213
  - rspec-documentation/pages/000-Introduction.md
199
- - rspec-documentation/pages/000-Introduction/000-Quickstart.md
214
+ - rspec-documentation/pages/001-Quickstart.md
200
215
  - rspec-documentation/pages/010-File System.md
201
216
  - rspec-documentation/pages/010-File System/000-Ordering.md
202
217
  - rspec-documentation/pages/010-File System/010-Documentation Bundle.md
203
218
  - rspec-documentation/pages/020-Running Tests.md
204
219
  - rspec-documentation/pages/030-Examples.md
205
- - rspec-documentation/pages/030-Examples/010-Basic.md
220
+ - rspec-documentation/pages/030-Examples/010-Basic Usage.md
221
+ - rspec-documentation/pages/030-Examples/011-Multiple Expectations.md
222
+ - rspec-documentation/pages/030-Examples/012-Regular it Blocks.md
206
223
  - rspec-documentation/pages/030-Examples/020-HTML.md
207
224
  - rspec-documentation/pages/030-Examples/030-ANSI.md
208
225
  - rspec-documentation/pages/030-Examples/040-JSON.md
209
226
  - rspec-documentation/pages/030-Examples/050-YAML.md
227
+ - rspec-documentation/pages/030-Examples/060-XML.md
210
228
  - rspec-documentation/pages/040-Spec Helper.md
211
229
  - rspec-documentation/pages/050-Linking.md
212
230
  - rspec-documentation/pages/060-Configuration.md