mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
reorg cucumber steps so gem extensions can reuse them
This commit is contained in:
parent
f02dd8c90e
commit
e02173425b
6 changed files with 63 additions and 64 deletions
|
@ -1,52 +0,0 @@
|
|||
require 'fileutils'
|
||||
|
||||
Given /^app "([^"]*)" is using config "([^"]*)"$/ do |path, config_name|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "fixtures", path)
|
||||
config_path = File.join(target, "config-#{config_name}.rb")
|
||||
config_dest = File.join(target, "config.rb")
|
||||
FileUtils.cp(config_path, config_dest)
|
||||
end
|
||||
|
||||
Given /^a built app at "([^"]*)"$/ do |path|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "fixtures", path)
|
||||
|
||||
build_target = File.join(target, "build")
|
||||
FileUtils.rm_rf(build_target)
|
||||
|
||||
build_cmd = File.expand_path(File.join(root, "bin", "middleman build"))
|
||||
`cd #{target} && #{build_cmd}`
|
||||
end
|
||||
|
||||
Then /^cleanup built app at "([^"]*)"$/ do |path|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "fixtures", path, "build")
|
||||
FileUtils.rm_rf(target)
|
||||
end
|
||||
|
||||
Given /^a built app at "([^"]*)" with flags "([^"]*)"$/ do |path, flags|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "fixtures", path)
|
||||
build_cmd = File.expand_path(File.join(root, "bin", "middleman build"))
|
||||
`cd #{target} && #{build_cmd} #{flags}`
|
||||
end
|
||||
|
||||
Then /^"([^"]*)" should exist at "([^"]*)"$/ do |target_file, path|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "fixtures", path, "build", target_file)
|
||||
File.exists?(target).should be_true
|
||||
end
|
||||
|
||||
Then /^"([^"]*)" should exist at "([^"]*)" and include "([^"]*)"$/ do |target_file, path, expected|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "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|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "fixtures", path, "build", target_file)
|
||||
File.exists?(target).should be_false
|
||||
end
|
|
@ -1,3 +1,3 @@
|
|||
root_path = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
require File.join(root_path, 'lib', 'middleman')
|
||||
require "rack/test"
|
||||
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman')
|
||||
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman', 'step_definitions')
|
6
lib/middleman/step_definitions.rb
Normal file
6
lib/middleman/step_definitions.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
MIDDLEMAN_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
MIDDLEMAN_BIN_PATH = File.join(MIDDLEMAN_ROOT_PATH, "bin")
|
||||
|
||||
require "middleman/step_definitions/builder_steps"
|
||||
require "middleman/step_definitions/generator_steps"
|
||||
require "middleman/step_definitions/server_steps"
|
45
lib/middleman/step_definitions/builder_steps.rb
Normal file
45
lib/middleman/step_definitions/builder_steps.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
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")
|
||||
FileUtils.cp(config_path, config_dest)
|
||||
end
|
||||
|
||||
Given /^a built app at "([^\"]*)"$/ do |path|
|
||||
target = File.join(PROJECT_ROOT_PATH, "fixtures", path)
|
||||
|
||||
build_target = File.join(target, "build")
|
||||
FileUtils.rm_rf(build_target)
|
||||
|
||||
build_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman build")
|
||||
`cd #{target} && #{build_cmd}`
|
||||
end
|
||||
|
||||
Then /^cleanup built app at "([^\"]*)"$/ do |path|
|
||||
target = File.join(PROJECT_ROOT_PATH, "fixtures", path, "build")
|
||||
FileUtils.rm_rf(target)
|
||||
end
|
||||
|
||||
Given /^a built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path, flags|
|
||||
target = File.join(PROJECT_ROOT_PATH, "fixtures", path)
|
||||
build_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman build")
|
||||
`cd #{target} && #{build_cmd} #{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
|
|
@ -1,14 +1,14 @@
|
|||
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", "middleman init"))
|
||||
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
|
||||
init_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman 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__))), "fixtures", dirname)
|
||||
template_glob = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "lib", "middleman", "templates", "default", "*/**/*")
|
||||
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
|
||||
template_glob = File.join(MIDDLEMAN_ROOT_PATH, "lib", "middleman", "templates", "default", "*/**/*")
|
||||
|
||||
Dir[template_glob].each do |f|
|
||||
next if File.directory?(f)
|
||||
|
@ -17,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__))), "fixtures", dirname)
|
||||
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
|
||||
|
||||
%w(source/stylesheets source/javascripts source/images).each do |d|
|
||||
File.exists?("#{target}/#{d}").should be_true
|
||||
|
@ -25,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__))), "fixtures", dirname)
|
||||
target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
|
||||
FileUtils.rm_rf(target)
|
||||
end
|
|
@ -1,3 +1,5 @@
|
|||
require "rack/test"
|
||||
|
||||
Given /^a clean server$/ do
|
||||
@initialize_commands = []
|
||||
end
|
||||
|
@ -20,11 +22,9 @@ Given /^current environment is "([^\"]*)"$/ do |env|
|
|||
end
|
||||
|
||||
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
||||
root_dir = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
|
||||
initialize_commands = @initialize_commands || []
|
||||
initialize_commands.unshift lambda {
|
||||
set :root, File.join(root_dir, "fixtures", app_path)
|
||||
set :root, File.join(PROJECT_ROOT_PATH, "fixtures", app_path)
|
||||
set :environment, @current_env || :development
|
||||
}
|
||||
|
Loading…
Reference in a new issue