Module: Siyousho
- Defined in:
- lib/siyousho.rb,
lib/siyousho/version.rb
Constant Summary collapse
- VERSION =
'0.0.2'
Class Attribute Summary collapse
-
.current_test ⇒ Object
Returns the value of attribute current_test.
-
.screenshots ⇒ Object
Returns the value of attribute screenshots.
Class Method Summary collapse
- .create_html ⇒ Object
- .dir_path ⇒ Object
- .file_name ⇒ Object
- .generate_parts(test_name, step_name) ⇒ Object
Class Attribute Details
.current_test ⇒ Object
Returns the value of attribute current_test.
11 12 13 |
# File 'lib/siyousho.rb', line 11 def current_test @current_test end |
.screenshots ⇒ Object
Returns the value of attribute screenshots.
11 12 13 |
# File 'lib/siyousho.rb', line 11 def screenshots @screenshots end |
Class Method Details
.create_html ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/siyousho.rb', line 33 def create_html return if screenshots.empty? html = "<html><head><title>#{current_test}</title></head><body>" screenshots.each do |screenshot| html += "<h1>#{screenshot[:step]}</h1>" html += "<img src='#{screenshot[:image_path]}' style='max-width: 1000px; width: auto; height: auto;'><br>" if screenshot[:image_path] end html += "</body></html>" File.write(file_name, html) end |
.dir_path ⇒ Object
13 14 15 |
# File 'lib/siyousho.rb', line 13 def dir_path Rails.root.join('tmp', '仕様書') end |
.file_name ⇒ Object
17 18 19 |
# File 'lib/siyousho.rb', line 17 def file_name dir_path.join("#{current_test}.html") end |
.generate_parts(test_name, step_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/siyousho.rb', line 21 def generate_parts(test_name, step_name) dir_path = Siyousho.dir_path.join(test_name) FileUtils.mkdir_p(dir_path) filename = "#{screenshots.size}.png" file_path = dir_path.join(filename) relative_file_path = test_name + '/' + filename Capybara.current_session.save_screenshot(file_path) screenshots << {image_path: relative_file_path, step: step_name} end |