more sprockets css tests. expire sprockets index on every request in dev mode. fixes #215

This commit is contained in:
Thomas Reynolds 2011-12-27 18:09:51 -08:00
parent cc7d51c4c8
commit aab166f3b3
5 changed files with 68 additions and 5 deletions

View file

@ -1,34 +1,83 @@
Feature: Sass Partials Feature: Sass Updates and Partials
Scenario: The preview server should update stylesheets when Sass changes
Given the Server is running at "preview-app"
And the file "source/stylesheets/plain.css.sass" has the contents
"""
red
color: red
"""
When I go to "/stylesheets/plain.css"
Then I should see "color: red;"
And the file "source/stylesheets/plain.css.sass" has the contents
"""
red
color: blue
"""
When I go to "/stylesheets/plain.css"
Then I should see "color: blue;"
Scenario: The preview server should update stylesheets when Sass partials change Scenario: The preview server should update stylesheets when Sass partials change
Given the Server is running at "preview-app" Given the Server is running at "preview-app"
And the file "source/stylesheets/main.css.sass" has the contents
"""
@import partial.sass
red
color: red
"""
And the file "source/stylesheets/_partial.sass" has the contents And the file "source/stylesheets/_partial.sass" has the contents
""" """
body body
font-size: 14px font-size: 14px
""" """
When I go to "/stylesheets/main.css" When I go to "/stylesheets/main.css"
Then I should see "font-size: 14px" Then I should see "color: red;"
And I should see "font-size: 14px;"
And the file "source/stylesheets/main.css.sass" has the contents
"""
@import partial.sass
red
color: blue
"""
And the file "source/stylesheets/_partial.sass" has the contents And the file "source/stylesheets/_partial.sass" has the contents
""" """
body body
font-size: 18px font-size: 18px
""" """
When I go to "/stylesheets/main.css" When I go to "/stylesheets/main.css"
Then I should see "font-size: 18px" Then I should see "color: blue;"
And I should see "font-size: 18px"
Scenario: The preview server should update stylesheets when Sprockets partials change Scenario: The preview server should update stylesheets when Sprockets partials change
Given the Server is running at "preview-app" Given the Server is running at "preview-app"
And the file "source/stylesheets/main2.css.sass" has the contents
"""
//= require "_partial2.css.sass"
red
color: red
"""
And the file "source/stylesheets/_partial2.css.sass" has the contents And the file "source/stylesheets/_partial2.css.sass" has the contents
""" """
body body
font-size: 14px font-size: 14px
""" """
When I go to "/stylesheets/main2.css" When I go to "/stylesheets/main2.css"
Then I should see "color: red;"
Then I should see "font-size: 14px" Then I should see "font-size: 14px"
And the file "source/stylesheets/main2.css.sass" has the contents
"""
//= require "_partial2.css.sass"
red
color: blue
"""
And the file "source/stylesheets/_partial2.css.sass" has the contents And the file "source/stylesheets/_partial2.css.sass" has the contents
""" """
body body
font-size: 18px font-size: 18px
""" """
When I go to "/stylesheets/main2.css" When I go to "/stylesheets/main2.css"
Then I should see "color: blue;"
Then I should see "font-size: 18px" Then I should see "font-size: 18px"

View file

@ -1 +1,4 @@
@import partial.sass @import partial.sass
red
color: blue

View file

@ -1 +1,4 @@
//= require "_partial2.css.sass" //= require "_partial2.css.sass"
red
color: blue

View file

@ -0,0 +1,2 @@
red
color: blue

View file

@ -68,6 +68,7 @@ module Middleman::CoreExtensions::Sprockets
class MiddlemanEnvironment < ::Sprockets::Environment class MiddlemanEnvironment < ::Sprockets::Environment
def initialize(app) def initialize(app)
@app = app
super app.source_dir super app.source_dir
# Make the app context available to Sprockets # Make the app context available to Sprockets
@ -82,6 +83,11 @@ module Middleman::CoreExtensions::Sprockets
end end
end end
end end
def find_asset(path, options = {})
expire_index! if @app.development?
super
end
end end
class JavascriptEnvironment < MiddlemanEnvironment class JavascriptEnvironment < MiddlemanEnvironment