Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a test.

  • Loading branch information...
commit d3c873efd256328e7e6a6f2b3f95463b88a5a31f 1 parent 4079064
@spraints spraints authored
View
3  Gemfile
@@ -1,4 +1,7 @@
source "http://rubygems.org"
+gem 'rake'
+gem 'activesupport', '~>3.1.0'
+
# Specify your gem's dependencies in handlebars_assets.gemspec
gemspec
View
6 Gemfile.lock
@@ -8,7 +8,11 @@ PATH
GEM
remote: http://rubygems.org/
specs:
+ activesupport (3.1.0)
+ multi_json (~> 1.0)
libv8 (3.3.10.2)
+ multi_json (1.0.3)
+ rake (0.9.2)
therubyracer (0.9.3)
libv8 (~> 3.3.10)
tilt (1.3.2)
@@ -17,4 +21,6 @@ PLATFORMS
ruby
DEPENDENCIES
+ activesupport (~> 3.1.0)
handlebars_assets!
+ rake
View
6 Rakefile
@@ -1 +1,7 @@
require "bundler/gem_tasks"
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.libs << 'test'
+ t.test_files = FileList['test/**/*_test.rb']
+end
View
31 test/handlebars_assets/tilt_handlebars_test.rb
@@ -0,0 +1,31 @@
+require 'test_helper'
+
+module HandlebarsAssets
+ class TiltHandlebarsTest < Test::Unit::TestCase
+ def test_render
+ # Try to act like sprockets.
+ scope = Object.new
+ class << scope
+ def logical_path ; 'x11' ; end
+ end
+ template = HandlebarsAssets::TiltHandlebars.new('/myapp/app/assets/templates/x11.jst.hbs') { "This is {{handlebars}}" }
+ assert_equal <<END_EXPECTED, template.render(scope, {})
+ function(context) {
+ return HandlebarsTemplates["x11"](context);
+ };
+ this.HandlebarsTemplates || (this.HandlebarsTemplates = {});
+ this.HandlebarsTemplates["x11"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
+ helpers = helpers || Handlebars.helpers;
+ var buffer = "", stack1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
+
+
+ buffer += "This is ";
+ stack1 = helpers.handlebars || depth0.handlebars
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "handlebars", { hash: {} }); }
+ buffer += escapeExpression(stack1);
+ return buffer;});
+END_EXPECTED
+ end
+ end
+end
View
7 test/test_helper.rb
@@ -0,0 +1,7 @@
+require 'active_support/core_ext/string/starts_ends_with'
+
+require 'handlebars_assets/tilt_handlebars'
+require 'handlebars_assets/loader'
+require 'handlebars_assets/handlebars'
+
+require 'test/unit'
Please sign in to comment.
Something went wrong with that request. Please try again.