dromedary 0.1.00

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f7c4953cb5e750a7e289cb591ab50655cad5920e
4
+ data.tar.gz: e6c1dcf1798ea13779f1759c9bbff33bce912275
5
+ SHA512:
6
+ metadata.gz: 7dc7fbae20ef3d331e3f27bd6e2779b7613193f275b4a8bd8602f63bdf81a57c7958d00120d8afb4d9da4422843e94c13872c2b07b6889942b26715c457270f9
7
+ data.tar.gz: 3bd2f99b43dc908f165597c91cbad255bc4936cd41189179fe2c3fcab8bc36fe45304579ce7fc7e97a0f92e2ed7f2f8ab13ccb6b1f721a8039625c28ba12e0d3
data/bin/dromedary ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dromedary'
4
+ Dromedary.init(ARGV[0])
data/lib/dromedary.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+ require_relative 'dromedary_initializer'
3
+
4
+ class Dromedary
5
+ include DromedaryInitializer
6
+
7
+ def self.init(options)
8
+ case options
9
+ when '--init'
10
+ show_init_msg
11
+ initialize_project
12
+ else
13
+ welcome
14
+ end
15
+ end
16
+
17
+ def self.welcome
18
+ puts 'Hello world! I am a wild Dromedary!'
19
+ puts 'If you like to take a ride, you will need to run "dromedary --init" first'
20
+ end
21
+
22
+ def self.initialize_project
23
+ DromedaryInitializer.run
24
+ end
25
+
26
+ def self.show_init_msg
27
+ puts 'Initializes folder structure and generates files for Dromedary reporting'
28
+ end
29
+ end
@@ -0,0 +1,165 @@
1
+ module DromedaryInitializer
2
+ def self.run
3
+ if cucumber_initialized?
4
+ report_no_cucumber_found
5
+ elsif already_initialized?
6
+ report_already_initialized
7
+ else
8
+ create_file 'config/dromedary.yml'
9
+ create_file 'features/support/dromedary_hooks.rb'
10
+
11
+ update_file 'config/dromedary.yml', dromedary_config_content
12
+ update_file 'features/support/dromedary_hooks.rb', dromedary_hooks_content
13
+ end
14
+ end
15
+
16
+ def self.create_directory(dir_name)
17
+ create_directory_or_file dir_name, true
18
+ end
19
+
20
+ def self.create_file(file_name)
21
+ create_directory_or_file file_name, false
22
+ end
23
+
24
+ def self.create_directory_or_file(file_name, directory)
25
+ file_type = if directory
26
+ :mkdir_p
27
+ else
28
+ :touch
29
+ end
30
+
31
+ report_exists(file_name) || return if File.exist?(file_name)
32
+
33
+ report_creating(file_name)
34
+ FileUtils.send file_type, file_name
35
+ end
36
+
37
+ def self.update_file(file_name, content)
38
+ open(file_name, 'a') do |file|
39
+ content.flatten!.each do |line|
40
+ file.puts line
41
+ end
42
+ end
43
+
44
+ report_updating(file_name)
45
+ end
46
+
47
+ def self.cucumber_initialized?
48
+ !File.exist?('features/support/env.rb')
49
+ end
50
+
51
+ def self.already_initialized?
52
+ File.exist?('config/dromedary.yml') || File.exist?('features/support/dromedary_hooks.rb')
53
+ end
54
+
55
+ def self.report_exists(file)
56
+ puts " exist #{file}"
57
+ end
58
+
59
+ def self.report_creating(file)
60
+ puts " creating #{file}"
61
+ end
62
+
63
+ def self.report_updating(file)
64
+ puts " updating #{file}"
65
+ end
66
+
67
+ def self.report_no_cucumber_found
68
+ puts " Dromedary had searched all Sahara desert for Cucumber, but didn't found it"
69
+ puts ' Are you sure that you had initialized Cucumber project?'
70
+ puts " If not, try to run 'cucumber --init' first"
71
+ end
72
+
73
+ def self.report_already_initialized
74
+ puts ' Our suspicious Dromedary says that you have already initialized it'
75
+ puts " There is no need to run 'dromedary -- init' command more than once"
76
+ end
77
+
78
+ def self.dromedary_config_content
79
+ ['# This file was generated by Dromedary gem',
80
+ '# It contains required settings to support TestRail integration',
81
+ '# Fill in each line with credentials of your TestRail account',
82
+ '',
83
+ dromedary_config_structure,
84
+ ' # By default Dromedary creates Test Runs on TestRail this way:',
85
+ ' # test_run_default_name + Suite Type + on Environment',
86
+ ' # So at the end you will get something like this:',
87
+ ' # "My_project Regression on Staging"']
88
+ end
89
+
90
+ def self.dromedary_config_structure
91
+ ['testrail:',
92
+ ' url:',
93
+ ' user:',
94
+ ' password:',
95
+ ' project_id:',
96
+ ' suite_id:',
97
+ ' test_run_default_name:']
98
+ end
99
+
100
+ def self.dromedary_hooks_content
101
+ ['# This file was generated by Dromedary gem',
102
+ '# It contains required Cucumber hooks to ensure that all reporting works',
103
+ '# Do not edit this file',
104
+ '',
105
+ dromedary_hooks_structure]
106
+ end
107
+
108
+ def self.dromedary_hooks_structure
109
+ [dromedary_before_hooks,
110
+ '',
111
+ dromedary_afterstep_hooks,
112
+ '',
113
+ dromedary_after_hooks]
114
+ end
115
+
116
+ def self.dromedary_before_hooks
117
+ ['Before do',
118
+ " # setting environment to 'local' in order not to generate reporting",
119
+ " # if you need individual reports, just put this variable to 'false'",
120
+ " ENV['local'] ||= 'true'",
121
+ " @local = ENV['local']",
122
+ '',
123
+ ' # creating results hash for TestRail',
124
+ ' @results = {}',
125
+ ' # and resetting passed steps count',
126
+ ' @passed_steps_count = 0',
127
+ 'end']
128
+ end
129
+
130
+ def self.dromedary_afterstep_hooks
131
+ ['AfterStep do |step|',
132
+ ' @passed_steps_count += 1 if step.passed?',
133
+ 'end']
134
+ end
135
+
136
+ def self.dromedary_after_hooks
137
+ ['After do |scenario|',
138
+ ' # updating results hash for TestRail after each scenario',
139
+ ' feature_name = scenario.feature.name',
140
+ ' scenario_name = scenario.name',
141
+ '',
142
+ ' scenario.test_steps.each do |step|',
143
+ " if step.text != 'Before hook' && step.text != 'AfterStep hook'",
144
+ " step_name = File.open(step.location.file).readlines[step.location.line-1].lstrip",
145
+ " full_description = (feature_name + ' ' + scenario_name + ' ' + step_name).rstrip",
146
+ ' status_id = []',
147
+ ' status_id = @passed_steps_count > 0 ? (status_id.push 1) : (status_id.push 5)',
148
+ ' if @results[ full_description ]',
149
+ ' @results[ full_description ].push(status_id).flatten!',
150
+ ' else',
151
+ ' @results[ full_description ] = status_id',
152
+ ' end',
153
+ ' @passed_steps_count -= 1',
154
+ ' end',
155
+ ' end',
156
+ '',
157
+ ' # setting TestRail to generate reports at specific folder',
158
+ " unless @local == 'true'",
159
+ ' File.open("artifacts/test_rail_results/file_#{UUID.generate(:compact).to_s}.json", "w") do |file|',
160
+ ' file.puts @results.to_json',
161
+ ' end',
162
+ ' end',
163
+ 'end']
164
+ end
165
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dromedary
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.00
5
+ platform: ruby
6
+ authors:
7
+ - Denys Bazarnyi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Dromedary is a helper gem which will unify and simplyfy test reporting
14
+ approaches for different Ruby Based Test Automation Solutions
15
+ email: denys.bazarnyi@storecast.de
16
+ executables:
17
+ - dromedary
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/dromedary
22
+ - lib/dromedary.rb
23
+ - lib/dromedary_initializer.rb
24
+ homepage:
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.6.12
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Test reporting helper gem
48
+ test_files: []