From aab166f3b39cf8c4269fe1fb93558aca93e245a2 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 27 Dec 2011 18:09:51 -0800 Subject: [PATCH] more sprockets css tests. expire sprockets index on every request in dev mode. fixes #215 --- features/sass_partials.feature | 55 ++++++++++++++++++- .../source/stylesheets/main.css.sass | 5 +- .../source/stylesheets/main2.css.sass | 5 +- .../source/stylesheets/plain.css.sass | 2 + lib/middleman/core_extensions/sprockets.rb | 6 ++ 5 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 fixtures/preview-app/source/stylesheets/plain.css.sass diff --git a/features/sass_partials.feature b/features/sass_partials.feature index 054d8c65..a6972783 100644 --- a/features/sass_partials.feature +++ b/features/sass_partials.feature @@ -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 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 """ body font-size: 14px """ 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 """ body font-size: 18px """ 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 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 """ body font-size: 14px """ When I go to "/stylesheets/main2.css" + Then I should see "color: red;" 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 """ body font-size: 18px """ When I go to "/stylesheets/main2.css" + Then I should see "color: blue;" Then I should see "font-size: 18px" \ No newline at end of file diff --git a/fixtures/preview-app/source/stylesheets/main.css.sass b/fixtures/preview-app/source/stylesheets/main.css.sass index b7c61042..66b4dfd6 100644 --- a/fixtures/preview-app/source/stylesheets/main.css.sass +++ b/fixtures/preview-app/source/stylesheets/main.css.sass @@ -1 +1,4 @@ -@import partial.sass \ No newline at end of file +@import partial.sass + +red + color: blue \ No newline at end of file diff --git a/fixtures/preview-app/source/stylesheets/main2.css.sass b/fixtures/preview-app/source/stylesheets/main2.css.sass index d1c5a9f9..5fb057ac 100644 --- a/fixtures/preview-app/source/stylesheets/main2.css.sass +++ b/fixtures/preview-app/source/stylesheets/main2.css.sass @@ -1 +1,4 @@ -//= require "_partial2.css.sass" \ No newline at end of file +//= require "_partial2.css.sass" + +red + color: blue \ No newline at end of file diff --git a/fixtures/preview-app/source/stylesheets/plain.css.sass b/fixtures/preview-app/source/stylesheets/plain.css.sass new file mode 100644 index 00000000..0c9695d2 --- /dev/null +++ b/fixtures/preview-app/source/stylesheets/plain.css.sass @@ -0,0 +1,2 @@ +red + color: blue \ No newline at end of file diff --git a/lib/middleman/core_extensions/sprockets.rb b/lib/middleman/core_extensions/sprockets.rb index 32bee098..80b85296 100644 --- a/lib/middleman/core_extensions/sprockets.rb +++ b/lib/middleman/core_extensions/sprockets.rb @@ -68,6 +68,7 @@ module Middleman::CoreExtensions::Sprockets class MiddlemanEnvironment < ::Sprockets::Environment def initialize(app) + @app = app super app.source_dir # Make the app context available to Sprockets @@ -82,6 +83,11 @@ module Middleman::CoreExtensions::Sprockets end end end + + def find_asset(path, options = {}) + expire_index! if @app.development? + super + end end class JavascriptEnvironment < MiddlemanEnvironment