Skip to content

Commit

Permalink
Add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
spraints committed Sep 9, 2011
1 parent 4079064 commit d3c873e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 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
6 changes: 6 additions & 0 deletions Gemfile.lock
Expand Up @@ -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)
Expand All @@ -17,4 +21,6 @@ PLATFORMS
ruby

DEPENDENCIES
activesupport (~> 3.1.0)
handlebars_assets!
rake
6 changes: 6 additions & 0 deletions 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
31 changes: 31 additions & 0 deletions 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
7 changes: 7 additions & 0 deletions 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'

0 comments on commit d3c873e

Please sign in to comment.