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
Gemfile.lock
docs
.rvmrc
.rbenv-version
fixtures/test-app/build
fixtures/generator-test
.*.swp
build
doc

View file

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

View file

@ -1,6 +1,7 @@
MIDDLEMAN_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
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/generator_steps"
require "middleman/step_definitions/server_steps"

View file

@ -1,30 +1,26 @@
require 'fileutils'
Given /^generated directory at "([^\"]*)"$/ do |dirname|
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
Given /^the project has been initialized$/ do
step %Q{the project should be cleaned up}
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
Then /^template files should exist at "([^\"]*)"$/ do |dirname|
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
Then /^template files should exist$/ do
template_glob = File.join(MIDDLEMAN_ROOT_PATH, "lib", "middleman", "templates", "default", "*/**/*")
Dir[template_glob].each do |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
Then /^empty directories should exist at "([^\"]*)"$/ do |dirname|
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
Then /^empty directories should exist$/ do
%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
Then /^cleanup at "([^\"]*)"$/ do |dirname|
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
FileUtils.rm_rf(target)
Then /^the project should be cleaned up$/ do
FileUtils.rm_rf(@target)
end

View file

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