henry-container 0.0.4 → 0.0.5
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.
- data/{gems/henry-container-0.0.1.gem → henry-container-0.0.1.gem} +0 -0
- data/{gems/henry-container-0.0.2.gem → henry-container-0.0.2.gem} +0 -0
- data/{gems/henry-container-0.0.3.gem → henry-container-0.0.3.gem} +0 -0
- data/henry-container-0.0.4.gem +0 -0
- metadata +7 -49
- data/.gitignore +0 -2
- data/.rvmrc +0 -1
- data/.yardoc/checksums +0 -5
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +0 -4
- data/Rakefile +0 -2
- data/bin/henry-ruby-container +0 -23
- data/doc/Henry/Container.html +0 -319
- data/doc/Henry/Task/CucumberTask.html +0 -287
- data/doc/Henry/Task.html +0 -551
- data/doc/Henry.html +0 -128
- data/doc/_index.html +0 -138
- data/doc/class_list.html +0 -53
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -57
- data/doc/css/style.css +0 -328
- data/doc/file_list.html +0 -52
- data/doc/frames.html +0 -28
- data/doc/index.html +0 -138
- data/doc/js/app.js +0 -214
- data/doc/js/full_list.js +0 -173
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -116
- data/doc/top-level-namespace.html +0 -112
- data/henry-container.gemspec +0 -24
- data/henry-context.yml.sample +0 -4
- data/in.henry.sample +0 -14
- data/lib/.yardoc/checksums +0 -0
- data/lib/.yardoc/object_types +0 -0
- data/lib/.yardoc/objects/root.dat +0 -0
- data/lib/.yardoc/proxy_types +0 -0
- data/lib/henry/.yardoc/checksums +0 -0
- data/lib/henry/.yardoc/object_types +0 -0
- data/lib/henry/.yardoc/objects/root.dat +0 -0
- data/lib/henry/.yardoc/proxy_types +0 -0
- data/lib/henry/container/version.rb +0 -11
- data/lib/henry/container.rb +0 -151
- data/lib/henry/task/cucumber_task.rb +0 -50
- data/lib/henry/task.rb +0 -31
- data/lib/henry.rb +0 -8
data/lib/henry/container.rb
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
require_relative 'container/version'
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
require 'ostruct'
|
5
|
-
require 'json'
|
6
|
-
require 'rake'
|
7
|
-
require 'colorize'
|
8
|
-
|
9
|
-
module Henry
|
10
|
-
|
11
|
-
# Henry Container
|
12
|
-
class Container
|
13
|
-
|
14
|
-
# Nothing to be done here yet...
|
15
|
-
def initialize(opts)
|
16
|
-
@opts = opts
|
17
|
-
end
|
18
|
-
|
19
|
-
# Executes the loaded tasks and stores their results.
|
20
|
-
def execute
|
21
|
-
self.before_execution
|
22
|
-
|
23
|
-
self.tasks_results = self.tasks.collect do |task|
|
24
|
-
task.execute(self.task_params(task.name))
|
25
|
-
end
|
26
|
-
|
27
|
-
self.update_results
|
28
|
-
|
29
|
-
self.dump_results
|
30
|
-
end
|
31
|
-
|
32
|
-
protected
|
33
|
-
|
34
|
-
# Initial state the conteiner execution results.
|
35
|
-
#
|
36
|
-
# @return [Hash] the results template.
|
37
|
-
RESULTS_TEMPLATE = {
|
38
|
-
summary: {
|
39
|
-
total: 0,
|
40
|
-
tasks_results: [],
|
41
|
-
breakdown_by_status_code: {
|
42
|
-
0 => 0,
|
43
|
-
1 => 0,
|
44
|
-
2 => 0
|
45
|
-
},
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
# Returns the input file path based on the given options.
|
50
|
-
#
|
51
|
-
# @return [String] the input file path.
|
52
|
-
def input_file_path
|
53
|
-
"#{@opts[:"in-dir"]}#{@opts[:in]}"
|
54
|
-
end
|
55
|
-
|
56
|
-
# Returns the output file path based on the given options.
|
57
|
-
#
|
58
|
-
# @return [String] the output file path.
|
59
|
-
def output_file_path
|
60
|
-
"#{@opts[:"out-dir"]}#{@opts[:out]}"
|
61
|
-
end
|
62
|
-
|
63
|
-
# Executes required validations before execution.
|
64
|
-
def before_execution
|
65
|
-
unless File.exists?(self.input_file_path)
|
66
|
-
abort "#{"'#{self.input_file_path}' file does not exist.".red}\n #{'*'.red} If running isolated make sure to create it first.\n #{'*'.red} If running from Henry contact us at henry@despegar.it."
|
67
|
-
end
|
68
|
-
|
69
|
-
unless File.exists?('henry-context.yml')
|
70
|
-
abort "'henry-context.yml' file does not exist. You need it in order to execute a Henry compatible test.".red
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
# Loads and parses the @opts[:in] params.
|
76
|
-
#
|
77
|
-
# @return [{String => String}] the execution params.
|
78
|
-
def params
|
79
|
-
@params ||= JSON.parse(File.read(self.input_file_path))
|
80
|
-
end
|
81
|
-
|
82
|
-
# Returns the default params.
|
83
|
-
# @note Custom task_params will overwrite the defaults.
|
84
|
-
#
|
85
|
-
# @return [Hash] the default params.
|
86
|
-
def default_params
|
87
|
-
@default_params ||= self.params['all']
|
88
|
-
end
|
89
|
-
|
90
|
-
# Returns the custom params for the given task.
|
91
|
-
# @note default_params will be used for undefined keys.
|
92
|
-
#
|
93
|
-
# @param [String] task_name the target Task name.
|
94
|
-
# @return [Hash] the Task custom params.
|
95
|
-
def task_params(task_name)
|
96
|
-
self.default_params.merge(self.params[task_name] || {})
|
97
|
-
end
|
98
|
-
|
99
|
-
# Load and parses the henry-context.yml params.
|
100
|
-
#
|
101
|
-
# @return [{String => String}] the execution context.
|
102
|
-
def context
|
103
|
-
@context ||= OpenStruct.new(YAML.load_file('henry-context.yml'))
|
104
|
-
end
|
105
|
-
|
106
|
-
# Returns the tasks to be executed based on the context.
|
107
|
-
#
|
108
|
-
# @return [<Task>] tasks to be executed.
|
109
|
-
def tasks
|
110
|
-
@tasks ||= self.context.tasks.collect { |task_data| Task.create(task_data["name"], task_data) }
|
111
|
-
end
|
112
|
-
|
113
|
-
# Returns the execution's current results.
|
114
|
-
#
|
115
|
-
# @return [Hash] the execution's current resutls.
|
116
|
-
def results
|
117
|
-
@results ||= RESULTS_TEMPLATE
|
118
|
-
end
|
119
|
-
|
120
|
-
# Returns the tasks_results node from the results hash.
|
121
|
-
#
|
122
|
-
# @return [Array]
|
123
|
-
def tasks_results
|
124
|
-
self.results[:summary][:tasks_results]
|
125
|
-
end
|
126
|
-
|
127
|
-
# Serts the tasks_results node of the results hash.
|
128
|
-
#
|
129
|
-
# @param [Array] results the tasks_results collection.
|
130
|
-
def tasks_results=(results)
|
131
|
-
self.results[:summary][:tasks_results] = results
|
132
|
-
end
|
133
|
-
|
134
|
-
# Updates the results attributes based on the task_results.
|
135
|
-
def update_results
|
136
|
-
self.tasks_results.each do |task_results|
|
137
|
-
self.results[:summary][:total] += 1
|
138
|
-
|
139
|
-
self.results[:summary][:breakdown_by_status_code][task_results[:code]] += 1
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
# Writes into @opts[:out] the execution results.
|
144
|
-
def dump_results
|
145
|
-
File.open(self.output_file_path, 'w') { |f| f.write(results.to_json) }
|
146
|
-
end
|
147
|
-
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'cucumber/rake/task'
|
3
|
-
|
4
|
-
module Henry
|
5
|
-
|
6
|
-
class Task
|
7
|
-
|
8
|
-
# The Henry Task implementation for Cucumber
|
9
|
-
class CucumberTask < Task
|
10
|
-
|
11
|
-
# Makes available the cucumber rake task.
|
12
|
-
Cucumber::Rake::Task.new do |t|
|
13
|
-
t.cucumber_opts = %w{--out cucumber.out}
|
14
|
-
end
|
15
|
-
|
16
|
-
# Executes the CucumberTask and returns its results.
|
17
|
-
#
|
18
|
-
# @return [Hash] the CucumberTask results.
|
19
|
-
def execute(params)
|
20
|
-
begin
|
21
|
-
File.open('cucumber.out', 'w') { |f| }
|
22
|
-
|
23
|
-
tail_pid = Process.spawn('tail -f cucumber.out')
|
24
|
-
|
25
|
-
Rake.application['cucumber'].invoke
|
26
|
-
|
27
|
-
Process.kill(:SIGINT, tail_pid)
|
28
|
-
|
29
|
-
{
|
30
|
-
code:0,
|
31
|
-
message:"OK",
|
32
|
-
data:File.open('cucumber.out', 'r').read,
|
33
|
-
stacktrace:nil
|
34
|
-
}
|
35
|
-
rescue Exception => e
|
36
|
-
{
|
37
|
-
code:2,
|
38
|
-
message:e.message,
|
39
|
-
data:File.open('cucumber.out', 'r').read,
|
40
|
-
stacktrace:e.backtrace
|
41
|
-
}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
data/lib/henry/task.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require_relative 'task/cucumber_task'
|
2
|
-
|
3
|
-
module Henry
|
4
|
-
|
5
|
-
# Henry Task
|
6
|
-
class Task
|
7
|
-
|
8
|
-
# Accessors for name and data
|
9
|
-
attr_accessor :name, :data
|
10
|
-
|
11
|
-
# Returns an instance of the target Task class.
|
12
|
-
# @note Factory to create XTask instances.
|
13
|
-
#
|
14
|
-
# @return [Task]
|
15
|
-
def self.create(name, data)
|
16
|
-
return Kernel.eval(data['class_name']).new(name, data)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Initialize the Task with the given name and data.
|
20
|
-
def initialize(name, data)
|
21
|
-
self.name = name
|
22
|
-
self.data = OpenStruct.new(data)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Nothing to be done here yet...
|
26
|
-
def execute(params)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|