From 43e6d669b56c29ffa2a33bef75ca29e7764e97a3 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 15 Dec 2011 16:33:09 -0800 Subject: [PATCH] fix clean tests --- features/builder.feature | 10 ++---- features/chained_templates.feature | 6 +--- features/clean_build.feature | 36 ++++++++++++------- features/custom_layout_engines.feature | 7 ++-- .../step_definitions/builder_steps.rb | 34 ++++++++---------- 5 files changed, 46 insertions(+), 47 deletions(-) diff --git a/features/builder.feature b/features/builder.feature index 0b678dd5..8445895c 100644 --- a/features/builder.feature +++ b/features/builder.feature @@ -2,10 +2,7 @@ Feature: Builder In order to output static html and css for delivery Scenario: Checking built folder for content - Given a built app at "test-app" - Then a directory named "build" should exist - And the exit status should be 0 - + Given a successfully built app at "test-app" When I cd to "build" Then the following files should exist: | index.html | @@ -38,10 +35,7 @@ Feature: Builder And the file "spaces in file.html" should contain "spaces" Scenario: Build glob - Given a built app at "glob-app" with flags "--glob '*.css'" - Then a directory named "build" should exist - And the exit status should be 0 - + Given a successfully built app at "glob-app" with flags "--glob '*.css'" When I cd to "build" Then the following files should not exist: | index.html | diff --git a/features/chained_templates.feature b/features/chained_templates.feature index 8642e79c..b7d4e83e 100644 --- a/features/chained_templates.feature +++ b/features/chained_templates.feature @@ -9,11 +9,7 @@ Feature: Templates should be chainable And I should see "Sup" Scenario: Build chained template - Given a built app at "chained-app" - - Then a directory named "build" should exist - And the exit status should be 0 - + Given a successfully built app at "chained-app" When I cd to "build" Then the following files should exist: | index.html | diff --git a/features/clean_build.feature b/features/clean_build.feature index 047d9fc4..e70d5d3e 100644 --- a/features/clean_build.feature +++ b/features/clean_build.feature @@ -1,19 +1,31 @@ Feature: Build Clean Scenario: Build and Clean an app - Given app "clean-app" is using config "empty" - And a built app at "clean-app" + Given a fixture app "clean-app" + And app "clean-app" is using config "empty" + And a successfully built app at "clean-app" And app "clean-app" is using config "complications" - And a built app at "clean-app" with flags "--clean" - Then "should_be_ignored.html" should not exist at "clean-app" - And "should_be_ignored2.html" should not exist at "clean-app" - And "should_be_ignored3.html" should not exist at "clean-app" + + Given a successfully built app at "clean-app" with flags "--clean" + When I cd to "build" + Then the following files should not exist: + | should_be_ignored.html | + | should_be_ignored2.html | + | should_be_ignored3.html | + And the file "index.html" should contain "Comment in layout" Scenario: Clean an app with directory indexes - Given a built app at "clean-dir-app" - Then "about/index.html" should exist at "clean-dir-app" - Given a built app at "clean-dir-app" with flags "--clean" - Then "about/index.html" should exist at "clean-dir-app" + Given a successfully built app at "clean-dir-app" + When I cd to "build" + Then the following files should exist: + | about/index.html | + + Given a successfully built app at "clean-dir-app" with flags "--clean" + When I cd to "build" + Then the following files should exist: + | about/index.html | Scenario: Clean build an app that's never been built - Given a built app at "clean-dir-app" with flags "--clean" - Then "about/index.html" should exist at "clean-dir-app" + Given a successfully built app at "clean-dir-app" with flags "--clean" + When I cd to "build" + Then the following files should exist: + | about/index.html | diff --git a/features/custom_layout_engines.feature b/features/custom_layout_engines.feature index 5963efd1..4d0a5618 100644 --- a/features/custom_layout_engines.feature +++ b/features/custom_layout_engines.feature @@ -1,8 +1,11 @@ Feature: Custom Layout Engine Scenario: Checking built folder for content - Given a built app at "custom-layout-app" - Then "index.html" should exist at "custom-layout-app" and include "Comment in layout" + Given a successfully built app at "custom-layout-app" + When I cd to "build" + Then the following files should exist: + | index.html | + And the file "index.html" should contain "Comment in layout" Scenario: Checking server for content Given the Server is running at "test-app" diff --git a/lib/middleman/step_definitions/builder_steps.rb b/lib/middleman/step_definitions/builder_steps.rb index 46d53e9e..16fad844 100644 --- a/lib/middleman/step_definitions/builder_steps.rb +++ b/lib/middleman/step_definitions/builder_steps.rb @@ -3,7 +3,7 @@ require 'fileutils' Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name| target = File.join(PROJECT_ROOT_PATH, "fixtures", path) config_path = File.join(target, "config-#{config_name}.rb") - config_dest = File.join(target, "config.rb") + config_dest = File.join(current_dir, "config.rb") FileUtils.cp(config_path, config_dest) end @@ -21,28 +21,22 @@ Given /^a built app at "([^\"]*)"$/ do |path| step %Q{I run `middleman build`} end +Given /^was successfully built$/ do + step %Q{a directory named "build" should exist} + step %Q{the exit status should be 0} +end + +Given /^a successfully built app at "([^\"]*)"$/ do |path| + step %Q{a built app at "#{path}"} + step %Q{was successfully built} +end + Given /^a built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path, flags| step %Q{a fixture app "#{path}"} step %Q{I run `middleman build #{flags}`} end -Then /^"([^\"]*)" should exist at "([^\"]*)"$/ do |target_file, path| - target = File.join(PROJECT_ROOT_PATH, "fixtures", path, "build", target_file) - File.exists?(target).should be_true -end - -Then /^"([^\"]*)" should exist at "([^\"]*)" and include "([^\"]*)"$/ do |target_file, path, expected| - target = File.join(PROJECT_ROOT_PATH, "fixtures", path, "build", target_file) - File.exists?(target).should be_true - File.read(target).should include(expected) -end - -Then /^"([^\"]*)" should not exist at "([^\"]*)"$/ do |target_file, path| - target = File.join(PROJECT_ROOT_PATH, "fixtures", path, "build", target_file) - File.exists?(target).should be_false -end - -Then /^the last exit code should be "([^\"]*)"$/ do |exit_code| - exit_code = exit_code.to_i - $?.exitstatus.should == exit_code +Given /^a successfully built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path, flags| + step %Q{a built app at "#{path}" with flags "#{flags}"} + step %Q{was successfully built} end