From 048baf651274802cb15d39a27c2e4fe308f6c8d0 Mon Sep 17 00:00:00 2001 From: Jami Couch Date: Wed, 23 Sep 2015 08:25:02 -0500 Subject: [PATCH] Properly register with app.assets (if available) or Sprockets if not --- jade.gemspec | 1 + lib/jade/engine.rb | 4 ++-- spec/source_spec.rb | 6 +++--- spec/template_spec.rb | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jade.gemspec b/jade.gemspec index e4ad024..04fe83b 100644 --- a/jade.gemspec +++ b/jade.gemspec @@ -24,4 +24,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'rspec' s.add_development_dependency 'rails', '>= 3.1' s.add_development_dependency 'pry' + s.add_development_dependency 'sqlite3' end diff --git a/lib/jade/engine.rb b/lib/jade/engine.rb index 72b36ee..7b895b0 100644 --- a/lib/jade/engine.rb +++ b/lib/jade/engine.rb @@ -4,8 +4,8 @@ module Jade class Engine < Rails::Engine initializer "jade.configure_rails_initialization", :before => 'sprockets.environment', :group => :all do |app| - next unless app.config.assets.enabled - Sprockets.register_engine '.jade', ::Jade::Template + sprockets = app.assets || Sprockets + sprockets.register_engine '.jade', ::Jade::Template end end end diff --git a/spec/source_spec.rb b/spec/source_spec.rb index a7ba503..ee5f1f4 100644 --- a/spec/source_spec.rb +++ b/spec/source_spec.rb @@ -2,11 +2,11 @@ describe Jade::Source do it "should contain jade asset" do - File.exist?(Jade::Source::jade_path).should be_true + File.exist?(Jade::Source::jade_path).should be_truthy end it "should contain runtime asset" do - File.exist?(Jade::Source::runtime_path).should be_true + File.exist?(Jade::Source::runtime_path).should be_truthy end it "should be able to read jade source" do @@ -16,4 +16,4 @@ it "should be able to read runtime source" do IO.read(Jade::Source::runtime_path).should_not be_empty end -end \ No newline at end of file +end diff --git a/spec/template_spec.rb b/spec/template_spec.rb index d7d38d8..6ac642f 100644 --- a/spec/template_spec.rb +++ b/spec/template_spec.rb @@ -15,7 +15,7 @@ def template(source, file) it 'should be served' do assets.should serve 'sample.js' - asset_for('sample.js').body.should include "Yap, it works" + asset_for('sample.js').to_s.should include "Yap, it works" end it 'should work fine with JST' do