From 240f67410d9fca78cdb033fc83d0208d24872b75 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 26 Apr 2012 14:07:10 -0700 Subject: [PATCH] Use config.rb file contents in minify test cases instead of fixtures --- .../features/extensionless_text_files.feature | 2 - middleman-more/features/minify_css.feature | 35 ++++++-- .../features/minify_javascript.feature | 82 ++++++++++++++++--- .../fixtures/minify-css-app/config.rb | 0 .../fixtures/passthrough-app/config.rb | 17 ---- 5 files changed, 102 insertions(+), 34 deletions(-) delete mode 100644 middleman-more/fixtures/minify-css-app/config.rb delete mode 100644 middleman-more/fixtures/passthrough-app/config.rb diff --git a/middleman-core/features/extensionless_text_files.feature b/middleman-core/features/extensionless_text_files.feature index dd015440..d5e983d9 100644 --- a/middleman-core/features/extensionless_text_files.feature +++ b/middleman-core/features/extensionless_text_files.feature @@ -1,7 +1,6 @@ Feature: Text Files Without Extensions Should Build and Preview Scenario: Building Text Files without directory indexes - Given a fixture app "extensionless-text-files-app" And a file named "config.rb" with: """ @@ -14,7 +13,6 @@ Feature: Text Files Without Extensions Should Build and Preview | README | Scenario: Building Text Files with directory indexes - Given a fixture app "extensionless-text-files-app" And a file named "config.rb" with: """ diff --git a/middleman-more/features/minify_css.feature b/middleman-more/features/minify_css.feature index 27bbb0e0..78a8d5e9 100644 --- a/middleman-more/features/minify_css.feature +++ b/middleman-more/features/minify_css.feature @@ -1,8 +1,5 @@ Feature: Minify CSS In order reduce bytes sent to client and appease YSlow - - Background: - Given current environment is "build" Scenario: Rendering external css with the feature disabled Given a fixture app "minify-css-app" @@ -28,7 +25,20 @@ Feature: Minify CSS Then I should see "1" lines Scenario: Rendering external css with passthrough compressor - Given the Server is running at "passthrough-app" + Given a fixture app "passthrough-app" + And a file named "config.rb" with: + """ + module ::PassThrough + def self.compress(data) + data + end + end + + activate :minify_css + + set :css_compressor, ::PassThrough + """ + And the Server is running at "passthrough-app" When I go to "/stylesheets/site.css" Then I should see "55" lines @@ -52,7 +62,22 @@ Feature: Minify CSS """ Scenario: Rendering inline css with a passthrough minifier - Given the Server is running at "passthrough-app" + Given a fixture app "passthrough-app" + And a file named "config.rb" with: + """ + module ::PassThrough + def self.compress(data) + data + end + end + + activate :minify_css, :inline => true + + set :css_compressor, ::PassThrough + + page "/inline-css.html", :layout => false + """ + And the Server is running at "passthrough-app" When I go to "/inline-css.html" Then I should see: """ diff --git a/middleman-more/features/minify_javascript.feature b/middleman-more/features/minify_javascript.feature index 41ef8b19..e4366b2f 100644 --- a/middleman-more/features/minify_javascript.feature +++ b/middleman-more/features/minify_javascript.feature @@ -1,11 +1,11 @@ Feature: Minify Javascript In order reduce bytes sent to client and appease YSlow - Background: - Given current environment is "build" - Scenario: Rendering inline js with the feature disabled - Given "minify_javascript" feature is "disabled" + Given a fixture app "minify-js-app" + And a file named "config.rb" with: + """ + """ And the Server is running at "minify-js-app" When I go to "/inline-js.html" Then I should see: @@ -42,7 +42,22 @@ Feature: Minify Javascript """ Scenario: Rendering inline js with a passthrough minifier - Given the Server is running at "passthrough-app" + Given a fixture app "passthrough-app" + And a file named "config.rb" with: + """ + module ::PassThrough + def self.compress(data) + data + end + end + + activate :minify_javascript, :inline => true + + set :js_compressor, ::PassThrough + + page "/inline-js.html", :layout => false + """ + And the Server is running at "passthrough-app" When I go to "/inline-js.html" Then I should see: """ @@ -78,7 +93,11 @@ Feature: Minify Javascript """ Scenario: Rendering inline js with the feature enabled - Given "minify_javascript" feature is "enabled" with ":inline => true" + Given a fixture app "minify-js-app" + And a file named "config.rb" with: + """ + activate :minify_javascript, :inline => true + """ And the Server is running at "minify-js-app" When I go to "/inline-js.html" Then I should see: @@ -102,7 +121,11 @@ Feature: Minify Javascript """ Scenario: Rendering external js with the feature enabled - Given "minify_javascript" feature is "enabled" + Given a fixture app "minify-js-app" + And a file named "config.rb" with: + """ + activate :minify_javascript + """ And the Server is running at "minify-js-app" When I go to "/javascripts/js_test.js" Then I should see "1" lines @@ -115,23 +138,62 @@ Feature: Minify Javascript Then I should see "8" lines Scenario: Rendering inline js (coffeescript) with the feature enabled - Given "minify_javascript" feature is "enabled" with ":inline => true" + 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 Scenario: Rendering external js (coffeescript) with the feature enabled - Given "minify_javascript" feature is "enabled" + Given a fixture app "minify-js-app" + And a file named "config.rb" with: + """ + activate :minify_javascript + """ And the Server is running at "minify-js-app" When I go to "/javascripts/coffee_test.js" Then I should see "1" lines Scenario: Rendering inline js (coffeescript) with a passthrough minifier - Given the Server is running at "passthrough-app" + Given a fixture app "passthrough-app" + And a file named "config.rb" with: + """ + require "coffee-filter" + + module ::PassThrough + def self.compress(data) + data + end + end + + activate :minify_javascript, :inline => true + + set :js_compressor, ::PassThrough + + page "/inline-coffeescript.html", :layout => false + """ + And the Server is running at "passthrough-app" When I go to "/inline-coffeescript.html" Then I should see "16" lines Scenario: Rendering external js (coffeescript) with a passthrough minifier + Given a fixture app "passthrough-app" + And a file named "config.rb" with: + """ + module ::PassThrough + def self.compress(data) + data + end + end + + activate :minify_javascript + + set :js_compressor, ::PassThrough + """ And the Server is running at "passthrough-app" When I go to "/javascripts/coffee_test.js" Then I should see "11" lines diff --git a/middleman-more/fixtures/minify-css-app/config.rb b/middleman-more/fixtures/minify-css-app/config.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman-more/fixtures/passthrough-app/config.rb b/middleman-more/fixtures/passthrough-app/config.rb deleted file mode 100644 index 1f6349db..00000000 --- a/middleman-more/fixtures/passthrough-app/config.rb +++ /dev/null @@ -1,17 +0,0 @@ -module ::PassThrough - def self.compress(data) - data - end -end - -activate :minify_javascript -activate :minify_css - -set :js_compressor, ::PassThrough -set :css_compressor, ::PassThrough - -with_layout false do - page "/inline-css.html" - page "/inline-js.html" - page "/inline-coffeescript.html" -end