From 4ba90bf1c74c87611a169584b396abc9c9420614 Mon Sep 17 00:00:00 2001 From: tdreyno Date: Mon, 6 Sep 2010 10:59:51 -0700 Subject: [PATCH] remove rspec, convert everything to cucumber --- Rakefile | 23 ++---- features/builder.feature | 16 +++++ features/coffee-script.feature | 7 ++ .../helpers_auto_stylesheet_link_tag.feature | 17 +++++ features/helpers_page_classes.feature | 17 +++++ features/helpers_simple_macros.feature | 31 ++++++++ features/less-css.feature | 7 ++ features/scss-support.feature | 7 ++ features/step_definitions/builder_steps.rb | 45 ++++++++++++ features/step_definitions/env.rb | 2 +- features/step_definitions/generator_steps.rb | 12 +++- features/step_definitions/middleman_steps.rb | 9 +-- .../step_definitions/page_layout_steps.rb | 4 +- ...sset_host.feature => w_asset_host.feature} | 0 ...eature => x_automatic_image_sizes.feature} | 0 ..._buster.feature => y_cache_buster.feature} | 0 ...sets.feature => z_relative_assets.feature} | 0 .../sample => fixtures/test-app}/config.rb | 0 .../test-app}/public/images/blank.gif | Bin .../test-app}/public/static.html | 0 .../test-app}/public/stylesheets/auto-css.css | 0 .../test-app}/public/stylesheets/static.css | 0 .../public/stylesheets/sub1/auto-css.css | 0 .../public/stylesheets/sub1/sub2/auto-css.css | 0 .../test-app}/views/_partial.haml | 0 .../test-app}/views/asset_host.html.haml | 0 .../test-app}/views/auto-css.html.haml | 0 .../views/auto-image-sizes.html.haml | 0 .../test-app}/views/cache-buster.html.haml | 0 .../test-app}/views/custom-layout.html.haml | 0 .../test-app}/views/custom.haml | 0 fixtures/test-app/views/image_tag.html.haml | 2 + .../test-app}/views/index.html.haml | 0 .../test-app}/views/inline-css.html.haml | 0 .../test-app}/views/inline-js.html.haml | 0 .../views/javascript_include_tag.html.haml | 4 ++ .../views/javascripts/coffee_test.js.coffee | 0 .../test-app}/views/layout.haml | 0 fixtures/test-app/views/link_to.html.haml | 3 + .../test-app}/views/maruku.html.maruku | 0 .../test-app}/views/page-classes.html.haml | 0 .../test-app}/views/services/index.html.haml | 0 .../views/stylesheet_link_tag.html.haml | 4 ++ .../views/stylesheets/asset_host.css.sass | 0 .../stylesheets/relative_assets.css.sass | 0 .../test-app}/views/stylesheets/site.css.sass | 0 .../views/stylesheets/site_scss.css.scss | 0 .../views/stylesheets/test_less.css.less | 0 lib/middleman/features/default_helpers.rb | 24 +++++-- spec/builder_spec.rb | 67 ------------------ spec/helpers_spec.rb | 43 ----------- spec/spec_helper.rb | 8 --- 52 files changed, 201 insertions(+), 151 deletions(-) create mode 100644 features/builder.feature create mode 100644 features/coffee-script.feature create mode 100644 features/helpers_auto_stylesheet_link_tag.feature create mode 100644 features/helpers_page_classes.feature create mode 100644 features/helpers_simple_macros.feature create mode 100644 features/less-css.feature create mode 100644 features/scss-support.feature create mode 100644 features/step_definitions/builder_steps.rb rename features/{asset_host.feature => w_asset_host.feature} (100%) rename features/{automatic_image_sizes.feature => x_automatic_image_sizes.feature} (100%) rename features/{cache_buster.feature => y_cache_buster.feature} (100%) rename features/{relative_assets.feature => z_relative_assets.feature} (100%) rename {spec/fixtures/sample => fixtures/test-app}/config.rb (100%) rename {spec/fixtures/sample => fixtures/test-app}/public/images/blank.gif (100%) rename {spec/fixtures/sample => fixtures/test-app}/public/static.html (100%) rename {spec/fixtures/sample => fixtures/test-app}/public/stylesheets/auto-css.css (100%) rename {spec/fixtures/sample => fixtures/test-app}/public/stylesheets/static.css (100%) rename {spec/fixtures/sample => fixtures/test-app}/public/stylesheets/sub1/auto-css.css (100%) rename {spec/fixtures/sample => fixtures/test-app}/public/stylesheets/sub1/sub2/auto-css.css (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/_partial.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/asset_host.html.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/auto-css.html.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/auto-image-sizes.html.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/cache-buster.html.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/custom-layout.html.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/custom.haml (100%) create mode 100644 fixtures/test-app/views/image_tag.html.haml rename {spec/fixtures/sample => fixtures/test-app}/views/index.html.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/inline-css.html.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/inline-js.html.haml (100%) create mode 100644 fixtures/test-app/views/javascript_include_tag.html.haml rename {spec/fixtures/sample => fixtures/test-app}/views/javascripts/coffee_test.js.coffee (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/layout.haml (100%) create mode 100755 fixtures/test-app/views/link_to.html.haml rename {spec/fixtures/sample => fixtures/test-app}/views/maruku.html.maruku (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/page-classes.html.haml (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/services/index.html.haml (100%) create mode 100644 fixtures/test-app/views/stylesheet_link_tag.html.haml rename {spec/fixtures/sample => fixtures/test-app}/views/stylesheets/asset_host.css.sass (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/stylesheets/relative_assets.css.sass (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/stylesheets/site.css.sass (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/stylesheets/site_scss.css.scss (100%) rename {spec/fixtures/sample => fixtures/test-app}/views/stylesheets/test_less.css.less (100%) delete mode 100644 spec/builder_spec.rb delete mode 100644 spec/helpers_spec.rb delete mode 100644 spec/spec_helper.rb diff --git a/Rakefile b/Rakefile index 22787a0f..12c28f2a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,18 +1,17 @@ require 'lib/middleman' require 'rake' -require 'spec/rake/spectask' require 'cucumber/rake/task' begin require 'jeweler' Jeweler::Tasks.new do |gem| - gem.name = "middleman" - gem.summary = %Q{A static site generator utilizing Haml, Sass and providing YUI compression and cache busting} - gem.email = "tdreyno@gmail.com" - gem.homepage = "http://wiki.github.com/tdreyno/middleman" - gem.authors = ["Thomas Reynolds"] + gem.name = "middleman" + gem.summary = %Q{A static site generator utilizing Haml, Sass and providing YUI compression and cache busting} + gem.email = "tdreyno@gmail.com" + gem.homepage = "http://wiki.github.com/tdreyno/middleman" + gem.authors = ["Thomas Reynolds"] gem.rubyforge_project = "middleman" - gem.executables = %w(mm-init mm-build mm-server) + gem.executables = %w(mm-init mm-build mm-server) gem.add_dependency("rack", "~>1.0") gem.add_dependency("thin", "~>1.2.0") gem.add_dependency("shotgun", "~>0.8.0") @@ -28,7 +27,6 @@ begin gem.add_dependency("compass-slickmap", "~>0.4.0") # gem.add_dependency("livereload", "~>1.4.0") - gem.add_development_dependency("rspec") gem.add_development_dependency("cucumber") gem.add_development_dependency("jeweler") end @@ -38,15 +36,8 @@ rescue LoadError puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" end -Spec::Rake::SpecTask.new(:spec) do |spec| - spec.libs << 'lib' << 'spec' - spec.spec_files = FileList['spec/**/*_spec.rb'] -end - Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t| t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" end -task :spec => :check_dependencies - -task :default => [:cucumber, :spec] +task :default => :cucumber diff --git a/features/builder.feature b/features/builder.feature new file mode 100644 index 00000000..f30a03e2 --- /dev/null +++ b/features/builder.feature @@ -0,0 +1,16 @@ +Feature: Builder + In order to output static html and css for delivery + + Scenario: Checking built folder for content + Given a built test app + Then "index.html" should exist and include "Comment in layout" + Then "javascripts/coffee_test.js" should exist and include "Array.prototype.slice" + Then "index.html" should exist and include "

Welcome

" + Then "static.html" should exist and include "Static, no code!" + Then "services/index.html" should exist and include "Services" + Then "stylesheets/site.css" should exist and include "html, body, div, span" + Then "stylesheets/site_scss.css" should exist and include "html, body, div, span" + Then "stylesheets/test_less.css" should exist and include "666" + Then "stylesheets/static.css" should exist and include "body" + Then "_partial.html" should not exist + And cleanup built test app \ No newline at end of file diff --git a/features/coffee-script.feature b/features/coffee-script.feature new file mode 100644 index 00000000..ec9ee85f --- /dev/null +++ b/features/coffee-script.feature @@ -0,0 +1,7 @@ +Feature: Support coffee-script + In order to offer an alternative when writing Javascript + + Scenario: Rendering coffee script + Given the Server is running + When I go to "/javascripts/coffee_test.js" + Then I should see "Array.prototype.slice" \ No newline at end of file diff --git a/features/helpers_auto_stylesheet_link_tag.feature b/features/helpers_auto_stylesheet_link_tag.feature new file mode 100644 index 00000000..8139662b --- /dev/null +++ b/features/helpers_auto_stylesheet_link_tag.feature @@ -0,0 +1,17 @@ +Feature: Built-in auto_stylesheet_link_tag view helper + In order to simplify including css files + + Scenario: Viewing the root path + Given the Server is running + When I go to "/auto-css.html" + Then I should see "stylesheets/auto-css.css" + + Scenario: Viewing a tier-1 path + Given the Server is running + When I go to "/sub1/auto-css.html" + Then I should see "stylesheets/sub1/auto-css.css" + + Scenario: Viewing a tier-2 path + Given the Server is running + When I go to "/sub1/sub2/auto-css.html" + Then I should see "stylesheets/sub1/sub2/auto-css.css" \ No newline at end of file diff --git a/features/helpers_page_classes.feature b/features/helpers_page_classes.feature new file mode 100644 index 00000000..888fa564 --- /dev/null +++ b/features/helpers_page_classes.feature @@ -0,0 +1,17 @@ +Feature: Built-in page_classes view helper + In order to generate body classes for views + + Scenario: Viewing the root path + Given the Server is running + When I go to "/page-class.html" + Then I should see "page-class" + + Scenario: Viewing a tier-1 path + Given the Server is running + When I go to "/sub1/page-class.html" + Then I should see "sub1 sub1_page-class" + + Scenario: Viewing a tier-2 path + Given the Server is running + When I go to "/sub1/sub2/page-class.html" + Then I should see "sub1 sub1_sub2 sub1_sub2_page-class" \ No newline at end of file diff --git a/features/helpers_simple_macros.feature b/features/helpers_simple_macros.feature new file mode 100644 index 00000000..2b5b3f39 --- /dev/null +++ b/features/helpers_simple_macros.feature @@ -0,0 +1,31 @@ +Feature: Built-in macro view helpers + In order to simplify generating HTML + + Scenario: Using the link_to helper + Given the Server is running + When I go to "/link_to.html" + Then I should see 'No Href' + And I should see 'Has Href' + And I should see 'Has param' + + Scenario: Using the image_tag helper + Given the Server is running + When I go to "/image_tag.html" + Then I should see '' + And I should see 'alt' + + Scenario: Using the javascript_include_tag helper + Given the Server is running + When I go to "/javascript_include_tag.html" + Then I should see '' + Then I should see '' + Then I should see '' + Then I should see '' + + Scenario: Using the stylesheet_link_tag helper + Given the Server is running + When I go to "/stylesheet_link_tag.html" + Then I should see '' + Then I should see '' + Then I should see '' + Then I should see '' \ No newline at end of file diff --git a/features/less-css.feature b/features/less-css.feature new file mode 100644 index 00000000..495b2825 --- /dev/null +++ b/features/less-css.feature @@ -0,0 +1,7 @@ +Feature: Support Less CSS + In order to offer an alternative when writing CSS + + Scenario: Rendering Less + Given the Server is running + When I go to "/stylesheets/test_less.css" + Then I should see "666" \ No newline at end of file diff --git a/features/scss-support.feature b/features/scss-support.feature new file mode 100644 index 00000000..d0a2ca59 --- /dev/null +++ b/features/scss-support.feature @@ -0,0 +1,7 @@ +Feature: Support SCSS Syntax + In order to offer an alternative when writing Sass + + Scenario: Rendering scss + Given the Server is running + When I go to "/stylesheets/site_scss.css" + Then I should see "html,body,div,span,applet,object,iframe" \ No newline at end of file diff --git a/features/step_definitions/builder_steps.rb b/features/step_definitions/builder_steps.rb new file mode 100644 index 00000000..3c6097dc --- /dev/null +++ b/features/step_definitions/builder_steps.rb @@ -0,0 +1,45 @@ +require 'fileutils' + +Given /^a built test app$/ do + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app") + build_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "mm-build")) + `cd #{target} && MM_DIR="#{target}" #{build_cmd}` +end + +Given /^cleanup built test app$/ do + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build") + FileUtils.rm_rf(target) +end + +Then /^"([^"]*)" should exist and include "([^"]*)"$/ do |target_file, expected| + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file) + File.exists?(target).should be_true + File.read(target).should include(expected) +end + +Then /^"([^"]*)" should not exist$/ do |target_file| + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file) + File.exists?(target).should be_false +end + + + +# require 'fileutils' +# +# describe "Builder" do +# def project_file(*parts) +# File.expand_path(File.join(File.dirname(__FILE__), "..", *parts)) +# end +# +# before :all do +# @root_dir = project_file("spec", "fixtures", "sample") +# end +# +# before :each do +# build_cmd = project_file("bin", "mm-build") +# `cd #{@root_dir} && MM_DIR="#{@root_dir}" #{build_cmd}` +# end +# +# after :each do +# FileUtils.rm_rf(File.join(@root_dir, "build")) +# end \ No newline at end of file diff --git a/features/step_definitions/env.rb b/features/step_definitions/env.rb index 603e4619..e4c5bca9 100644 --- a/features/step_definitions/env.rb +++ b/features/step_definitions/env.rb @@ -1,3 +1,3 @@ -ENV["MM_DIR"] = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", "sample") +ENV["MM_DIR"] = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app") require File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib', 'middleman') require "rack/test" \ No newline at end of file diff --git a/features/step_definitions/generator_steps.rb b/features/step_definitions/generator_steps.rb index e9a9c163..5e000e39 100644 --- a/features/step_definitions/generator_steps.rb +++ b/features/step_definitions/generator_steps.rb @@ -1,7 +1,13 @@ require 'fileutils' +Given /^generated directory at "([^\"]*)"$/ do |dirname| + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname) + init_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "mm-init")) + `cd #{File.dirname(target)} && #{init_cmd} #{File.basename(target)}` +end + Then /^template files should exist at "([^\"]*)"$/ do |dirname| - target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname) + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname) template_glob = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "lib", "middleman", "template", "*/**/*") Dir[template_glob].each do |f| @@ -11,7 +17,7 @@ Then /^template files should exist at "([^\"]*)"$/ do |dirname| end Then /^empty directories should exist at "([^\"]*)"$/ do |dirname| - target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname) + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname) %w(views/stylesheets public/stylesheets public/javascripts public/images).each do |d| File.exists?("#{target}/#{d}").should be_true @@ -19,6 +25,6 @@ Then /^empty directories should exist at "([^\"]*)"$/ do |dirname| end Then /^cleanup at "([^\"]*)"$/ do |dirname| - target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname) + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname) FileUtils.rm_rf(target) end \ No newline at end of file diff --git a/features/step_definitions/middleman_steps.rb b/features/step_definitions/middleman_steps.rb index d8104091..3acb905d 100644 --- a/features/step_definitions/middleman_steps.rb +++ b/features/step_definitions/middleman_steps.rb @@ -4,10 +4,8 @@ Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state| @browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server.new)) end -Given /^generated directory at "([^\"]*)"$/ do |dirname| - target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname) - init_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "mm-init")) - `cd #{File.dirname(target)} && #{init_cmd} #{File.basename(target)}` +Given /^the Server is running$/ do + @browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server.new)) end When /^I go to "([^\"]*)"$/ do |url| @@ -17,6 +15,9 @@ end Then /^I should see "([^\"]*)"$/ do |expected| @browser.last_response.body.should include(expected) end +Then /^I should see '([^\']*)'$/ do |expected| + @browser.last_response.body.should include(expected) +end Then /^I should not see "([^\"]*)"$/ do |expected| @browser.last_response.body.should_not include(expected) diff --git a/features/step_definitions/page_layout_steps.rb b/features/step_definitions/page_layout_steps.rb index 05f23c48..920a00b8 100644 --- a/features/step_definitions/page_layout_steps.rb +++ b/features/step_definitions/page_layout_steps.rb @@ -1,11 +1,11 @@ Given /^page "([^\"]*)" has layout "([^\"]*)"$/ do |url, layout| - Middleman::Server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", "sample") + Middleman::Server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app") Middleman::Server.page(url, :layout => layout.to_sym) @browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server.new)) end Given /^"([^\"]*)" with_layout block has layout "([^\"]*)"$/ do |url, layout| - Middleman::Server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", "sample") + Middleman::Server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app") Middleman::Server.with_layout(:layout => layout.to_sym) do page(url) end diff --git a/features/asset_host.feature b/features/w_asset_host.feature similarity index 100% rename from features/asset_host.feature rename to features/w_asset_host.feature diff --git a/features/automatic_image_sizes.feature b/features/x_automatic_image_sizes.feature similarity index 100% rename from features/automatic_image_sizes.feature rename to features/x_automatic_image_sizes.feature diff --git a/features/cache_buster.feature b/features/y_cache_buster.feature similarity index 100% rename from features/cache_buster.feature rename to features/y_cache_buster.feature diff --git a/features/relative_assets.feature b/features/z_relative_assets.feature similarity index 100% rename from features/relative_assets.feature rename to features/z_relative_assets.feature diff --git a/spec/fixtures/sample/config.rb b/fixtures/test-app/config.rb similarity index 100% rename from spec/fixtures/sample/config.rb rename to fixtures/test-app/config.rb diff --git a/spec/fixtures/sample/public/images/blank.gif b/fixtures/test-app/public/images/blank.gif similarity index 100% rename from spec/fixtures/sample/public/images/blank.gif rename to fixtures/test-app/public/images/blank.gif diff --git a/spec/fixtures/sample/public/static.html b/fixtures/test-app/public/static.html similarity index 100% rename from spec/fixtures/sample/public/static.html rename to fixtures/test-app/public/static.html diff --git a/spec/fixtures/sample/public/stylesheets/auto-css.css b/fixtures/test-app/public/stylesheets/auto-css.css similarity index 100% rename from spec/fixtures/sample/public/stylesheets/auto-css.css rename to fixtures/test-app/public/stylesheets/auto-css.css diff --git a/spec/fixtures/sample/public/stylesheets/static.css b/fixtures/test-app/public/stylesheets/static.css similarity index 100% rename from spec/fixtures/sample/public/stylesheets/static.css rename to fixtures/test-app/public/stylesheets/static.css diff --git a/spec/fixtures/sample/public/stylesheets/sub1/auto-css.css b/fixtures/test-app/public/stylesheets/sub1/auto-css.css similarity index 100% rename from spec/fixtures/sample/public/stylesheets/sub1/auto-css.css rename to fixtures/test-app/public/stylesheets/sub1/auto-css.css diff --git a/spec/fixtures/sample/public/stylesheets/sub1/sub2/auto-css.css b/fixtures/test-app/public/stylesheets/sub1/sub2/auto-css.css similarity index 100% rename from spec/fixtures/sample/public/stylesheets/sub1/sub2/auto-css.css rename to fixtures/test-app/public/stylesheets/sub1/sub2/auto-css.css diff --git a/spec/fixtures/sample/views/_partial.haml b/fixtures/test-app/views/_partial.haml similarity index 100% rename from spec/fixtures/sample/views/_partial.haml rename to fixtures/test-app/views/_partial.haml diff --git a/spec/fixtures/sample/views/asset_host.html.haml b/fixtures/test-app/views/asset_host.html.haml similarity index 100% rename from spec/fixtures/sample/views/asset_host.html.haml rename to fixtures/test-app/views/asset_host.html.haml diff --git a/spec/fixtures/sample/views/auto-css.html.haml b/fixtures/test-app/views/auto-css.html.haml similarity index 100% rename from spec/fixtures/sample/views/auto-css.html.haml rename to fixtures/test-app/views/auto-css.html.haml diff --git a/spec/fixtures/sample/views/auto-image-sizes.html.haml b/fixtures/test-app/views/auto-image-sizes.html.haml similarity index 100% rename from spec/fixtures/sample/views/auto-image-sizes.html.haml rename to fixtures/test-app/views/auto-image-sizes.html.haml diff --git a/spec/fixtures/sample/views/cache-buster.html.haml b/fixtures/test-app/views/cache-buster.html.haml similarity index 100% rename from spec/fixtures/sample/views/cache-buster.html.haml rename to fixtures/test-app/views/cache-buster.html.haml diff --git a/spec/fixtures/sample/views/custom-layout.html.haml b/fixtures/test-app/views/custom-layout.html.haml similarity index 100% rename from spec/fixtures/sample/views/custom-layout.html.haml rename to fixtures/test-app/views/custom-layout.html.haml diff --git a/spec/fixtures/sample/views/custom.haml b/fixtures/test-app/views/custom.haml similarity index 100% rename from spec/fixtures/sample/views/custom.haml rename to fixtures/test-app/views/custom.haml diff --git a/fixtures/test-app/views/image_tag.html.haml b/fixtures/test-app/views/image_tag.html.haml new file mode 100644 index 00000000..6c74d1d4 --- /dev/null +++ b/fixtures/test-app/views/image_tag.html.haml @@ -0,0 +1,2 @@ += image_tag "test.png" += image_tag "test2.png", :alt => "alt" \ No newline at end of file diff --git a/spec/fixtures/sample/views/index.html.haml b/fixtures/test-app/views/index.html.haml similarity index 100% rename from spec/fixtures/sample/views/index.html.haml rename to fixtures/test-app/views/index.html.haml diff --git a/spec/fixtures/sample/views/inline-css.html.haml b/fixtures/test-app/views/inline-css.html.haml similarity index 100% rename from spec/fixtures/sample/views/inline-css.html.haml rename to fixtures/test-app/views/inline-css.html.haml diff --git a/spec/fixtures/sample/views/inline-js.html.haml b/fixtures/test-app/views/inline-js.html.haml similarity index 100% rename from spec/fixtures/sample/views/inline-js.html.haml rename to fixtures/test-app/views/inline-js.html.haml diff --git a/fixtures/test-app/views/javascript_include_tag.html.haml b/fixtures/test-app/views/javascript_include_tag.html.haml new file mode 100644 index 00000000..2be9fff0 --- /dev/null +++ b/fixtures/test-app/views/javascript_include_tag.html.haml @@ -0,0 +1,4 @@ += javascript_include_tag "test1" += javascript_include_tag :test2 += javascript_include_tag "test3.js" += javascript_include_tag "http://test.com/javascripts/test4.js" \ No newline at end of file diff --git a/spec/fixtures/sample/views/javascripts/coffee_test.js.coffee b/fixtures/test-app/views/javascripts/coffee_test.js.coffee similarity index 100% rename from spec/fixtures/sample/views/javascripts/coffee_test.js.coffee rename to fixtures/test-app/views/javascripts/coffee_test.js.coffee diff --git a/spec/fixtures/sample/views/layout.haml b/fixtures/test-app/views/layout.haml similarity index 100% rename from spec/fixtures/sample/views/layout.haml rename to fixtures/test-app/views/layout.haml diff --git a/fixtures/test-app/views/link_to.html.haml b/fixtures/test-app/views/link_to.html.haml new file mode 100755 index 00000000..43393c6b --- /dev/null +++ b/fixtures/test-app/views/link_to.html.haml @@ -0,0 +1,3 @@ += link_to "No Href" += link_to "Has Href", "test.com" += link_to "Has param", "test2.com", :class => "test" \ No newline at end of file diff --git a/spec/fixtures/sample/views/maruku.html.maruku b/fixtures/test-app/views/maruku.html.maruku similarity index 100% rename from spec/fixtures/sample/views/maruku.html.maruku rename to fixtures/test-app/views/maruku.html.maruku diff --git a/spec/fixtures/sample/views/page-classes.html.haml b/fixtures/test-app/views/page-classes.html.haml similarity index 100% rename from spec/fixtures/sample/views/page-classes.html.haml rename to fixtures/test-app/views/page-classes.html.haml diff --git a/spec/fixtures/sample/views/services/index.html.haml b/fixtures/test-app/views/services/index.html.haml similarity index 100% rename from spec/fixtures/sample/views/services/index.html.haml rename to fixtures/test-app/views/services/index.html.haml diff --git a/fixtures/test-app/views/stylesheet_link_tag.html.haml b/fixtures/test-app/views/stylesheet_link_tag.html.haml new file mode 100644 index 00000000..9ff4dff0 --- /dev/null +++ b/fixtures/test-app/views/stylesheet_link_tag.html.haml @@ -0,0 +1,4 @@ += stylesheet_link_tag "test1" += stylesheet_link_tag :test2 += stylesheet_link_tag "test3.css" += stylesheet_link_tag "http://test.com/stylesheets/test4.css" \ No newline at end of file diff --git a/spec/fixtures/sample/views/stylesheets/asset_host.css.sass b/fixtures/test-app/views/stylesheets/asset_host.css.sass similarity index 100% rename from spec/fixtures/sample/views/stylesheets/asset_host.css.sass rename to fixtures/test-app/views/stylesheets/asset_host.css.sass diff --git a/spec/fixtures/sample/views/stylesheets/relative_assets.css.sass b/fixtures/test-app/views/stylesheets/relative_assets.css.sass similarity index 100% rename from spec/fixtures/sample/views/stylesheets/relative_assets.css.sass rename to fixtures/test-app/views/stylesheets/relative_assets.css.sass diff --git a/spec/fixtures/sample/views/stylesheets/site.css.sass b/fixtures/test-app/views/stylesheets/site.css.sass similarity index 100% rename from spec/fixtures/sample/views/stylesheets/site.css.sass rename to fixtures/test-app/views/stylesheets/site.css.sass diff --git a/spec/fixtures/sample/views/stylesheets/site_scss.css.scss b/fixtures/test-app/views/stylesheets/site_scss.css.scss similarity index 100% rename from spec/fixtures/sample/views/stylesheets/site_scss.css.scss rename to fixtures/test-app/views/stylesheets/site_scss.css.scss diff --git a/spec/fixtures/sample/views/stylesheets/test_less.css.less b/fixtures/test-app/views/stylesheets/test_less.css.less similarity index 100% rename from spec/fixtures/sample/views/stylesheets/test_less.css.less rename to fixtures/test-app/views/stylesheets/test_less.css.less diff --git a/lib/middleman/features/default_helpers.rb b/lib/middleman/features/default_helpers.rb index 8de71c2a..845d429e 100644 --- a/lib/middleman/features/default_helpers.rb +++ b/lib/middleman/features/default_helpers.rb @@ -45,22 +45,32 @@ class Middleman::Features::DefaultHelpers def image_tag(path, params={}) params[:alt] ||= "" prefix = settings.http_images_path rescue settings.images_dir - params = params.merge(:src => asset_url(path, prefix)) params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') - "" + params << " " if params.length > 0 + "" end def javascript_include_tag(path, params={}) - params = params.merge(:src => asset_url(path, settings.js_dir), :type => "text/javascript") + path = path.to_s + path << ".js" unless path =~ /\.js$/ + + params.delete(:type) + params.delete(:src) params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') - "" + params = " " + params if params.length > 0 + "" end def stylesheet_link_tag(path, params={}) - params[:rel] ||= "stylesheet" - params = params.merge(:href => asset_url(path, settings.css_dir), :type => "text/css") + path = path.to_s + path << ".css" unless path =~ /\.css$/ + + params.delete(:type) + params.delete(:rel) + params.delete(:href) params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') - "" + params << " " if params.length > 0 + "" end end end diff --git a/spec/builder_spec.rb b/spec/builder_spec.rb deleted file mode 100644 index 617494d3..00000000 --- a/spec/builder_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'fileutils' - -describe "Builder" do - def project_file(*parts) - File.expand_path(File.join(File.dirname(__FILE__), "..", *parts)) - end - - before :all do - @root_dir = project_file("spec", "fixtures", "sample") - end - - before :each do - build_cmd = project_file("bin", "mm-build") - `cd #{@root_dir} && MM_DIR="#{@root_dir}" #{build_cmd}` - end - - after :each do - FileUtils.rm_rf(File.join(@root_dir, "build")) - end - - it "should use layout" do - File.exists?("#{@root_dir}/build/index.html").should be_true - File.read("#{@root_dir}/build/index.html").should include("Comment in layout") - end - - it "should build coffee files" do - File.exists?("#{@root_dir}/build/javascripts/coffee_test.js").should be_true - File.read("#{@root_dir}/build/javascripts/coffee_test.js").should include("Array.prototype.slice") - end - - it "should build haml files" do - File.exists?("#{@root_dir}/build/index.html").should be_true - File.read("#{@root_dir}/build/index.html").should include("

Welcome

") - end - - it "should build static files" do - File.exists?("#{@root_dir}/build/static.html").should be_true - File.read("#{@root_dir}/build/static.html").should include("Static, no code!") - end - - it "should build subdirectory files" do - File.exists?("#{@root_dir}/build/services/index.html").should be_true - end - - it "should build sass files" do - File.exists?("#{@root_dir}/build/stylesheets/site.css").should be_true - File.read("#{@root_dir}/build/stylesheets/site.css").gsub(/\s/, "").should include("html,body,div,span,applet,object,iframe") - end - - it "should build less files" do - File.exists?("#{@root_dir}/build/stylesheets/test_less.css").should be_true - File.read("#{@root_dir}/build/stylesheets/test_less.css").should include("666") - end - - it "should build scss files" do - File.exists?("#{@root_dir}/build/stylesheets/site_scss.css").should be_true - File.read("#{@root_dir}/build/stylesheets/site_scss.css").gsub(/\s/, "").should include("html,body,div,span,applet,object,iframe") - end - - it "should build static css files" do - File.exists?("#{@root_dir}/build/stylesheets/static.css").should be_true - end - - it "should not build partial files" do - File.exists?("#{@root_dir}/build/_partial.html").should be_false - end -end \ No newline at end of file diff --git a/spec/helpers_spec.rb b/spec/helpers_spec.rb deleted file mode 100644 index d07d4712..00000000 --- a/spec/helpers_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require File.join(File.dirname(__FILE__), "spec_helper") - -base = ::Middleman::Server - -describe "page_classes helper" do - it "should generate root paths correctly" do - browser = Rack::Test::Session.new(Rack::MockSession.new(base.new)) - browser.get("/page-class.html") - browser.last_response.body.chomp.should == "page-class" - end - - it "should generate 1-deep paths correctly" do - browser = Rack::Test::Session.new(Rack::MockSession.new(base.new)) - browser.get("/sub1/page-class.html") - browser.last_response.body.chomp.should == "sub1 sub1_page-class" - end - - it "should generate 2-deep paths correctly" do - browser = Rack::Test::Session.new(Rack::MockSession.new(base.new)) - browser.get("/sub1/sub2/page-class.html") - browser.last_response.body.chomp.should == "sub1 sub1_sub2 sub1_sub2_page-class" - end -end - -describe "auto_stylesheet_link_tag helper" do - it "should generate root paths correctly" do - browser = Rack::Test::Session.new(Rack::MockSession.new(base.new)) - browser.get("/auto-css.html") - browser.last_response.body.chomp.should include("stylesheets/auto-css.css") - end - - it "should generate 1-deep paths correctly" do - browser = Rack::Test::Session.new(Rack::MockSession.new(base.new)) - browser.get("/sub1/auto-css.html") - browser.last_response.body.chomp.should include("stylesheets/sub1/auto-css.css") - end - - it "should generate 2-deep paths correctly" do - browser = Rack::Test::Session.new(Rack::MockSession.new(base.new)) - browser.get("/sub1/sub2/auto-css.html") - browser.last_response.body.chomp.should include("stylesheets/sub1/sub2/auto-css.css") - end -end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index f918934c..00000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -ENV["MM_DIR"] = File.join(File.dirname(__FILE__), "fixtures", "sample") -require File.join(File.dirname(File.dirname(__FILE__)), 'lib', 'middleman') -require 'spec' -require 'rack/test' - -Spec::Runner.configure do |config| - -end