capybara-autodoc 0.0.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 +7 -0
- data/bin/capybara-autodoc +11 -0
- data/lib/capybara-autodoc.rb +88 -0
- data/lib/support/autodoc.rb +3 -0
- metadata +117 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2990a2002180ade8c3f257a54fe1aa4fd65f558becf4e13c2f882f0d4daed422
|
|
4
|
+
data.tar.gz: a40083c93bdee457db62fa2e88ff1f9a4df783fbad7facf92c64eb4420424625
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 288ca9cf1f385e2f842b7cca2716a46cb44dafa67355ad5f19b6abc477268901d41db74eb14f6d824f13f8bc1dca9b269df6c7348652f2592a0f7a29aad8a233
|
|
7
|
+
data.tar.gz: 9da3ce9576d594b449d8db7ce1152359dc59d87a5d83b1cca7c7d6c76d00c169e462172ba932a3e56ed92fe85acbc55131a74809c63b9137341f19ab43831d24
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
FileUtils.mkdir_p("spec/support/autodoc")
|
|
6
|
+
template_dirname = File.dirname(__dir__) + "/lib/templates/."
|
|
7
|
+
|
|
8
|
+
FileUtils.cp_r(template_dirname, "spec/support/autodoc")
|
|
9
|
+
|
|
10
|
+
support_dirname = File.dirname(__dir__) + "/lib/support/."
|
|
11
|
+
FileUtils.cp_r(support_dirname, "spec/support")
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
require 'capybara/email/rspec'
|
|
2
|
+
require "slim"
|
|
3
|
+
|
|
4
|
+
class Capybara::Autodoc
|
|
5
|
+
@scenarios = []
|
|
6
|
+
|
|
7
|
+
def self.start_scenario(title, example)
|
|
8
|
+
scenario = Scenario.new(title, example)
|
|
9
|
+
@scenarios << scenario
|
|
10
|
+
scenario
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.render
|
|
14
|
+
return if @scenarios.empty?
|
|
15
|
+
|
|
16
|
+
`mkdir -p tmp/capybara/autodoc`
|
|
17
|
+
|
|
18
|
+
@scenarios.each do |scenario|
|
|
19
|
+
Rails.root.join("tmp/capybara/autodoc/scenario_#{scenario.index}.html").write(
|
|
20
|
+
Slim::Template.new(Rails.root.join("spec/support/autodoc/layout.html.slim")).render(scenario) do
|
|
21
|
+
Slim::Template.new(Rails.root.join("spec/support/autodoc/scenario.html.slim")).render(scenario).html_safe # rubocop:disable Rails/OutputSafety
|
|
22
|
+
end
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
Rails.root.join("tmp/capybara/autodoc/index.html").write(
|
|
27
|
+
Slim::Template.new(Rails.root.join("spec/support/autodoc/layout.html.slim")).render(self) do
|
|
28
|
+
Slim::Template.new(Rails.root.join("spec/support/autodoc/index.html.slim")).render(self).html_safe # rubocop:disable Rails/OutputSafety
|
|
29
|
+
end
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
if @scenarios.any?
|
|
33
|
+
puts "The autodoc is available at file://#{Rails.root.join('tmp/capybara/autodoc/index.html')}"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class Scenario
|
|
38
|
+
def initialize(title, example)
|
|
39
|
+
@title = title
|
|
40
|
+
@index = Digest::SHA1.hexdigest(title)[0..8]
|
|
41
|
+
@example = example
|
|
42
|
+
@sections = []
|
|
43
|
+
@current_section = nil
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
attr_reader :title, :index
|
|
47
|
+
|
|
48
|
+
def start_section(title)
|
|
49
|
+
@current_section = Section.new(title)
|
|
50
|
+
@sections << @current_section
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def add_text(description)
|
|
54
|
+
@current_section.steps << { text: description }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def add_screenshot(page_or_email, text: nil, wait_for: nil)
|
|
58
|
+
if wait_for
|
|
59
|
+
@example.expect(page_or_email).to(@example.have_content(wait_for))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
filename = "scenario_#{@index}_section_#{@sections.count}_step_#{@current_section.steps.count}.png"
|
|
63
|
+
`mkdir -p tmp/capybara/autodoc`
|
|
64
|
+
|
|
65
|
+
path = Rails.root.join("tmp/capybara/autodoc/#{filename}")
|
|
66
|
+
|
|
67
|
+
if page_or_email.is_a?(Capybara::Node::Email)
|
|
68
|
+
Capybara.current_session.driver.visit "file://#{page_or_email.save_page}"
|
|
69
|
+
Capybara.current_session.driver.save_screenshot(path)
|
|
70
|
+
else
|
|
71
|
+
page_or_email.driver.save_screenshot(path)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
img_src = ENV["UPLOAD_TO_GH_PAGES"] ? "/rdv-service-public/#{filename}" : path
|
|
75
|
+
|
|
76
|
+
@current_section.steps << { text: text, img_src: img_src }
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class Section
|
|
81
|
+
def initialize(title)
|
|
82
|
+
@title = title
|
|
83
|
+
@steps = []
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
attr_accessor :title, :steps
|
|
87
|
+
end
|
|
88
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: capybara-autodoc
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Victor Mours
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-11-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: slim
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: capybara
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: capybara-screenshot
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: capybara-email
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: ''
|
|
84
|
+
email: victor.mours@beta.gouv.fr
|
|
85
|
+
executables:
|
|
86
|
+
- capybara-autodoc
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- bin/capybara-autodoc
|
|
91
|
+
- lib/capybara-autodoc.rb
|
|
92
|
+
- lib/support/autodoc.rb
|
|
93
|
+
homepage: https://github.com/betagouv/capybara-autodoc
|
|
94
|
+
licenses:
|
|
95
|
+
- MIT
|
|
96
|
+
metadata: {}
|
|
97
|
+
post_install_message:
|
|
98
|
+
rdoc_options: []
|
|
99
|
+
require_paths:
|
|
100
|
+
- lib
|
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
|
+
requirements:
|
|
103
|
+
- - ">="
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: '0'
|
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
requirements: []
|
|
112
|
+
rubygems_version: 3.4.10
|
|
113
|
+
signing_key:
|
|
114
|
+
specification_version: 4
|
|
115
|
+
summary: Turn your integration specs into always up-to-date documentation for your
|
|
116
|
+
team
|
|
117
|
+
test_files: []
|