Skip to content

Commit def172b

Browse files
committedNov 21, 2013
Don't rely on local static files
I had a local build/specs.js that gave me false positives.
1 parent 8694bcc commit def172b

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed
 

Diff for: ‎Rakefile

+5
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ desc 'Rebuild grammar.rb for opal parser'
5050
task :racc do
5151
%x(racc -l lib/opal/parser/grammar.y -o lib/opal/parser/grammar.rb)
5252
end
53+
54+
desc 'Remove any generated file.'
55+
task :clobber do
56+
rm_r './build'
57+
end

Diff for: ‎lib/mspec/opal/rake_task.rb

+12-11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def initialize(name, &task_block)
3636
namespace name do
3737
desc 'Run MSpec::Opal code examples' unless ::Rake.application.last_comment
3838
task :default do
39+
puts 'Starting MSpec Runner...'
3940
runner = Runner.new(&task_block)
4041
runner.run
4142
end
@@ -56,7 +57,7 @@ def initialize(name, &task_block)
5657

5758
class Runner
5859
def initialize &block
59-
@app = RackApp.new(&block).app
60+
@app = RackApp.new(&block).to_app
6061
@port = 9999
6162
end
6263

@@ -116,6 +117,8 @@ def initialize(basedir = nil, pattern = nil)
116117
stubs.each do |asset|
117118
::Opal::Processor.stub_file asset
118119
end
120+
121+
ENV['OPAL_SPEC'] = files_to_run(pattern).join(',')
119122
end
120123

121124
def stubs
@@ -136,7 +139,7 @@ def specs
136139
end
137140

138141
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
140143
end
141144

142145
def files
@@ -171,29 +174,27 @@ def files_to_run(pattern=nil)
171174
end
172175

173176
def build_specs file = "#{basedir}/build/specs.js"
174-
ENV['OPAL_SPEC'] = files_to_run(pattern).join(',')
175177
code = specs.to_s
176178
FileUtils.mkdir_p File.dirname(file)
177179
puts "Building #{file}..."
178180
File.open(file, 'w+') { |o| o << code }
179181
end
180182
end
181183

182-
class RackApp
184+
class RackApp < Rack::Builder
183185
attr_accessor :pattern, :basedir
184-
attr_reader :app
185186

186187
def initialize
187188
self.pattern = DEFAULT_PATTERN
188189
self.basedir = DEFAULT_BASEDIR
189190

190191
yield(self) if block_given?
192+
super()
191193

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
197198
end
198199

199200
def environment
@@ -209,7 +210,7 @@ class Index
209210
<title>Opal Specs</title>
210211
</head>
211212
<body>
212-
<script src="/build/specs.js"></script>
213+
<script src="/mspec/opal/main.js"></script>
213214
</body>
214215
</html>
215216
HTML

0 commit comments

Comments
 (0)
Please sign in to comment.