henry-container 0.0.53 → 0.0.54

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ module Henry
3
3
  class Container
4
4
 
5
5
  # Current Gem version
6
- VERSION = '0.0.53'
6
+ VERSION = '0.0.54'
7
7
 
8
8
  end
9
9
 
@@ -23,7 +23,7 @@ module Henry
23
23
  self.before_execution
24
24
 
25
25
  self.tasks.select {|task| task.enabled?}.each do |task|
26
- task.configure(self.task_params(task.name))
26
+ task.configure(self.task_params(task.name), self.task_extended_context(task.name))
27
27
  task.before_execute
28
28
  task.execute
29
29
  task.after_execute
@@ -122,6 +122,31 @@ module Henry
122
122
  self.default_params.merge(self.params[task_name] || {})
123
123
  end
124
124
 
125
+ # Return the default extended execution.
126
+ # @note Custom extended_executions will overwrite the defaults.
127
+ #
128
+ # @return [Hash] the Task default extended context
129
+ def default_extended_context
130
+ self.default_params['extended_context'] || {}
131
+ end
132
+
133
+ # Retrun the custom extended_context fo the given task.
134
+ # @note default_extended_context will be used for undefined keys.
135
+ #
136
+ # @return [Hash] the Task custom extended context.
137
+ def extended_context
138
+ (self.params[task_name] || {})['extended_context']
139
+ end
140
+
141
+ # Returns the custom execution_context for the given task.
142
+ # @note default_execution_context will be used for undefined keys.
143
+ #
144
+ # @param [String] task_name the target Task name.
145
+ # @return [Hash] the Task custom execution_context.
146
+ def task_extended_context
147
+ self.default_extended_context.merge(self.extended_context[task_name] || {})
148
+ end
149
+
125
150
 
126
151
  # Returns de task hints (tasks to be executed) or an empty array if they are not defined.
127
152
  #
@@ -1,4 +1,5 @@
1
1
  require 'drb/drb'
2
+ require 'fileutils'
2
3
  require 'json'
3
4
  require 'colorize'
4
5
 
@@ -12,6 +13,11 @@ module Henry
12
13
  # To be used as proxy to access the Task execution params from the tests
13
14
  class Environment
14
15
 
16
+ # The path to the default file export directory
17
+ #
18
+ # @return [String]
19
+ EXPORT_FILE_PATH = "/output"
20
+
15
21
  # Imports and returs the Task execution parameters.
16
22
  #
17
23
  # @return [Hash] the Task execution parameters
@@ -26,6 +32,13 @@ module Henry
26
32
  return DRbObject.new_with_uri(LoggerService::DRB_URI)
27
33
  end
28
34
 
35
+ # Copies the file from the given path to the default export directory
36
+ #
37
+ # @param [String] path the path of the file to be exported.
38
+ def self.export_file(path)
39
+ FileUtils.copy_file(path, "#{EXPORT_FILE_PATH}/#{File.basename(path)}")
40
+ end
41
+
29
42
  end
30
43
 
31
44
  end
@@ -24,6 +24,8 @@ module Henry
24
24
  self.execution.output = File.open(OUT_PATH, 'r').read
25
25
  self.execution.log = self.logger.log_as_hash
26
26
  rescue Exception => e
27
+ # retry if self.rerun?
28
+
27
29
  self.execution.code = 'ERROR'
28
30
  self.execution.message = 'ERROR'
29
31
  self.execution.output = File.open(OUT_PATH, 'r').read
@@ -35,15 +37,16 @@ module Henry
35
37
  # Configures the Task.
36
38
  #
37
39
  # @param [Hash] params the task params.
38
- def configure(params)
40
+ # @param [Hash] extended_context task extended context.
41
+ def configure(params, extended_context)
39
42
  File.open(OUT_PATH, 'w') { |f| }
40
43
 
41
44
  # Makes available the cucumber rake task.
42
45
  Cucumber::Rake::Task.new do |t|
43
46
  if self.data.options
44
- t.cucumber_opts = self.custom_options
47
+ t.cucumber_opts = "#{self.custom_options} #{extended_context['options']}"
45
48
  else
46
- t.cucumber_opts = self.default_options
49
+ t.cucumber_opts = "#{self.default_options} #{extended_context['options']}"
47
50
  t.fork = false
48
51
  end
49
52
  end
@@ -55,7 +58,7 @@ module Henry
55
58
  #
56
59
  # @return [String]
57
60
  def custom_options
58
- "#{self.format_options} #{self.tags_options} #{self.report_options} #{self.misc_options}"
61
+ "#{self.format_options} #{self.tags_options} #{self.report_options} #{self.rerun_options} #{self.misc_options}"
59
62
  end
60
63
 
61
64
  # Returns the miscellaneous cucumber_opts.
@@ -101,6 +104,26 @@ module Henry
101
104
  end.join(' ')
102
105
  end
103
106
 
107
+ # Returns the cucumber_opts related with the rerun usage.
108
+ #
109
+ # @return [String]
110
+ def rerun_options
111
+ return ''
112
+
113
+ return '' if self.data.options['rerun'].nil?
114
+
115
+ self.data.options['rerun'] -= 1
116
+
117
+ "---format rerun --out tmp/rerun"
118
+ end
119
+
120
+ # Returns true whenever rerun is set and the reties counter is still positive.
121
+ #
122
+ # @return [True,False]
123
+ def rerun?
124
+ self.data.options['rerun'] && self.data.options['rerun'] >= 0
125
+ end
126
+
104
127
  # Returns the report file path for the given format and file name.
105
128
  #
106
129
  # @param [String] format the rspec formatter name.
@@ -35,17 +35,18 @@ module Henry
35
35
  # Configures the Task.
36
36
  #
37
37
  # @param [Hash] params the task params.
38
- def configure(params)
38
+ # @param [Hash] extended_context the task extended context.
39
+ def configure(params, extended_context)
39
40
  File.open(OUT_PATH, 'w') { |f| }
40
41
 
41
42
  # Makes available the spec rake task.
42
43
  RSpec::Core::RakeTask.new do |t|
43
44
  if self.data.options
44
45
  t.pattern = self.data.options['pattern'] || 'spec/*'
45
- t.rspec_opts = self.custom_options
46
+ t.rspec_opts = "#{self.custom_options} #{extended_context['options']}"
46
47
  else
47
48
  t.pattern = 'spec/*'
48
- t.rspec_opts = self.default_options
49
+ t.rspec_opts = "#{self.default_options} #{extended_context['options']}"
49
50
  end
50
51
  end
51
52
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: henry-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.53
4
+ version: 0.0.54
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-30 00:00:00.000000000 Z
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake