test/helper.rb in skim-0.8.2 vs test/helper.rb in skim-0.8.3
- old
+ new
@@ -1,26 +1,29 @@
require "rubygems"
require "minitest/unit"
require "minitest/reporters"
require "skim"
require "coffee_script"
+require "execjs"
-MiniTest::Unit.runner = MiniTest::SuiteRunner.new
-MiniTest::Unit.runner.reporters <<
- if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
- MiniTest::Reporters::RubyMineReporter.new
- else
- MiniTest::Reporters::ProgressReporter.new
- end
+if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
+ MiniTest::Reporters.use! MiniTest::Reporters::RubyMineReporter.new
+else
+ MiniTest::Reporters.use! MiniTest::Reporters::ProgressReporter.new
+end
MiniTest::Unit.autorun
class TestSkim < MiniTest::Unit::TestCase
def context_source
File.read(File.expand_path("../context.coffee", __FILE__))
end
+ def skim_source
+ CoffeeScript.compile(Skim::Template.skim_src)
+ end
+
def setup
@context = CoffeeScript.compile(context_source, :bare => true)
end
def context(options)
@@ -37,18 +40,17 @@
def compile(source, options = {})
Skim::Template.new(options[:file], options) { source }.render(options[:scope] || Env.new)
end
def evaluate(source, options = {})
- require "execjs"
code = [
@context,
"var context = #{context(options)}",
"var template = #{compile(source, options)}",
"var evaluate = function () { return template(context); }"
]
if Skim::Engine.default_options[:use_asset]
- code.unshift CoffeeScript.compile(Skim::Template.skim_src)
+ code.unshift skim_source
end
context = ExecJS.compile(code.join(";"))
context.call("evaluate")
end