@@ -36,6 +36,7 @@ def initialize(name, &task_block)
36
36
namespace name do
37
37
desc 'Run MSpec::Opal code examples' unless ::Rake . application . last_comment
38
38
task :default do
39
+ puts 'Starting MSpec Runner...'
39
40
runner = Runner . new ( &task_block )
40
41
runner . run
41
42
end
@@ -56,7 +57,7 @@ def initialize(name, &task_block)
56
57
57
58
class Runner
58
59
def initialize &block
59
- @app = RackApp . new ( &block ) . app
60
+ @app = RackApp . new ( &block ) . to_app
60
61
@port = 9999
61
62
end
62
63
@@ -116,6 +117,8 @@ def initialize(basedir = nil, pattern = nil)
116
117
stubs . each do |asset |
117
118
::Opal ::Processor . stub_file asset
118
119
end
120
+
121
+ ENV [ 'OPAL_SPEC' ] = files_to_run ( pattern ) . join ( ',' )
119
122
end
120
123
121
124
def stubs
@@ -136,7 +139,7 @@ def specs
136
139
end
137
140
138
141
def build_min file = "#{ basedir } /build/specs.min.js"
139
- build uglify ( specs . to_s ) , file
142
+ build :: Opal :: Builder :: Util . uglify ( specs . to_s ) , file
140
143
end
141
144
142
145
def files
@@ -171,29 +174,27 @@ def files_to_run(pattern=nil)
171
174
end
172
175
173
176
def build_specs file = "#{ basedir } /build/specs.js"
174
- ENV [ 'OPAL_SPEC' ] = files_to_run ( pattern ) . join ( ',' )
175
177
code = specs . to_s
176
178
FileUtils . mkdir_p File . dirname ( file )
177
179
puts "Building #{ file } ..."
178
180
File . open ( file , 'w+' ) { |o | o << code }
179
181
end
180
182
end
181
183
182
- class RackApp
184
+ class RackApp < Rack :: Builder
183
185
attr_accessor :pattern , :basedir
184
- attr_reader :app
185
186
186
187
def initialize
187
188
self . pattern = DEFAULT_PATTERN
188
189
self . basedir = DEFAULT_BASEDIR
189
190
190
191
yield ( self ) if block_given?
192
+ super ( )
191
193
192
- @app = Rack ::Builder . app environment do
193
- use Rack ::ShowExceptions
194
- use Rack ::ShowStatus
195
- use Index
196
- end
194
+ use Rack ::ShowExceptions
195
+ use Rack ::ShowStatus
196
+ use Index
197
+ run environment
197
198
end
198
199
199
200
def environment
@@ -209,7 +210,7 @@ class Index
209
210
< title > Opal Specs</ title >
210
211
</ head >
211
212
< body >
212
- < script src ="/build/specs .js "> </ script >
213
+ < script src ="/mspec/opal/main .js "> </ script >
213
214
</ body >
214
215
</ html >
215
216
HTML
0 commit comments