qTestScenarioRuby 1.0.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc6e9dfd1295fe83365f0b536090eb6d4e31a38b
4
- data.tar.gz: 3e9153475ba0e4582ebb70d687f077d7365898b5
3
+ metadata.gz: 3f743244a37c634d7147a58bcdc48469733d2413
4
+ data.tar.gz: 95886be96c6fd6c4cf1dc5fe6eb9157edb566427
5
5
  SHA512:
6
- metadata.gz: a42ed9e488d80870624113340c604b425d7239030680249f106ccffe7d8e7478ac05bb9c7feff1447f4fca625c76d2a478d1f61ee723f6192478123c8d8ac0fa
7
- data.tar.gz: d0f64e914993f1b78e335d143e464d04baf4ea6e8eca556e76af78eefa52036a13f5a8146123094cbf1064e1e2250557c3a48e6f0e84a12afaadfa0aa0e08b67
6
+ metadata.gz: fb59dc12bea654264ceda9b97a8099d5148874b4f18be4050d2c3113a4fb05f5b30ad7d5d3afaa67d7c370966c3071414cb2dc2c697aab99a6a2ed788ba9d935
7
+ data.tar.gz: 19a7cb4e86e7ba02591d734d764265e0855e5224473d9730daab4a9cb7c1b932118af55f231b0d32099a7173cf01706c786af13db93298129a21c33ff58791f9
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'cucumber'
5
+ gem 'rest-client'
6
+ gem 'qTestScenarioRuby'
@@ -0,0 +1,18 @@
1
+ require 'cucumber'
2
+ require 'cucumber/rake/task'
3
+ require 'qTestScenarioRuby'
4
+
5
+ task :setup do
6
+ ENV['QTSCN_SERVER'] = 'http://localhost:9999/api'
7
+ ENV['QTSCN_SERVER_API_KEY'] = 'ZDUwMDU0MmMtYmY5OS00ZTJhLWI0YTktNzlmOGU2ZTgxM2Y4'
8
+ ENV['QTSCN_SERVER_FEATURE_DIR'] = 'features/features/'
9
+ ENV['QTSCN_JQL'] = 'project = RUBY-NEW'
10
+ ENV['QTSCN_KEYS'] = ''
11
+ ENV['QTSCN_SUPPORT_DIR'] = 'features/support/'
12
+ end
13
+
14
+ Cucumber::Rake::Task.new(:test)
15
+ QTestScenario::Task::PrepareTest.new(:prepareTest)
16
+
17
+ task :test => :setup
18
+ task :prepareTest => :setup
@@ -3,16 +3,35 @@ require_relative '../lib/qspec_feature/qspec_feature'
3
3
  require_relative '../lib/utils/q_test_scenario_utils'
4
4
  require_relative '../lib/logs/feature_log'
5
5
  require_relative '../lib/logs/scenario_log'
6
+ require_relative '../lib/utils/hook_utils'
6
7
  require_relative 'configuration/constants'
7
8
  require 'fileutils'
8
9
 
9
10
  module QTestScenario
10
- $outline_pattern = '%s, %s (#%s)'
11
- $hook_version = '1.2'
11
+ OUTLINE_PATTERN = '%s, %s (#%s)'
12
+ HOOK_VERSION = '1.0'
13
+
14
+ module Task
15
+ class PrepareTest
16
+ include ::Rake::DSL if defined?(::Rake::DSL)
17
+
18
+ def initialize(task_name = 'prepareTest')
19
+ task task_name do
20
+ plugin = QTestScenario::QTestScenarioPlugin.new({
21
+ 'server' => ENV['QTSCN_SERVER'],
22
+ 'api_key' => ENV['QTSCN_SERVER_API_KEY'],
23
+ 'destination_dir' => ENV['QTSCN_SERVER_FEATURE_DIR'],
24
+ 'jql' => ENV['QTSCN_JQL'],
25
+ 'keys' => ENV['QTSCN_KEYS'],
26
+ 'support_folder' => ENV['QTSCN_SUPPORT_DIR']})
27
+ plugin.prepare_test
28
+ end
29
+ end
30
+ end
31
+ end
12
32
 
13
33
  class QTestScenarioPlugin
14
-
15
- attr_accessor :server, :api_key, :destination_dir, :jql, :keys, :support_folder, :project_path
34
+ attr_accessor :server, :api_key, :destination_dir, :jql, :keys, :support_folder
16
35
 
17
36
  def initialize(args)
18
37
  args.each do |k, v|
@@ -32,7 +51,7 @@ module QTestScenario
32
51
  end
33
52
 
34
53
  @setup_is_done = false
35
- generate_hooks
54
+ HookUtils.generate_hook(@support_folder, HOOK_VERSION)
36
55
  end
37
56
 
38
57
  def prepare_test
@@ -113,7 +132,7 @@ module QTestScenario
113
132
  child.examples_tables.each { |table|
114
133
  outline_example_count += table.example_rows.length
115
134
  table.example_rows.each { |row|
116
- outLineName = $outline_pattern % [child.name, table.name, row.number]
135
+ outLineName = OUTLINE_PATTERN % [child.name, table.name, row.number]
117
136
  feature_meta.scenarios[outLineName] = scenarioId
118
137
  }
119
138
  }
@@ -199,64 +218,6 @@ module QTestScenario
199
218
  QTestScenarioUtils.update_execution(@execution, @server, @api_key)
200
219
  end
201
220
 
202
- def generate_hooks? (version_file_path, hook_file_path)
203
- generate_hook = false
204
- begin
205
- File.open(version_file_path, 'r') do |f|
206
- versionUsed = f.gets
207
- if !$hook_version.eql? versionUsed
208
- File.delete(hook_file_path)
209
- generate_hook = true
210
- end
211
- end
212
- rescue
213
- # hook_version does not exist, then generate hook
214
- generate_hook = true
215
- end
216
- generate_hook
217
- end
218
-
219
- def generate_hooks
220
- support_folder_path = @project_path + '/' + @support_folder + '/hook/'
221
- if !File.directory? (support_folder_path)
222
- FileUtils.mkdir(support_folder_path)
223
- end
224
-
225
- version_file_path = support_folder_path + 'hook_version'
226
- hook_file_path = support_folder_path + 'hooks.rb'
227
- generate_hook = generate_hooks?(version_file_path, hook_file_path)
228
-
229
- if (generate_hook)
230
- File.open(version_file_path, 'wb') do |f|
231
- f << $hook_version
232
- end
233
-
234
- File.open(hook_file_path, 'wb') do |f|
235
- f.puts 'require \'qTestScenarioRuby\''
236
- f.puts ''
237
- f.puts '$plugin = QTestScenario::QTestScenarioPlugin.new({'
238
- f.puts ' \'server\' => ENV[\'server\'],'
239
- f.puts ' \'api_key\' => ENV[\'api_key\'],'
240
- f.puts ' \'destination_dir\' => ENV[\'destination_dir\'],'
241
- f.puts ' \'jql\' => ENV[\'jql\'],'
242
- f.puts ' \'support_folder\' => ENV[\'support_folder\'],'
243
- f.puts ' \'project_path\' => Dir.pwd'
244
- f.puts ' })'
245
- f.puts ''
246
- f.puts 'Before do |scenario|'
247
- f.puts ' $plugin.before_scenario scenario'
248
- f.puts 'end'
249
- f.puts ''
250
- f.puts 'After do |scenario|'
251
- f.puts ' $plugin.after_scenario scenario'
252
- f.puts 'end'
253
- f.puts ''
254
- f.puts 'at_exit do'
255
- f.puts ' $plugin.at_exit'
256
- f.puts 'end'
257
- end
258
- end
259
- end
260
221
  end
261
222
  end
262
223
 
@@ -0,0 +1,66 @@
1
+ require 'fileutils'
2
+
3
+ class HookUtils
4
+
5
+ def self.generate_hooks? (version_file_path, hook_file_path, hook_version)
6
+ generate_hook = false
7
+ begin
8
+ File.open(version_file_path, 'r') do |f|
9
+ versionUsed = f.gets
10
+ if !hook_version.eql? versionUsed
11
+ File.delete(hook_file_path)
12
+ generate_hook = true
13
+ end
14
+ end
15
+ rescue
16
+ # hook_version does not exist, then generate hook
17
+ generate_hook = true
18
+ end
19
+ generate_hook
20
+ end
21
+
22
+ def self.generate_hook (support_folder, hook_version)
23
+ support_folder_path = support_folder + 'hook/'
24
+ if !File.directory? (support_folder_path)
25
+ FileUtils.mkdir(support_folder_path)
26
+ end
27
+
28
+ version_file_path = support_folder_path + 'hook_version'
29
+ hook_file_path = support_folder_path + 'hooks.rb'
30
+ generate_hook = generate_hooks?(version_file_path, hook_file_path, hook_version)
31
+
32
+ if (generate_hook)
33
+ File.open(version_file_path, 'wb') do |f|
34
+ f << hook_version
35
+ end
36
+ generate_hook_file (hook_file_path)
37
+ end
38
+ end
39
+
40
+ def self.generate_hook_file(hook_file_path)
41
+ File.open(hook_file_path, 'wb') do |f|
42
+ f.puts 'require \'qTestScenarioRuby\''
43
+ f.puts ''
44
+ f.puts '$plugin = QTestScenario::QTestScenarioPlugin.new({'
45
+ f.puts ' \'server\' => ENV[\'QTSCN_SERVER\'],'
46
+ f.puts ' \'api_key\' => ENV[\'QTSCN_SERVER_API_KEY\'],'
47
+ f.puts ' \'destination_dir\' => ENV[\'QTSCN_SERVER_FEATURE_DIR\'],'
48
+ f.puts ' \'jql\' => ENV[\'QTSCN_JQL\'],'
49
+ f.puts ' \'keys\' => ENV[\'QTSCN_KEYS\'],'
50
+ f.puts ' \'support_folder\' => ENV[\'QTSCN_SUPPORT_DIR\']'
51
+ f.puts '})'
52
+ f.puts ''
53
+ f.puts 'Before do |scenario|'
54
+ f.puts ' $plugin.before_scenario scenario'
55
+ f.puts 'end'
56
+ f.puts ''
57
+ f.puts 'After do |scenario|'
58
+ f.puts ' $plugin.after_scenario scenario'
59
+ f.puts 'end'
60
+ f.puts ''
61
+ f.puts 'at_exit do'
62
+ f.puts ' $plugin.at_exit'
63
+ f.puts 'end'
64
+ end
65
+ end
66
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qTestScenarioRuby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thuan Tran
@@ -17,12 +17,15 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/configuration/constants.rb
20
+ - lib/example/Gemfile
21
+ - lib/example/Rakefile
20
22
  - lib/logs/execution_log.rb
21
23
  - lib/logs/feature_log.rb
22
24
  - lib/logs/scenario_log.rb
23
25
  - lib/qspec_feature/feature_meta.rb
24
26
  - lib/qspec_feature/qspec_feature.rb
25
27
  - lib/qTestScenarioRuby.rb
28
+ - lib/utils/hook_utils.rb
26
29
  - lib/utils/q_test_scenario_utils.rb
27
30
  homepage: https://www.qasymphony.com/testing-platform/qtest-scenario/
28
31
  licenses: