henry-container 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rvmrc +1 -0
- data/.yardoc/checksums +6 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/bin/henry-ruby-container +23 -0
- data/doc/Henry.html +128 -0
- data/doc/Henry/Container.html +325 -0
- data/doc/Henry/Task.html +551 -0
- data/doc/Henry/Task/CucumberTask.html +299 -0
- data/doc/Henry/Task/RspecTask.html +299 -0
- data/doc/_index.html +153 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file_list.html +52 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +153 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +124 -0
- data/doc/top-level-namespace.html +112 -0
- data/{henry-container-0.0.1.gem → gems/henry-container-0.0.1.gem} +0 -0
- data/{henry-container-0.0.2.gem → gems/henry-container-0.0.2.gem} +0 -0
- data/{henry-container-0.0.3.gem → gems/henry-container-0.0.3.gem} +0 -0
- data/{henry-container-0.0.4.gem → gems/henry-container-0.0.4.gem} +0 -0
- data/{henry-container-0.0.5.gem → gems/henry-container-0.0.5.gem} +0 -0
- data/{henry-container-0.0.6.gem → gems/henry-container-0.0.6.gem} +0 -0
- data/gems/henry-container-0.0.7.gem +0 -0
- data/gems/henry-container-0.0.8.gem +0 -0
- data/henry-container.gemspec +24 -0
- data/henry-context.yml.sample +4 -0
- data/in.henry.sample +14 -0
- 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.rb +8 -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.rb +151 -0
- data/lib/henry/container/version.rb +11 -0
- data/lib/henry/task.rb +32 -0
- data/lib/henry/task/cucumber_task.rb +50 -0
- data/lib/henry/task/rspec_task.rb +50 -0
- metadata +55 -8
data/in.henry.sample
ADDED
File without changes
|
Binary file
|
Binary file
|
Binary file
|
data/lib/henry.rb
ADDED
File without changes
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,151 @@
|
|
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
|
+
|
data/lib/henry/task.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'task/cucumber_task'
|
2
|
+
require_relative 'task/rspec_task'
|
3
|
+
|
4
|
+
module Henry
|
5
|
+
|
6
|
+
# Henry Task
|
7
|
+
class Task
|
8
|
+
|
9
|
+
# Accessors for name and data
|
10
|
+
attr_accessor :name, :data
|
11
|
+
|
12
|
+
# Returns an instance of the target Task class.
|
13
|
+
# @note Factory to create XTask instances.
|
14
|
+
#
|
15
|
+
# @return [Task]
|
16
|
+
def self.create(name, data)
|
17
|
+
return Kernel.eval(data['class_name']).new(name, data)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Initialize the Task with the given name and data.
|
21
|
+
def initialize(name, data)
|
22
|
+
self.name = name
|
23
|
+
self.data = OpenStruct.new(data)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Nothing to be done here yet...
|
27
|
+
def execute(params)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
module Henry
|
5
|
+
|
6
|
+
class Task
|
7
|
+
|
8
|
+
# The Henry Task implementation for Rspec
|
9
|
+
class RspecTask < Task
|
10
|
+
|
11
|
+
# Makes available the spec rake task.
|
12
|
+
RSpec::Core::RakeTask.new do |t|
|
13
|
+
t.rspec_opts = '--out rspec.out --format documentation --color'
|
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('rspec.out', 'w') { |f| }
|
22
|
+
|
23
|
+
tail_pid = Process.spawn('tail -f rspec.out')
|
24
|
+
|
25
|
+
Rake.application['spec'].invoke
|
26
|
+
|
27
|
+
Process.kill(:SIGINT, tail_pid)
|
28
|
+
|
29
|
+
{
|
30
|
+
code:0,
|
31
|
+
message:"OK",
|
32
|
+
data:File.open('rspec.out', 'r').read,
|
33
|
+
stacktrace:nil
|
34
|
+
}
|
35
|
+
rescue Exception => e
|
36
|
+
{
|
37
|
+
code:2,
|
38
|
+
message:e.message,
|
39
|
+
data:File.open('rspec.out', 'r').read,
|
40
|
+
stacktrace:e.backtrace
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
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.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -94,16 +94,63 @@ dependencies:
|
|
94
94
|
description: The Ruby Container for Henry
|
95
95
|
email:
|
96
96
|
- decurnex.roberto@gmail.com
|
97
|
-
executables:
|
97
|
+
executables:
|
98
|
+
- henry-ruby-container
|
98
99
|
extensions: []
|
99
100
|
extra_rdoc_files: []
|
100
101
|
files:
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
102
|
+
- .gitignore
|
103
|
+
- .rvmrc
|
104
|
+
- .yardoc/checksums
|
105
|
+
- .yardoc/object_types
|
106
|
+
- .yardoc/objects/root.dat
|
107
|
+
- .yardoc/proxy_types
|
108
|
+
- Gemfile
|
109
|
+
- Rakefile
|
110
|
+
- bin/henry-ruby-container
|
111
|
+
- doc/Henry.html
|
112
|
+
- doc/Henry/Container.html
|
113
|
+
- doc/Henry/Task.html
|
114
|
+
- doc/Henry/Task/CucumberTask.html
|
115
|
+
- doc/Henry/Task/RspecTask.html
|
116
|
+
- doc/_index.html
|
117
|
+
- doc/class_list.html
|
118
|
+
- doc/css/common.css
|
119
|
+
- doc/css/full_list.css
|
120
|
+
- doc/css/style.css
|
121
|
+
- doc/file_list.html
|
122
|
+
- doc/frames.html
|
123
|
+
- doc/index.html
|
124
|
+
- doc/js/app.js
|
125
|
+
- doc/js/full_list.js
|
126
|
+
- doc/js/jquery.js
|
127
|
+
- doc/method_list.html
|
128
|
+
- doc/top-level-namespace.html
|
129
|
+
- gems/henry-container-0.0.1.gem
|
130
|
+
- gems/henry-container-0.0.2.gem
|
131
|
+
- gems/henry-container-0.0.3.gem
|
132
|
+
- gems/henry-container-0.0.4.gem
|
133
|
+
- gems/henry-container-0.0.5.gem
|
134
|
+
- gems/henry-container-0.0.6.gem
|
135
|
+
- gems/henry-container-0.0.7.gem
|
136
|
+
- gems/henry-container-0.0.8.gem
|
137
|
+
- henry-container.gemspec
|
138
|
+
- henry-context.yml.sample
|
139
|
+
- in.henry.sample
|
140
|
+
- lib/.yardoc/checksums
|
141
|
+
- lib/.yardoc/object_types
|
142
|
+
- lib/.yardoc/objects/root.dat
|
143
|
+
- lib/.yardoc/proxy_types
|
144
|
+
- lib/henry.rb
|
145
|
+
- lib/henry/.yardoc/checksums
|
146
|
+
- lib/henry/.yardoc/object_types
|
147
|
+
- lib/henry/.yardoc/objects/root.dat
|
148
|
+
- lib/henry/.yardoc/proxy_types
|
149
|
+
- lib/henry/container.rb
|
150
|
+
- lib/henry/container/version.rb
|
151
|
+
- lib/henry/task.rb
|
152
|
+
- lib/henry/task/cucumber_task.rb
|
153
|
+
- lib/henry/task/rspec_task.rb
|
107
154
|
homepage: http://henry.despegar.it
|
108
155
|
licenses: []
|
109
156
|
post_install_message:
|