Support Haml 4. Tests only run with Haml 4 now. Fixes #783

This commit is contained in:
Ben Hollis 2013-02-17 19:40:17 -08:00
parent aa10991b78
commit 9057b7a85e
7 changed files with 45 additions and 57 deletions

View file

@ -1,5 +1,8 @@
source :rubygems
# Make sure to use Haml 4 for tests
gem "haml", "~> 4.0.0"
# Build and doc tools
gem "rake", "~> 10.0.3"
gem "yard", "~> 0.8.0"
@ -13,7 +16,6 @@ gem "rspec", "~> 2.12"
# Optional middleman dependencies, included for tests
gem "sinatra"
gem "slim", "~> 1.2.0"
gem "coffee-filter", "~> 0.1.1"
gem "liquid", "~> 2.2"
gem "less", "~> 2.2"
gem "stylus", "~> 0.6.2"

View file

@ -11,25 +11,29 @@ module Middleman
class << self
# Once registered
def registered(app)
app.before_configuration do
template_extensions :coffee => :js
end
# Tell Tilt to use it as well (for inline scss blocks)
::Tilt.register 'coffee', DebuggingCoffeeScriptTemplate
::Tilt.prefer(DebuggingCoffeeScriptTemplate)
app.before_configuration do
template_extensions :coffee => :js
DebuggingCoffeeScriptTemplate.middleman_app = self
end
end
alias :included :registered
end
# A Template for Tilt which outputs debug messages
class DebuggingCoffeeScriptTemplate < ::Tilt::CoffeeScriptTemplate
# Make the current Middleman app accessible to the template
cattr_accessor :middleman_app
# Add exception messaging
# @param [Class] context
# @param [Hash] locals
# @return [String]
def evaluate(context, locals, &block)
return super if context.build?
return super if middleman_app.build?
begin
super

View file

@ -53,13 +53,11 @@ Feature: Minify CSS
When I go to "/inline-css.html"
Then I should see:
"""
<style type='text/css'>
/*<![CDATA[*/
<style>
body {
test: style;
good: deal;
}
/*]]>*/
</style>
"""
@ -83,7 +81,7 @@ Feature: Minify CSS
When I go to "/inline-css.html"
Then I should see:
"""
<style type='text/css'>
<style>
body {
test: style;
good: deal; }
@ -108,7 +106,7 @@ Feature: Minify CSS
When I go to "/inline-css.html"
Then I should see:
"""
<style type='text/css'>
<style>
Hello
</style>
"""
@ -123,9 +121,7 @@ Feature: Minify CSS
When I go to "/inline-css.html"
Then I should see:
"""
<style type='text/css'>
/*<![CDATA[*/
<style>
body{test:style;good:deal}
/*]]>*/
</style>
"""

View file

@ -10,15 +10,13 @@ Feature: Minify Javascript
When I go to "/inline-js.html"
Then I should see:
"""
<script type='text/javascript'>
//<![CDATA[
<script>
;(function() {
this;
should();
all.be();
on = { one: line };
})();
//]]>
</script>
<script>
;(function() {
@ -61,15 +59,13 @@ Feature: Minify Javascript
When I go to "/inline-js.html"
Then I should see:
"""
<script type='text/javascript'>
//<![CDATA[
<script>
;(function() {
this;
should();
all.be();
on = { one: line };
})();
//]]>
</script>
<script>
;(function() {
@ -110,10 +106,8 @@ Feature: Minify Javascript
When I go to "/inline-js.html"
Then I should see:
"""
<script type='text/javascript'>
//<![CDATA[
<script>
Hello
//]]>
</script>
<script>
Hello
@ -138,10 +132,8 @@ Feature: Minify Javascript
When I go to "/inline-js.html"
Then I should see:
"""
<script type='text/javascript'>
//<![CDATA[
<script>
(function(){this,should(),all.be(),on={one:line}})();
//]]>
</script>
<script>
(function(){this,should(),too()})();
@ -177,12 +169,11 @@ Feature: Minify Javascript
Given a fixture app "minify-js-app"
And a file named "config.rb" with:
"""
require "coffee-filter"
activate :minify_javascript, :inline => true
"""
And the Server is running at "minify-js-app"
When I go to "/inline-coffeescript.html"
Then I should see "6" lines
Then I should see "3" lines
Scenario: Rendering external js (coffeescript) with the feature enabled
Given a fixture app "minify-js-app"
@ -198,8 +189,6 @@ Feature: Minify Javascript
Given a fixture app "passthrough-app"
And a file named "config.rb" with:
"""
require "coffee-filter"
module ::PassThrough
def self.compress(data)
data
@ -214,7 +203,7 @@ Feature: Minify Javascript
"""
And the Server is running at "passthrough-app"
When I go to "/inline-coffeescript.html"
Then I should see "16" lines
Then I should see "13" lines
Scenario: Rendering external js (coffeescript) with a passthrough minifier
Given a fixture app "passthrough-app"

View file

@ -1 +0,0 @@
require "coffee-filter"

View file

@ -1 +0,0 @@
require "coffee-filter"

View file

@ -1,5 +1,4 @@
%style(type="text/css")
:sass
:sass
body
test: style
good: deal