siyousho 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/siyousho/version.rb +1 -1
- data/lib/siyousho.rb +72 -49
- data/siyousho.gemspec +3 -2
- metadata +19 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 483630747b5e4867c4c66618a9aa7d9c2834b9ee8394b3ecabdfeaab29d4c472
|
4
|
+
data.tar.gz: 99b7d1d59fd3e1d8132224e33c6f9c736f75afdd08559175187d6dd9a992401d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc5b5aefdb96b4e3d4f36591659f6eba2ec03118d1f14bc64910700dbfbbc2d7e13688edbaa297eaf6b9b7c473c67f90a2779fd8f9b87526ef62ec5feca9b590
|
7
|
+
data.tar.gz: b35dd7188dc4a20e8337adef85b37a984bc0adf9fb1f77a7acdf0e69a436dc37eea984446e1e7564fe5f9cab863a4885497c89e84021f4c15b7044ae28d12177
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
31
31
|
|
32
32
|
## Contributing
|
33
33
|
|
34
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/colorbox/siyousho. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/colorbox/siyousho/blob/master/CODE_OF_CONDUCT.md).
|
35
35
|
|
36
36
|
## License
|
37
37
|
|
@@ -39,4 +39,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
39
39
|
|
40
40
|
## Code of Conduct
|
41
41
|
|
42
|
-
Everyone interacting in the Siyousho project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
42
|
+
Everyone interacting in the Siyousho project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/colorbox/siyousho/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/siyousho/version.rb
CHANGED
data/lib/siyousho.rb
CHANGED
@@ -2,72 +2,95 @@
|
|
2
2
|
|
3
3
|
require_relative 'siyousho/version'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
end
|
5
|
+
require 'unparser'
|
6
|
+
require 'parser/current'
|
7
|
+
require 'method_source'
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
9
|
+
module Siyousho
|
10
|
+
class << self
|
11
|
+
attr_accessor :current_test, :screenshots
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
def dir_path
|
14
|
+
Rails.root.join('tmp', '仕様書')
|
15
|
+
end
|
20
16
|
|
21
|
-
def
|
22
|
-
|
17
|
+
def file_name
|
18
|
+
dir_path.join("#{current_test}.html")
|
19
|
+
end
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
def generate_parts(test_name, step_name)
|
22
|
+
dir_path = Siyousho.dir_path.join(test_name)
|
23
|
+
FileUtils.mkdir_p(dir_path)
|
24
|
+
filename = "#{screenshots.size}.png"
|
25
|
+
file_path = dir_path.join(filename)
|
29
26
|
|
30
|
-
|
27
|
+
relative_file_path = test_name + '/' + filename
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
screenshots << {image_path: relative_file_path, step: step_or_description.raw[:text]}
|
35
|
-
else
|
36
|
-
screenshots << {step: step_or_description}
|
37
|
-
end
|
29
|
+
Capybara.current_session.save_screenshot(file_path)
|
30
|
+
screenshots << {image_path: relative_file_path, step: step_name}
|
38
31
|
end
|
39
32
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
33
|
+
def create_html
|
34
|
+
return if screenshots.empty?
|
35
|
+
html = "<html><head><title>#{current_test}</title></head><body>"
|
43
36
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
screenshots.each do |screenshot|
|
38
|
+
html += "<h1>#{screenshot[:step]}</h1>"
|
39
|
+
html += "<img src='#{screenshot[:image_path]}' style='max-width: 1000px; width: auto; height: auto;'><br>" if screenshot[:image_path]
|
40
|
+
end
|
41
|
+
html += "</body></html>"
|
48
42
|
|
43
|
+
File.write(file_name, html)
|
44
|
+
end
|
49
45
|
end
|
50
46
|
end
|
51
47
|
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
def modify_proc(proc)
|
49
|
+
buffer = Parser::Source::Buffer.new('(string)')
|
50
|
+
buffer.source = proc.source
|
51
|
+
parser = Parser::CurrentRuby.new
|
52
|
+
ast = parser.parse(buffer)
|
53
|
+
|
54
|
+
rewriter = Parser::Source::TreeRewriter.new(buffer)
|
55
|
+
ast.children.last.children.each do |child|
|
56
|
+
rewriter.insert_before(child.location.expression, "Siyousho.generate_parts(Siyousho.current_test,'#{Unparser.unparse(child)}')\n")
|
55
57
|
end
|
58
|
+
modified_code = rewriter.process
|
59
|
+
|
60
|
+
modified_modified_code = modified_code.split("\n")[1..-2].join("\n")
|
61
|
+
|
62
|
+
Proc.new { eval(modified_modified_code) }
|
56
63
|
end
|
57
64
|
|
58
|
-
module
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
65
|
+
module Minitest
|
66
|
+
class Test < Runnable
|
67
|
+
def run
|
68
|
+
with_info_handler do
|
69
|
+
time_it do
|
70
|
+
capture_exceptions do
|
71
|
+
Siyousho.current_test = self.name
|
72
|
+
Siyousho.screenshots = []
|
73
|
+
|
74
|
+
SETUP_METHODS.each do |hook|
|
75
|
+
self.send hook
|
76
|
+
end
|
66
77
|
|
67
|
-
|
68
|
-
|
69
|
-
|
78
|
+
proc = self.method(self.name).to_proc
|
79
|
+
hello_block = modify_proc(proc)
|
80
|
+
hello_block.call
|
81
|
+
end
|
70
82
|
|
71
|
-
|
83
|
+
TEARDOWN_METHODS.each do |hook|
|
84
|
+
capture_exceptions do
|
85
|
+
self.send hook
|
86
|
+
end
|
87
|
+
Siyousho.create_html
|
88
|
+
Siyousho.screenshots.clear
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
Result.from self # per contract
|
94
|
+
end
|
72
95
|
end
|
73
96
|
end
|
data/siyousho.gemspec
CHANGED
@@ -30,8 +30,9 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ['lib']
|
32
32
|
|
33
|
-
spec.add_runtime_dependency '
|
34
|
-
spec.add_runtime_dependency '
|
33
|
+
spec.add_runtime_dependency 'parser'
|
34
|
+
spec.add_runtime_dependency 'unparser'
|
35
|
+
spec.add_runtime_dependency 'method_source'
|
35
36
|
|
36
37
|
# For more information and examples about making a new gem, check out our
|
37
38
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: siyousho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- colorbox
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: parser
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,25 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: unparser
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '4.0'
|
33
|
+
version: '0'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ">="
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
44
|
-
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: method_source
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
45
46
|
- !ruby/object:Gem::Version
|
46
|
-
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'
|
47
55
|
description: The Siyousho gem is designed to facilitate End-to-End (E2E) testing by
|
48
56
|
automatically generating detailed specification documents. These documents are enriched
|
49
57
|
with screenshots, providing a visual context for each testing step. Ideal for developers
|