cleanup generator feature steps

This commit is contained in:
Thomas Reynolds 2011-11-29 22:12:33 -08:00
parent e02173425b
commit baa3c32b45
5 changed files with 18 additions and 19 deletions

3
.gitignore vendored
View file

@ -7,9 +7,8 @@ pkg
.tmp .tmp
Gemfile.lock Gemfile.lock
docs docs
.rvmrc
.rbenv-version .rbenv-version
fixtures/test-app/build fixtures/generator-test
.*.swp .*.swp
build build
doc doc

View file

@ -2,7 +2,7 @@ Feature: Generator
In order to generate static assets for client In order to generate static assets for client
Scenario: Copying template files Scenario: Copying template files
Given generated directory at "generator-test" Given a project at "generator-test"
Then template files should exist at "generator-test" And the project has been initialized
And empty directories should exist at "generator-test" Then template files should exist
And cleanup at "generator-test" And empty directories should exist

View file

@ -1,6 +1,7 @@
MIDDLEMAN_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__))) MIDDLEMAN_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
MIDDLEMAN_BIN_PATH = File.join(MIDDLEMAN_ROOT_PATH, "bin") MIDDLEMAN_BIN_PATH = File.join(MIDDLEMAN_ROOT_PATH, "bin")
require "middleman/step_definitions/middleman_steps"
require "middleman/step_definitions/builder_steps" require "middleman/step_definitions/builder_steps"
require "middleman/step_definitions/generator_steps" require "middleman/step_definitions/generator_steps"
require "middleman/step_definitions/server_steps" require "middleman/step_definitions/server_steps"

View file

@ -1,30 +1,26 @@
require 'fileutils' require 'fileutils'
Given /^generated directory at "([^\"]*)"$/ do |dirname| Given /^the project has been initialized$/ do
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname) step %Q{the project should be cleaned up}
init_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman init") init_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman init")
`cd #{File.dirname(target)} && #{init_cmd} #{File.basename(target)}` `cd #{File.dirname(@target)} && #{init_cmd} #{File.basename(@target)}`
end end
Then /^template files should exist at "([^\"]*)"$/ do |dirname| Then /^template files should exist$/ do
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
template_glob = File.join(MIDDLEMAN_ROOT_PATH, "lib", "middleman", "templates", "default", "*/**/*") template_glob = File.join(MIDDLEMAN_ROOT_PATH, "lib", "middleman", "templates", "default", "*/**/*")
Dir[template_glob].each do |f| Dir[template_glob].each do |f|
next if File.directory?(f) next if File.directory?(f)
File.exists?("#{target}/#{f.split('template/')[1]}").should be_true File.exists?("#{@target}/#{f.split('template/')[1]}").should be_true
end end
end end
Then /^empty directories should exist at "([^\"]*)"$/ do |dirname| Then /^empty directories should exist$/ do
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
%w(source/stylesheets source/javascripts source/images).each do |d| %w(source/stylesheets source/javascripts source/images).each do |d|
File.exists?("#{target}/#{d}").should be_true File.exists?("#{@target}/#{d}").should be_true
end end
end end
Then /^cleanup at "([^\"]*)"$/ do |dirname| Then /^the project should be cleaned up$/ do
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname) FileUtils.rm_rf(@target)
FileUtils.rm_rf(target)
end end

View file

@ -0,0 +1,3 @@
Given /^a project at "([^\"]*)"$/ do |dirname|
@target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
end