henry-container 0.0.39 → 0.0.40
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/henry/container/version.rb +1 -1
- data/lib/henry/task/rspec_task.rb +62 -4
- data/lib/henry.rb +2 -0
- metadata +1 -1
@@ -7,6 +7,12 @@ module Henry
|
|
7
7
|
|
8
8
|
# The Henry Task implementation for Rspec
|
9
9
|
class RspecTask < Task
|
10
|
+
|
11
|
+
# The temporary output file path for the RspecTask execution.
|
12
|
+
OUT_PATH = 'rspec.out'
|
13
|
+
|
14
|
+
# The reports path template.
|
15
|
+
REPORTS_DIR = '.henry/reports/${FORMAT}'
|
10
16
|
|
11
17
|
# Executes the Task and returns its results.
|
12
18
|
def execute
|
@@ -15,11 +21,11 @@ module Henry
|
|
15
21
|
|
16
22
|
self.execution.code = 'OK'
|
17
23
|
self.execution.message = 'OK'
|
18
|
-
self.execution.output = File.open(
|
24
|
+
self.execution.output = File.open(OUT_PATH, 'r').read
|
19
25
|
rescue Exception => e
|
20
26
|
self.execution.code = 'ERROR'
|
21
27
|
self.execution.message = 'ERROR'
|
22
|
-
self.execution.output = File.open(
|
28
|
+
self.execution.output = File.open(OUT_PATH, 'r').read
|
23
29
|
self.execution.backtrace = e.message
|
24
30
|
end
|
25
31
|
end
|
@@ -34,16 +40,68 @@ module Henry
|
|
34
40
|
RSpec::Core::RakeTask.new do |t|
|
35
41
|
if self.data.options
|
36
42
|
t.pattern = self.data.options['pattern'] || 'spec/*'
|
37
|
-
t.rspec_opts =
|
43
|
+
t.rspec_opts = self.custom_options
|
38
44
|
else
|
39
45
|
t.pattern = 'spec/*'
|
40
|
-
t.rspec_opts =
|
46
|
+
t.rspec_opts = "--out #{OUT_PATH}"
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
44
50
|
self.export_params(params)
|
45
51
|
end
|
46
52
|
|
53
|
+
protected
|
54
|
+
|
55
|
+
# Returns the custom rspec_opts that user may have passed.
|
56
|
+
#
|
57
|
+
# @return [String]
|
58
|
+
def custom_options
|
59
|
+
"#{self.format_options} #{self.report_options}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the rspec_opts related with formatting.
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
def format_options
|
66
|
+
"--format #{self.data.options['format'] || 'documentation'} --out #{OUT_PATH}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns the rspec_opts related with report paaths and formats.
|
70
|
+
#
|
71
|
+
# @return [String]
|
72
|
+
def report_options
|
73
|
+
return '' if self.data.reports.nil?
|
74
|
+
|
75
|
+
self.data.reports.collect do |report_options|
|
76
|
+
"--format #{report_options['format']} --out #{self.report_file_path(report_options['format'], report_options['name'])}"
|
77
|
+
end.join(' ')
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns the report file path for the given format and file name.
|
81
|
+
#
|
82
|
+
# @param [String] format the rspec formatter name.
|
83
|
+
# @param [String] file_name the report file name template.
|
84
|
+
# @return [String] the report file path.
|
85
|
+
def report_file_path(format, file_name)
|
86
|
+
"#{self.reports_dir(format)}/#{self.report_file_name(file_name)}"
|
87
|
+
end
|
88
|
+
|
89
|
+
# Interpolates and returns the report file name.
|
90
|
+
#
|
91
|
+
# @param [String] file_name the report file name.
|
92
|
+
# @returns [String] the report file name.
|
93
|
+
def report_file_name(file_name)
|
94
|
+
file_name.gsub(/\${[AZ_]}/, '${TASK_NAME}' => self.name, '${DATE}' => DateTime.now.to_s)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Interpolates and returns the reports directory for the given format.
|
98
|
+
#
|
99
|
+
# @param [String] format the formatter name.
|
100
|
+
# @return [Stiring] the reports directory.
|
101
|
+
def reports_dir(format)
|
102
|
+
REPORTS_DIR.gsub(/\${[AZ_]}/, '${FORMAT}' => format)
|
103
|
+
end
|
104
|
+
|
47
105
|
end
|
48
106
|
|
49
107
|
end
|
data/lib/henry.rb
CHANGED