henry-container 0.0.58 → 0.0.59

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,2 +1,5 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new { |t| t.pattern = './spec{,/*/**}/*_spec.rb' }
@@ -3,7 +3,7 @@ module Henry
3
3
  class Container
4
4
 
5
5
  # Current Gem version
6
- VERSION = '0.0.58'
6
+ VERSION = '0.0.59'
7
7
 
8
8
  end
9
9
 
@@ -1,4 +1,5 @@
1
1
  require 'rake'
2
+ require 'fileutils'
2
3
  require 'cucumber/rake/task'
3
4
 
4
5
  module Henry
@@ -100,6 +101,7 @@ module Henry
100
101
  return '' if self.data.reports.nil?
101
102
 
102
103
  self.data.reports.collect do |report_options|
104
+ FileUtils.mkdir_p(self.reports_dir(report_options['format']))
103
105
  "--format #{report_options['format']} --out #{self.report_file_path(report_options['format'], report_options['name'])}"
104
106
  end.join(' ')
105
107
  end
@@ -0,0 +1,64 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ module Henry
5
+
6
+ class Task
7
+
8
+ # The Henry Task implementation for MiniTest
9
+ class MiniTestTask < Task
10
+
11
+ # The temporary output file path for the MiniTest execution.
12
+ OUT_PATH = 'minitest.out'
13
+
14
+ # The reports path template.
15
+ REPORTS_DIR = '.henry/reports/minitest'
16
+
17
+ # Executes the Task and returns its results.
18
+ def execute
19
+ begin
20
+ Rake.application['minitest'].invoke
21
+
22
+ self.execution.code = 'OK'
23
+ self.execution.message = 'OK'
24
+ self.execution.output = File.open(OUT_PATH, 'r').read
25
+ rescue Exception => e
26
+ self.execution.code = 'ERROR'
27
+ self.execution.message = 'ERROR'
28
+ self.execution.output = File.open(OUT_PATH, 'r').read
29
+ self.execution.backtrace = e.message
30
+ end
31
+ end
32
+
33
+ # Configures the Task.
34
+ #
35
+ # @param [Hash] params the task params.
36
+ def configure(params)
37
+ File.open(OUT_PATH, 'w') { |f| }
38
+
39
+ pattern = params['pattern'] || './spec{,/*/**}/*_spec.rb'
40
+ format = params['format'] || 'SpecReporter'
41
+
42
+ File.open("preconfig.rb", 'w') do |f|
43
+ f.write <<CODE
44
+ $stdout = File.open('#{OUT_PATH}', 'w')
45
+ require 'minitest/autorun'
46
+ require 'minitest/reporters'
47
+ MiniTest::Reporters.use! MiniTest::Reporters::#{format}.new
48
+ CODE
49
+ end
50
+
51
+ # Makes available the spec rake task.
52
+ Rake::TestTask.new('minitest') do |t|
53
+ t.pattern = pattern
54
+ t.ruby_opts << "-r ./preconfig"
55
+ end
56
+
57
+ self.export_params(params)
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -1,4 +1,5 @@
1
1
  require 'rake'
2
+ require 'fileutils'
2
3
  require 'rspec/core/rake_task'
3
4
 
4
5
  module Henry
@@ -94,6 +95,7 @@ module Henry
94
95
  return '' if self.data.reports.nil?
95
96
 
96
97
  self.data.reports.collect do |report_options|
98
+ FileUtils.mkdir_p(self.reports_dir(report_options['format']))
97
99
  "--format #{report_options['format']} --out #{self.report_file_path(report_options['format'], report_options['name'])}"
98
100
  end.join(' ')
99
101
  end
data/lib/henry/task.rb CHANGED
@@ -1,14 +1,15 @@
1
1
  require_relative 'task/cucumber_task'
2
2
  require_relative 'task/rspec_task'
3
+ require_relative 'task/minitest_task'
3
4
 
4
5
  module Henry
5
-
6
- # Henry Task
6
+
7
+ # Henry Task
7
8
  class Task
8
9
 
9
10
  # Accessors for name, data and enabled
10
11
  attr_accessor :name, :data, :enabled
11
-
12
+
12
13
  # Returns an instance of the target Task class.
13
14
  # @note Factory to create X Task instances.
14
15
  #
@@ -16,7 +17,7 @@ module Henry
16
17
  def self.create(name, data)
17
18
  return Kernel.eval(data['class_name']).new(name, data)
18
19
  end
19
-
20
+
20
21
  # Initialize the Task with the given name and data.
21
22
  def initialize(name, data)
22
23
  self.name = name
@@ -41,7 +42,7 @@ module Henry
41
42
  def report
42
43
  self.execution.report
43
44
  end
44
-
45
+
45
46
  # Exports the Task params to the ENV.
46
47
  #
47
48
  # @param [Hash] params the Task params to be exported.
@@ -91,7 +92,7 @@ module Henry
91
92
  def execute
92
93
  abort "Your task class ('#{self.class}' may be?) MUST define this method with its execution logic."
93
94
  end
94
-
95
+
95
96
  # Nothing to be done here...
96
97
  # The Task configuration code should be defined under this method on the specific Task class.
97
98
  def configure(params)
@@ -0,0 +1,19 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require 'henry'
4
+ require 'henry/task/minitest_task'
5
+
6
+ describe Henry::Task::MiniTestTask do
7
+
8
+ before do
9
+ @task = Henry::Task.create('name', {'class_name' => "Henry::Task::MiniTestTask"})
10
+ @task.configure({'pattern' => 'spec/task/*'})
11
+ @task.execute
12
+ @output_path = Henry::Task::MiniTestTask::OUT_PATH
13
+ end
14
+
15
+ it "must log something" do
16
+ File.open(@output_path).read.wont_be_empty
17
+ end
18
+
19
+ end
@@ -0,0 +1,7 @@
1
+ describe "This is a Henry MiniTest Task test" do
2
+
3
+ it "must be true" do
4
+ true.must_equal true
5
+ end
6
+
7
+ end
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.58
4
+ version: 0.0.59
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-09-19 00:00:00.000000000 Z
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -133,7 +133,10 @@ files:
133
133
  - lib/henry/logger_service.rb
134
134
  - lib/henry/task.rb
135
135
  - lib/henry/task/cucumber_task.rb
136
+ - lib/henry/task/minitest_task.rb
136
137
  - lib/henry/task/rspec_task.rb
138
+ - spec/minitest_task_spec.rb
139
+ - spec/task/minitest_test_task.rb
137
140
  homepage: http://henry.despegar.it
138
141
  licenses: []
139
142
  post_install_message:
@@ -158,5 +161,7 @@ rubygems_version: 1.8.24
158
161
  signing_key:
159
162
  specification_version: 3
160
163
  summary: The Ruby Container for Henry
161
- test_files: []
164
+ test_files:
165
+ - spec/minitest_task_spec.rb
166
+ - spec/task/minitest_test_task.rb
162
167
  has_rdoc: