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

Support sprockets-rails 3 #41

Merged
merged 4 commits into from
Jan 20, 2016
Merged
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ script: "bundle exec rake test"
gemfile:
- gemfiles/sprockets_2_12.gemfile
- gemfiles/sprockets_3_0.gemfile
- gemfiles/sprockets-rails_3_0.gemfile
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_4_1.gemfile
- gemfiles/rails_4_0.gemfile
Expand Down
7 changes: 7 additions & 0 deletions gemfiles/sprockets-rails_3_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

gem "sprockets", "~> 3.0.0"
gem "sprockets-rails", github: "rails/sprockets-rails"

# Specify your gem's dependencies in sassc-rails.gemspec
gemspec path: "../"
8 changes: 4 additions & 4 deletions lib/sassc/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ class Railtie < ::Rails::Railtie
# config.sass.full_exception = app.config.consider_all_requests_local
# end

if app.assets
app.assets.context_class.class_eval do
app.config.assets.configure do |env|
env.context_class.class_eval do
class_attribute :sass_config
self.sass_config = app.config.sass
end

app.assets.register_engine '.sass', SassC::Rails::SassTemplate
app.assets.register_engine '.scss', SassC::Rails::ScssTemplate
env.register_engine '.sass', SassC::Rails::SassTemplate
env.register_engine '.scss', SassC::Rails::ScssTemplate
end
end

Expand Down
13 changes: 9 additions & 4 deletions test/sassc_rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def setup
@app.config.sass.line_comments = false

# Add a fake compressor for testing purposes
@app.assets.register_compressor "text/css", :test, TestCompressor
@app.config.assets.configure do |env|
env.register_compressor "text/css", :test, TestCompressor
end

Rails.backtrace_cleaner.remove_silencers!
end
Expand Down Expand Up @@ -230,11 +232,12 @@ def test_compression_works
end

def test_sassc_compression_is_used
initialize_prod!

engine = stub(render: "")
SassC::Engine.expects(:new).returns(engine)
SassC::Engine.expects(:new).with("", {style: :compressed}).returns(engine)

initialize_prod!

render_asset("application.scss")
end

Expand Down Expand Up @@ -322,5 +325,7 @@ def test_globbed_imports_work_when_globbed_file_is_added
end
end

class TestCompressor; end
class TestCompressor
def self.call(*); end
end
end