marcinbunsch-bolt 0.2.7 → 0.2.8
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/.bolt +1 -0
- data/lib/bolt.rb +35 -17
- data/lib/bolt/listener.rb +11 -24
- data/lib/bolt/listeners/osx.rb +1 -1
- data/lib/bolt/notifiers/growl.rb +3 -3
- data/lib/bolt/runner.rb +2 -1
- data/lib/bolt/runners/cucumber.rb +50 -2
- data/lib/bolt/runners/legacy_test_unit.rb +194 -0
- data/lib/bolt/runners/rspec.rb +16 -2
- data/spec/bolt/listener_spec.rb +17 -0
- data/spec/bolt_spec.rb +39 -0
- metadata +7 -2
data/.bolt
CHANGED
data/lib/bolt.rb
CHANGED
|
@@ -38,7 +38,16 @@ module Bolt
|
|
|
38
38
|
|
|
39
39
|
# check for verbose execution
|
|
40
40
|
def self.verbose?
|
|
41
|
-
@@config['verbose']
|
|
41
|
+
@@config['verbose'] == true
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Trap appropriate signals
|
|
45
|
+
def self.trap_signals
|
|
46
|
+
# ctrl-c should exit
|
|
47
|
+
trap 'INT' do
|
|
48
|
+
$stdout.puts "\n** Exiting Bolt..."
|
|
49
|
+
exit(0)
|
|
50
|
+
end
|
|
42
51
|
end
|
|
43
52
|
|
|
44
53
|
# start bolt
|
|
@@ -51,13 +60,21 @@ module Bolt
|
|
|
51
60
|
# read the arguments passed
|
|
52
61
|
Bolt.read_argv
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
# trap signals
|
|
64
|
+
Bolt.trap_signals
|
|
65
|
+
|
|
66
|
+
listener = Bolt::Listener.new
|
|
67
|
+
|
|
68
|
+
# display info to user
|
|
69
|
+
listener.selected.notifier.info 'Bolt running', "Bolt is enabled and running in #{Dir.pwd}"
|
|
70
|
+
|
|
71
|
+
# if in Rails, start environment
|
|
72
|
+
listener.selected.start
|
|
55
73
|
end
|
|
56
|
-
|
|
57
|
-
autoload :
|
|
58
|
-
autoload :
|
|
59
|
-
autoload :
|
|
60
|
-
autoload :Listener, 'bolt/listener'
|
|
74
|
+
|
|
75
|
+
autoload :Runner, File.dirname(__FILE__) + '/bolt/runner'
|
|
76
|
+
autoload :Notifier, File.dirname(__FILE__) + '/bolt/notifier'
|
|
77
|
+
autoload :Listener, File.dirname(__FILE__) + '/bolt/listener'
|
|
61
78
|
|
|
62
79
|
#
|
|
63
80
|
# Bolt::Listeners
|
|
@@ -65,9 +82,9 @@ module Bolt
|
|
|
65
82
|
# Wrapper for specific listeners
|
|
66
83
|
#
|
|
67
84
|
module Listeners
|
|
68
|
-
autoload :Generic, 'bolt/listeners/generic'
|
|
69
|
-
autoload :Kqueue, 'bolt/listeners/kqueue'
|
|
70
|
-
autoload :Osx, 'bolt/listeners/osx'
|
|
85
|
+
autoload :Generic, File.dirname(__FILE__) + '/bolt/listeners/generic'
|
|
86
|
+
autoload :Kqueue, File.dirname(__FILE__) + '/bolt/listeners/kqueue'
|
|
87
|
+
autoload :Osx, File.dirname(__FILE__) + '/bolt/listeners/osx'
|
|
71
88
|
end
|
|
72
89
|
|
|
73
90
|
#
|
|
@@ -86,10 +103,11 @@ module Bolt
|
|
|
86
103
|
@@noticed_files
|
|
87
104
|
end
|
|
88
105
|
|
|
89
|
-
autoload :Base, 'bolt/runners/base'
|
|
90
|
-
autoload :Cucumber, 'bolt/runners/cucumber'
|
|
91
|
-
autoload :TestUnit, 'bolt/runners/test_unit'
|
|
92
|
-
autoload :
|
|
106
|
+
autoload :Base, File.dirname(__FILE__) + '/bolt/runners/base'
|
|
107
|
+
autoload :Cucumber, File.dirname(__FILE__) + '/bolt/runners/cucumber'
|
|
108
|
+
autoload :TestUnit, File.dirname(__FILE__) + '/bolt/runners/test_unit'
|
|
109
|
+
autoload :LegacyTestUnit, File.dirname(__FILE__) + '/bolt/runners/legacy_test_unit'
|
|
110
|
+
autoload :RSpec, File.dirname(__FILE__) + '/bolt/runners/rspec'
|
|
93
111
|
end
|
|
94
112
|
|
|
95
113
|
#
|
|
@@ -98,8 +116,8 @@ module Bolt
|
|
|
98
116
|
# Wrapper for specific notifier
|
|
99
117
|
#
|
|
100
118
|
module Notifiers
|
|
101
|
-
autoload :Generic, 'bolt/notifiers/generic'
|
|
102
|
-
autoload :Growl, 'bolt/notifiers/growl'
|
|
103
|
-
autoload :NotifyOsd, 'bolt/notifiers/notify_osd'
|
|
119
|
+
autoload :Generic, File.dirname(__FILE__) + '/bolt/notifiers/generic'
|
|
120
|
+
autoload :Growl, File.dirname(__FILE__) + '/bolt/notifiers/growl'
|
|
121
|
+
autoload :NotifyOsd, File.dirname(__FILE__) + '/bolt/notifiers/notify_osd'
|
|
104
122
|
end
|
|
105
123
|
end
|
data/lib/bolt/listener.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require '
|
|
1
|
+
require File.dirname(__FILE__) + '/notifier'
|
|
2
|
+
require File.dirname(__FILE__) + '/runner'
|
|
3
3
|
#
|
|
4
4
|
# Bolt::Listener
|
|
5
5
|
#
|
|
@@ -10,15 +10,13 @@ module Bolt
|
|
|
10
10
|
attr_accessor :selected, :notifier, :runner
|
|
11
11
|
|
|
12
12
|
# Constructor
|
|
13
|
+
# TODO: move most of this code to Bolt.start
|
|
13
14
|
def initialize
|
|
14
15
|
# find appropriate listener
|
|
15
16
|
listener
|
|
16
17
|
|
|
17
18
|
$stdout.puts "** Using #{listener.class} " if Bolt.verbose?
|
|
18
19
|
|
|
19
|
-
# trap the INT signal
|
|
20
|
-
add_sigint_handler
|
|
21
|
-
|
|
22
20
|
# attach a notifier
|
|
23
21
|
self.notifier = Bolt::Notifier.new.selected
|
|
24
22
|
|
|
@@ -35,12 +33,6 @@ module Bolt
|
|
|
35
33
|
# attach listener wrapper
|
|
36
34
|
listener.parent = self
|
|
37
35
|
|
|
38
|
-
# display info to user
|
|
39
|
-
notifier.info 'Bolt running', "Bolt is enabled and running in #{Dir.pwd}"
|
|
40
|
-
|
|
41
|
-
# if in Rails, start environment
|
|
42
|
-
listener.start
|
|
43
|
-
|
|
44
36
|
end
|
|
45
37
|
|
|
46
38
|
# handle updated files found by specific listener
|
|
@@ -52,21 +44,26 @@ module Bolt
|
|
|
52
44
|
# run appropriate tests in runner
|
|
53
45
|
end
|
|
54
46
|
|
|
47
|
+
def os
|
|
48
|
+
# TODO: os identification via RUBY_PLATFORM is flawed as it will return 'java' in jruby. Look for a different solution
|
|
49
|
+
os_string = RUBY_PLATFORM.downcase
|
|
50
|
+
end
|
|
51
|
+
|
|
55
52
|
# Pick a listener to launch
|
|
56
53
|
def listener
|
|
57
54
|
return selected if selected
|
|
58
55
|
|
|
59
56
|
if Bolt['listener'] and ['generic', 'osx'].include?(Bolt['listener'])
|
|
60
57
|
self.selected= Bolt::Listeners::Generic.new if Bolt['listener'] == 'generic'
|
|
61
|
-
self.selected= Bolt::Listeners::Osx.
|
|
58
|
+
self.selected= Bolt::Listeners::Osx.start if Bolt['listener'] == 'osx'
|
|
62
59
|
$stdout.puts "** Found listener setting in .bolt" if Bolt.verbose?
|
|
63
60
|
return self.selected
|
|
64
61
|
end
|
|
65
62
|
|
|
66
63
|
$stdout.puts "** Determining listener..." if Bolt.verbose?
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
os_string = os
|
|
66
|
+
|
|
70
67
|
self.selected= Bolt::Listeners::Generic.new
|
|
71
68
|
self.selected= Bolt::Listeners::Osx.start if os_string.include?("darwin")
|
|
72
69
|
# TODO:
|
|
@@ -74,16 +71,6 @@ module Bolt
|
|
|
74
71
|
# self.selected= Bolt::Listeners::Linux.new if os_string.include?("linux")
|
|
75
72
|
selected
|
|
76
73
|
end
|
|
77
|
-
|
|
78
|
-
# capture the INT signal
|
|
79
|
-
# TODO: Move to Bolt.add_sigint_handler
|
|
80
|
-
def add_sigint_handler
|
|
81
|
-
trap 'INT' do
|
|
82
|
-
$stdout.puts "\n** Exiting Bolt..."
|
|
83
|
-
notifier.info 'Bolt terminated', "Bolt has been terminated"
|
|
84
|
-
exit(0)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
74
|
|
|
88
75
|
end
|
|
89
76
|
end
|
data/lib/bolt/listeners/osx.rb
CHANGED
data/lib/bolt/notifiers/growl.rb
CHANGED
|
@@ -53,7 +53,7 @@ module Bolt
|
|
|
53
53
|
|
|
54
54
|
def result(filename, results)
|
|
55
55
|
message = results
|
|
56
|
-
if results.match('example') #rspec
|
|
56
|
+
if results and results.match('example') #rspec
|
|
57
57
|
if results.match('pending')
|
|
58
58
|
icon = 'pending'
|
|
59
59
|
elsif results.match('0 failures')
|
|
@@ -61,9 +61,9 @@ module Bolt
|
|
|
61
61
|
else
|
|
62
62
|
icon = 'failed'
|
|
63
63
|
end
|
|
64
|
-
elsif
|
|
64
|
+
elsif results and results.match('0 failures, 0 errors') # test::unit
|
|
65
65
|
icon = 'success'
|
|
66
|
-
elsif
|
|
66
|
+
elsif results and results.match(/([0-9]*) scenario(s*) \([0-9]+ passed\) ([0-9]*) step(s*) \([0-9]+ passed\)/) # cucumber
|
|
67
67
|
icon = 'success'
|
|
68
68
|
else
|
|
69
69
|
icon = 'failed'
|
data/lib/bolt/runner.rb
CHANGED
|
@@ -19,7 +19,8 @@ module Bolt
|
|
|
19
19
|
def runner
|
|
20
20
|
return selected if selected
|
|
21
21
|
|
|
22
|
-
if Bolt['runner'] and ['test_unit', 'rspec', 'cucumber'].include?(Bolt['runner'])
|
|
22
|
+
if Bolt['runner'] and ['legacy_test_unit', 'test_unit', 'rspec', 'cucumber'].include?(Bolt['runner'])
|
|
23
|
+
self.selected= Bolt::Runners::LegacyTestUnit.new if Bolt['runner'] == 'legacy_test_unit'
|
|
23
24
|
self.selected= Bolt::Runners::TestUnit.new if Bolt['runner'] == 'test_unit'
|
|
24
25
|
self.selected= Bolt::Runners::RSpec.new if Bolt['runner'] == 'rspec'
|
|
25
26
|
self.selected= Bolt::Runners::Cucumber.new if Bolt['runner'] == 'cucumber'
|
|
@@ -78,6 +78,8 @@ module Bolt
|
|
|
78
78
|
def translate(file)
|
|
79
79
|
self.heard = file
|
|
80
80
|
|
|
81
|
+
puts file
|
|
82
|
+
|
|
81
83
|
case file
|
|
82
84
|
when %r:^app/controllers/:
|
|
83
85
|
name = file.sub('_controller.rb', '').sub('app/controllers/', '')
|
|
@@ -95,7 +97,14 @@ module Bolt
|
|
|
95
97
|
features = self.models[name]
|
|
96
98
|
when %r:.feature$:
|
|
97
99
|
return [file]
|
|
100
|
+
when %r:steps.rb$:
|
|
101
|
+
if Bolt::Runners::Cucumber.mother
|
|
102
|
+
puts '=> reloading step definitions'
|
|
103
|
+
Bolt::Runners::Cucumber.mother.reload_definitions!
|
|
104
|
+
end
|
|
105
|
+
features = [file.gsub('features/step_definitions/', '').gsub('_steps.rb', '')]
|
|
98
106
|
else
|
|
107
|
+
|
|
99
108
|
#
|
|
100
109
|
end
|
|
101
110
|
|
|
@@ -116,7 +125,10 @@ module Bolt
|
|
|
116
125
|
#$".delete(file)
|
|
117
126
|
#require file
|
|
118
127
|
|
|
119
|
-
|
|
128
|
+
if Bolt::Runners::Cucumber.mother and self.heard.match('_steps.rb')
|
|
129
|
+
#puts '=> reloading step definitions'
|
|
130
|
+
#Bolt::Runners::Cucumber.mother.reload_definitions!
|
|
131
|
+
end
|
|
120
132
|
|
|
121
133
|
::Cucumber::Cli::Main.execute(features)
|
|
122
134
|
|
|
@@ -129,8 +141,11 @@ module Bolt
|
|
|
129
141
|
# send buffer to stdout
|
|
130
142
|
puts result
|
|
131
143
|
|
|
144
|
+
if result.include?('You can implement step definitions')
|
|
145
|
+
result = result.split('You can implement step definitions').first
|
|
146
|
+
end
|
|
132
147
|
last_three = result.split("\n")[-3..-1].join(' ')
|
|
133
|
-
last_three = last_three.gsub("\e[32m", '').gsub("\e[0m", '').gsub("\e[36m", '').gsub("\e[31m", '') # get ri of the color codes
|
|
148
|
+
last_three = last_three.gsub("\e[32m", '').gsub("\e[0m", '').gsub("\e[36m", '').gsub("\e[31m", '').gsub("\e[33m", '') # get ri of the color codes
|
|
134
149
|
|
|
135
150
|
# sent result to notifier
|
|
136
151
|
notifier.result(features.join(' '), last_three)
|
|
@@ -142,6 +157,8 @@ module Bolt
|
|
|
142
157
|
end
|
|
143
158
|
|
|
144
159
|
# Cucumber hacks
|
|
160
|
+
# =======
|
|
161
|
+
# Below you will find hacks of cucumber which allow bolt to work
|
|
145
162
|
|
|
146
163
|
# Load Cucumber requirements
|
|
147
164
|
require 'cucumber'
|
|
@@ -150,6 +167,7 @@ begin
|
|
|
150
167
|
rescue LoadError
|
|
151
168
|
puts '** ERROR: Could not load cucumber/rspec_neuter' if Bolt.verbose?
|
|
152
169
|
end
|
|
170
|
+
require 'cucumber/version'
|
|
153
171
|
require 'cucumber/cli/main'
|
|
154
172
|
|
|
155
173
|
module Cucumber #:nodoc:
|
|
@@ -184,4 +202,34 @@ module Cucumber #:nodoc:
|
|
|
184
202
|
|
|
185
203
|
end
|
|
186
204
|
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
if Cucumber::VERSION::STRING=='0.3.3'
|
|
208
|
+
# this applies only to cucumber 0.3.3
|
|
209
|
+
# it prevents cucumber from exiting when features fail
|
|
210
|
+
module Cucumber #:nodoc:
|
|
211
|
+
module Cli #:nodoc:
|
|
212
|
+
class Main #:nodoc:
|
|
213
|
+
def execute!(step_mother)
|
|
214
|
+
configuration.load_language
|
|
215
|
+
step_mother.options = configuration.options
|
|
216
|
+
|
|
217
|
+
require_files
|
|
218
|
+
enable_diffing
|
|
219
|
+
|
|
220
|
+
features = load_plain_text_features
|
|
221
|
+
|
|
222
|
+
visitor = configuration.build_formatter_broadcaster(step_mother)
|
|
223
|
+
step_mother.visitor = visitor # Needed to support World#announce
|
|
224
|
+
visitor.visit_features(features)
|
|
225
|
+
|
|
226
|
+
failure = step_mother.steps(:failed).any? ||
|
|
227
|
+
(configuration.strict? && step_mother.steps(:undefined).any?)
|
|
228
|
+
|
|
229
|
+
# do not exit!!!!!!
|
|
230
|
+
# Kernel.exit(failure ? 1 : 0)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
end
|
|
187
235
|
end
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'test/unit/ui/console/testrunner'
|
|
3
|
+
#
|
|
4
|
+
# Bolt::Runners::TestUnit
|
|
5
|
+
#
|
|
6
|
+
# The TestUnit Runners maps the filename to the appropriate test
|
|
7
|
+
#
|
|
8
|
+
module Bolt
|
|
9
|
+
module Runners
|
|
10
|
+
class LegacyTestUnit
|
|
11
|
+
|
|
12
|
+
MAPPINGS = /(\.\/app\/|\.\/lib\/|\.\/test\/functional|\.\/test\/unit)/
|
|
13
|
+
|
|
14
|
+
attr_accessor :notifier, :test_io
|
|
15
|
+
|
|
16
|
+
def initialize
|
|
17
|
+
fix_test_unit_io
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def fix_test_unit_io
|
|
21
|
+
# Test::Unit stdio capture workaround, taken from Roman2K-rails-test-serving
|
|
22
|
+
self.test_io = StringIO.new
|
|
23
|
+
io = test_io
|
|
24
|
+
Test::Unit::UI::Console::TestRunner.class_eval do
|
|
25
|
+
alias_method :old_initialize, :initialize
|
|
26
|
+
def initialize(suite, output_level, io=Thread.current["test_runner_io"])
|
|
27
|
+
old_initialize(suite, output_level, io)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
Thread.current["test_runner_io"] = io
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# handle specified file
|
|
34
|
+
def handle(file)
|
|
35
|
+
|
|
36
|
+
# force reload of file
|
|
37
|
+
$".delete(file)
|
|
38
|
+
$".delete(File.join(Dir.pwd, file))
|
|
39
|
+
|
|
40
|
+
# reload tests and classes
|
|
41
|
+
if file.match(/(test\/functional|test\/unit|app\/controllers|app\/models|lib\/)/)
|
|
42
|
+
puts '=================='
|
|
43
|
+
klassname = file.sub('test/unit/', '').sub('test/functional/', '').sub('app/controllers/', '').sub('app/models/', '').sub('lib/', '')
|
|
44
|
+
klass_to_be_tested = klassname.sub('.rb', '').gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# remove all methods - don't worry, the reload will bring them back refreshed
|
|
48
|
+
begin
|
|
49
|
+
klass = eval(klass_to_be_tested)
|
|
50
|
+
klass.instance_methods.each { |m|
|
|
51
|
+
begin
|
|
52
|
+
klass.send(:remove_method, m)
|
|
53
|
+
rescue
|
|
54
|
+
end
|
|
55
|
+
}
|
|
56
|
+
rescue NameError
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if file.include?('app/controllers') or file.include?('app/models') or file.include?('lib/')
|
|
61
|
+
begin
|
|
62
|
+
filename = File.join(Dir.pwd, file)
|
|
63
|
+
filename << '.rb' if !filename.match('.rb')
|
|
64
|
+
load filename
|
|
65
|
+
rescue LoadError
|
|
66
|
+
notifier.error("Error in #{file}", $!)
|
|
67
|
+
return []
|
|
68
|
+
rescue ArgumentError
|
|
69
|
+
notifier.error("Error in #{file}", $!)
|
|
70
|
+
return []
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
puts '=> Test::Unit running test for ' + file
|
|
75
|
+
test_files = translate(file)
|
|
76
|
+
|
|
77
|
+
puts '==== Test::Unit running: ' + test_files.join(', ') + ' ===='
|
|
78
|
+
|
|
79
|
+
run(test_files) if test_files != []
|
|
80
|
+
|
|
81
|
+
puts '==== Test::Unit completed run ===='
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# check whether file exists
|
|
86
|
+
def file_verified?(filename)
|
|
87
|
+
if !File.exists?(filename)
|
|
88
|
+
notifier.test_file_missing(filename)
|
|
89
|
+
puts "=> ERROR: could not find test file: #{filename}"
|
|
90
|
+
return false
|
|
91
|
+
end
|
|
92
|
+
return true
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# mapping is a copied and modified version of mislav/rspactor Inspector#translate
|
|
96
|
+
def translate(file)
|
|
97
|
+
|
|
98
|
+
basename = File.basename(file)
|
|
99
|
+
candidates = []
|
|
100
|
+
test_filename = nil
|
|
101
|
+
case file
|
|
102
|
+
when %r:^app/controllers/:
|
|
103
|
+
test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')
|
|
104
|
+
when %r:^app/models/:
|
|
105
|
+
test_filename = "test/unit/#{basename.sub('.rb', '_test.rb')}"
|
|
106
|
+
when %r:^app/views/:
|
|
107
|
+
file = file.sub('app/views/', '')
|
|
108
|
+
directory = file.split('/')[0..-2].compact.join('/')
|
|
109
|
+
test_filename = "test/functional/#{directory}_controller_test.rb"
|
|
110
|
+
when %r:^test/:
|
|
111
|
+
test_filename = file
|
|
112
|
+
when %r:^lib/:
|
|
113
|
+
# map libs to units
|
|
114
|
+
test_filename = "test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}"
|
|
115
|
+
when 'config/routes.rb'
|
|
116
|
+
test_filename = "test/functional/#{basename.sub('.rb', '_test.rb')}"
|
|
117
|
+
#candidates << 'controllers' << 'helpers' << 'views'
|
|
118
|
+
when 'config/database.yml', 'db/schema.rb'
|
|
119
|
+
#candidates << 'models'
|
|
120
|
+
else
|
|
121
|
+
#
|
|
122
|
+
end
|
|
123
|
+
if test_filename and file_verified?(test_filename)
|
|
124
|
+
candidates << test_filename
|
|
125
|
+
end
|
|
126
|
+
if candidates == []
|
|
127
|
+
puts "=> NOTICE: could not find test file for: #{file}"
|
|
128
|
+
end
|
|
129
|
+
# puts candidates.inspect
|
|
130
|
+
candidates
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def run(files)
|
|
134
|
+
file = files.first
|
|
135
|
+
puts "** Running #{file}"
|
|
136
|
+
# make sure that you reload the test file
|
|
137
|
+
#load file
|
|
138
|
+
#contents = File.open(file).read
|
|
139
|
+
# puts contents
|
|
140
|
+
#eval contents
|
|
141
|
+
|
|
142
|
+
# This is Rails' String#camelcase
|
|
143
|
+
klassname = file.sub('test/functional/', '').sub('test/unit/', '')
|
|
144
|
+
test_class = klassname.sub('.rb', '').gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
|
145
|
+
|
|
146
|
+
# create dummy wrapper modules if test is in subfolder
|
|
147
|
+
test_class.split('::').each do |part|
|
|
148
|
+
eval "module ::#{part}; end" if !part.match('Test')
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
$".delete(file)
|
|
152
|
+
|
|
153
|
+
#(defined?(ActiveRecord::Base) ? ActiveRecord::Base.instance_eval { subclasses }.each { |c| c.reset_column_information } : nil)
|
|
154
|
+
#(defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies.clear : nil)
|
|
155
|
+
|
|
156
|
+
begin
|
|
157
|
+
require file
|
|
158
|
+
rescue LoadError
|
|
159
|
+
notifier.error("Error in #{file}", $!)
|
|
160
|
+
puts $!
|
|
161
|
+
return
|
|
162
|
+
rescue ArgumentError
|
|
163
|
+
notifier.error("Error in #{file}", $!)
|
|
164
|
+
puts $!
|
|
165
|
+
return
|
|
166
|
+
rescue SyntaxError
|
|
167
|
+
notifier.error("Error in #{file}", $!)
|
|
168
|
+
puts $!
|
|
169
|
+
return
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# TODO: change that to run multiple suites
|
|
173
|
+
#klass = Kernel.const_get(test_class) - this threw errors
|
|
174
|
+
klass = eval(test_class)
|
|
175
|
+
|
|
176
|
+
Test::Unit::UI::Console::TestRunner.run(klass)
|
|
177
|
+
|
|
178
|
+
# Invoke method to test that writes to stdout.
|
|
179
|
+
result = test_io.string.to_s.dup
|
|
180
|
+
|
|
181
|
+
# clear the buffer
|
|
182
|
+
test_io.truncate(0)
|
|
183
|
+
|
|
184
|
+
# sent result to notifier
|
|
185
|
+
notifier.result(file, result.split("\n").compact.last)
|
|
186
|
+
|
|
187
|
+
# sent result to stdio
|
|
188
|
+
puts result
|
|
189
|
+
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
data/lib/bolt/runners/rspec.rb
CHANGED
|
@@ -69,8 +69,22 @@ module Bolt
|
|
|
69
69
|
|
|
70
70
|
# refresh the loaded test file
|
|
71
71
|
$".delete(file)
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
begin
|
|
73
|
+
require file
|
|
74
|
+
rescue LoadError
|
|
75
|
+
notifier.error("Error in #{file}", $!)
|
|
76
|
+
puts $!
|
|
77
|
+
return
|
|
78
|
+
rescue ArgumentError
|
|
79
|
+
notifier.error("Error in #{file}", $!)
|
|
80
|
+
puts $!
|
|
81
|
+
return
|
|
82
|
+
rescue SyntaxError
|
|
83
|
+
notifier.error("Error in #{file}", $!)
|
|
84
|
+
puts $!
|
|
85
|
+
return
|
|
86
|
+
end
|
|
87
|
+
|
|
74
88
|
# run the tests in the Spec::Runner
|
|
75
89
|
::Spec::Runner::CommandLine.run
|
|
76
90
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/bolt.rb'
|
|
3
|
+
|
|
4
|
+
describe Bolt::Listener do
|
|
5
|
+
|
|
6
|
+
it 'should select appropriate listener' do
|
|
7
|
+
Bolt.set('listener', 'generic')
|
|
8
|
+
instance = Bolt::Listener.new
|
|
9
|
+
instance.listener.class.should == Bolt::Listeners::Generic
|
|
10
|
+
instance.stub(:os).and_return('unknown system')
|
|
11
|
+
instance.os.should == 'unknown system'
|
|
12
|
+
instance.selected = nil
|
|
13
|
+
instance.selected.should == nil
|
|
14
|
+
instance.listener.class.should == Bolt::Listeners::Generic
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
data/spec/bolt_spec.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
require File.dirname(__FILE__) + '/../lib/bolt'
|
|
3
|
+
|
|
4
|
+
describe Bolt do
|
|
5
|
+
|
|
6
|
+
it 'should load .bolt file and access config' do
|
|
7
|
+
File.stub(:exists?).and_return(true)
|
|
8
|
+
YAML.stub(:load_file).and_return({ 'test', 'one' })
|
|
9
|
+
Bolt.read_dotfile
|
|
10
|
+
|
|
11
|
+
Bolt['test'].should == 'one'
|
|
12
|
+
Bolt.get('test').should == 'one'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should read and write config' do
|
|
16
|
+
Bolt.set('test_two', 'two')
|
|
17
|
+
|
|
18
|
+
Bolt['test_two'].should == 'two'
|
|
19
|
+
Bolt.get('test_two').should == 'two'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'should read ARGV' do
|
|
23
|
+
Bolt.set('verbose', 'false')
|
|
24
|
+
ARGV << '-v'
|
|
25
|
+
|
|
26
|
+
Bolt.read_argv
|
|
27
|
+
Bolt['verbose'].should == true
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should response correctly to verbose?' do
|
|
31
|
+
Bolt.set('verbose', 'true')
|
|
32
|
+
Bolt.verbose?.should == true
|
|
33
|
+
Bolt.set('verbose', 'false')
|
|
34
|
+
Bolt.verbose?.should == false
|
|
35
|
+
Bolt.set('verbose', nil)
|
|
36
|
+
Bolt.verbose?.should == false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: marcinbunsch-bolt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcin Bunsch
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-06-
|
|
12
|
+
date: 2009-06-26 00:00:00 -07:00
|
|
13
13
|
default_executable: bolt
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -46,10 +46,13 @@ files:
|
|
|
46
46
|
- lib/bolt/runner.rb
|
|
47
47
|
- lib/bolt/runners/base.rb
|
|
48
48
|
- lib/bolt/runners/cucumber.rb
|
|
49
|
+
- lib/bolt/runners/legacy_test_unit.rb
|
|
49
50
|
- lib/bolt/runners/rspec.rb
|
|
50
51
|
- lib/bolt/runners/test_unit.rb
|
|
52
|
+
- spec/bolt/listener_spec.rb
|
|
51
53
|
- spec/bolt/runners/rspec_spec.rb
|
|
52
54
|
- spec/bolt/runners/test_unit_spec.rb
|
|
55
|
+
- spec/bolt_spec.rb
|
|
53
56
|
has_rdoc: false
|
|
54
57
|
homepage: http://github.com/marcinbunsch/bolt
|
|
55
58
|
post_install_message:
|
|
@@ -77,5 +80,7 @@ signing_key:
|
|
|
77
80
|
specification_version: 3
|
|
78
81
|
summary: Bolt is a merge of autotest, mislav/rspactor and rails_server_testing to produce a lightning fast, configurable and simple to set up autotest clone
|
|
79
82
|
test_files:
|
|
83
|
+
- spec/bolt/listener_spec.rb
|
|
80
84
|
- spec/bolt/runners/rspec_spec.rb
|
|
81
85
|
- spec/bolt/runners/test_unit_spec.rb
|
|
86
|
+
- spec/bolt_spec.rb
|