Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly register with app.assets if available or Sprockets otherwise #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jade.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/jade/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions spec/source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
end
2 changes: 1 addition & 1 deletion spec/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down