glyptic-strips 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/lib/glyptic_strips.rb +110 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1bbb77491323a394fdaf057ab83d355bbefa43da
|
4
|
+
data.tar.gz: e9b7587a1a71c969248189b11d2d7ebdca05aa70
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e55c076908f6a1de14663d7daf6ffff0fa30e706ebe8a06e7e4611c883c5f8b01b5b2d59ac05914976b27b32fac7b6db04f7398be8a95c6f874be9c2d68333a
|
7
|
+
data.tar.gz: 07a74b3c0029a228bd50edb12c9a2b7b55ddff72dba64de6c165b54e7cce5f080a96639a1768804099e2a357459e42cfa0554d12f898a5014363a13b4d7b1279
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'mini_magick'
|
2
|
+
require 'cucumber'
|
3
|
+
require 'fileutils'
|
4
|
+
##
|
5
|
+
#
|
6
|
+
# Main class of Glyptic Strips
|
7
|
+
#
|
8
|
+
|
9
|
+
# = Setting up your project
|
10
|
+
#
|
11
|
+
# = Example
|
12
|
+
#
|
13
|
+
# create_gif(sceanrio, './myproj/test_reports/screenshots', @browser, :watir)
|
14
|
+
class GlypticStrips
|
15
|
+
@@scenario_index = 0
|
16
|
+
@@scenario_number = 0
|
17
|
+
@@explicit_wait = 0
|
18
|
+
@@red = '#C40D0D'
|
19
|
+
@@green = '#65c400'
|
20
|
+
@@divider = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
|
21
|
+
|
22
|
+
##
|
23
|
+
# This methods takes all of the png files from the parameter png_folder
|
24
|
+
# creates an html formatted string with them layed out in rows
|
25
|
+
#
|
26
|
+
|
27
|
+
def create_strip(scenario, png_folder, driver, driver_type, number_in_row)
|
28
|
+
@@scenario_index = 0
|
29
|
+
final_strip = ''
|
30
|
+
take_strip_frame(driver, driver_type, png_folder) if(scenario.failed?)
|
31
|
+
dir_contents = Dir.glob("#{png_folder}/scenario-#{@@scenario_number}-image-*.png").sort
|
32
|
+
img_index = 0
|
33
|
+
num_of_images = dir_contents.size
|
34
|
+
scenario_index = get_correct_scenario_index(scenario)
|
35
|
+
scenario_array = scenario.feature.feature_elements[scenario_index.to_i].send(:raw_steps).to_a
|
36
|
+
# Add the step description in red or green text to each image frame
|
37
|
+
dir_contents.each do |file_name|
|
38
|
+
if(scenario_array[img_index] == nil)
|
39
|
+
puts @@divider
|
40
|
+
puts ":::::::::::::::::: There are more screenshots than steps :::::::::::::::::::::::::::::::::::::"
|
41
|
+
puts "::::: Error :::::: Strips currently doesn't support background :::::::::::::::::::::::::::::::"
|
42
|
+
puts ":::::::::::::::::: If you don't have backgrounds then clear our your screenshots dir :::::::::"
|
43
|
+
puts @@divider
|
44
|
+
puts "SCREENSHOTS DIR: #{png_folder} "
|
45
|
+
raise 'There are more screenshots than steps. Check console output for more details'
|
46
|
+
end
|
47
|
+
step_name = scenario_array[img_index].name.to_s
|
48
|
+
if (scenario.failed? && (num_of_images - 1 == img_index))
|
49
|
+
image_html = get_image_html(file_name, "#{img_index+1}: #{step_name}", @@red, number_in_row)
|
50
|
+
else
|
51
|
+
image_html = get_image_html(file_name, "#{img_index+1}: #{step_name}", @@green, number_in_row)
|
52
|
+
end
|
53
|
+
puts
|
54
|
+
final_strip = final_strip+image_html
|
55
|
+
if((img_index+1)%number_in_row == 0)
|
56
|
+
final_strip = final_strip+'</br>'
|
57
|
+
end
|
58
|
+
img_index = img_index + 1
|
59
|
+
|
60
|
+
end
|
61
|
+
@@scenario_number = @@scenario_number + 1
|
62
|
+
final_strip
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# Takes a screenshot and saves it as a single frame for the gif
|
67
|
+
# in the png_folder location
|
68
|
+
#
|
69
|
+
def take_strip_frame(driver, driver_type, png_folder)
|
70
|
+
if(driver_type == :appium)
|
71
|
+
@@explicit_wait = 2
|
72
|
+
end
|
73
|
+
sleep @@explicit_wait
|
74
|
+
@@scenario_index = 0 if @@scenario_index == nil
|
75
|
+
screenshot_name = "%03d" % @@scenario_index
|
76
|
+
screenshot_location = "#{png_folder}/scenario-#{@@scenario_number}-image-#{screenshot_name}.png"
|
77
|
+
if(driver_type == :watir)
|
78
|
+
driver.screenshot.save screenshot_location
|
79
|
+
elsif(driver_type == :appium)
|
80
|
+
driver.screenshot(screenshot_location)
|
81
|
+
end
|
82
|
+
@@scenario_index = @@scenario_index + 1
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# Helper method to get the correct text to add to the png file
|
87
|
+
#
|
88
|
+
def get_correct_scenario_index(scenario)
|
89
|
+
expected_name = scenario.name
|
90
|
+
number_of_sceanrios = scenario.feature.feature_elements.size
|
91
|
+
found = false
|
92
|
+
current_iteration = 0
|
93
|
+
while(!found && number_of_sceanrios > current_iteration) do
|
94
|
+
if expected_name == scenario.feature.feature_elements[current_iteration].name
|
95
|
+
found = true
|
96
|
+
else
|
97
|
+
current_iteration = current_iteration + 1
|
98
|
+
end
|
99
|
+
end
|
100
|
+
current_iteration
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Adds given text to image
|
105
|
+
#
|
106
|
+
def get_image_html(image_location, text, color, number_in_row)
|
107
|
+
image_percent = 90/number_in_row
|
108
|
+
"<a href='#{image_location}' title='#{text}'><img style='border:4px solid #{color}' width='#{image_percent}%' src='#{image_location}'/></a>"
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glyptic-strips
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jared Sheffer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mini_magick
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.6.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.6.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cucumber
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.0.0
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.0
|
47
|
+
description: "Glyptic Gifs - A gem which assists in the creation of gifs for cucumber
|
48
|
+
projects\n "
|
49
|
+
email: magus.chef@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- lib/glyptic_strips.rb
|
55
|
+
homepage: http://rubygems.org/gems/glyptic_gifs
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.4.5.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Gif Creating Library
|
79
|
+
test_files: []
|