Move some tests around

This commit is contained in:
Thomas Reynolds 2016-01-19 14:55:47 -08:00
parent 801a83f7cb
commit 65aebc1887
21 changed files with 25 additions and 9 deletions

View file

@ -65,10 +65,7 @@ Feature: Middleman CLI
Scenario: Create an invalid project using Middleman directory Scenario: Create an invalid project using Middleman directory
When I run `middleman init MY_PROJECT -T does-not-exist-for-reals` When I run `middleman init MY_PROJECT -T does-not-exist-for-reals`
Then a directory named "MY_PROJECT" should exist Then the exit status should be 1
When I cd to "MY_PROJECT"
And the file "Gemfile" should contain "middleman-blog"
And the file ".gitignore" should exist
Scenario: Create a new project using github(user/repository) Scenario: Create a new project using github(user/repository)
When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default` interactively When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default` interactively

View file

@ -0,0 +1,19 @@
ENV["TEST"] = "true"
require 'sassc'
require 'simplecov'
SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/../..'))
require 'phantomjs/poltergeist'
Capybara.javascript_driver = :poltergeist
require 'coveralls'
Coveralls.wear!
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-cli')
require File.join(File.dirname(PROJECT_ROOT_PATH), 'middleman-core', 'lib', 'middleman-core', 'step_definitions')

View file

@ -4,7 +4,7 @@ module Middleman::Cli
class Init < Thor::Group class Init < Thor::Group
include Thor::Actions include Thor::Actions
GIT_CMD = 'git' GIT_CMD = 'git'.freeze
check_unknown_options! check_unknown_options!
@ -27,8 +27,8 @@ module Middleman::Cli
require 'fileutils' require 'fileutils'
require 'tmpdir' require 'tmpdir'
if !git_present? unless git_present?
msg = "You need to install the git command line tool to initialize a new project. " msg = 'You need to install the git command line tool to initialize a new project. '
msg << "For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git" msg << "For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git"
say msg, :red say msg, :red
exit 1 exit 1
@ -63,7 +63,7 @@ module Middleman::Cli
git_path = "#{branch_cmd}#{repo_path}" git_path = "#{branch_cmd}#{repo_path}"
run("#{GIT_CMD} clone --depth 1 #{branch_cmd}#{repo_path} #{dir}") run("#{GIT_CMD} clone --depth 1 #{branch_cmd}#{repo_path} #{dir}")
if !$?.success? unless $?.success?
say "Git clone command failed. Make sure git repository exists: #{git_path}", :red say "Git clone command failed. Make sure git repository exists: #{git_path}", :red
exit 1 exit 1
end end
@ -92,7 +92,7 @@ module Middleman::Cli
# Copied from Bundler # Copied from Bundler
def git_present? def git_present?
return @git_present if defined?(@git_present) return @git_present if defined?(@git_present)
@git_present = which(GIT_CMD) || which("git.exe") @git_present = which(GIT_CMD) || which('git.exe')
end end
# Copied from Bundler # Copied from Bundler