1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

fix interactive init test

This commit is contained in:
Thomas Reynolds 2015-01-04 15:06:14 -06:00
parent 96e05128a1
commit 8e743aea94
3 changed files with 18 additions and 12 deletions

View file

@ -11,6 +11,9 @@ rvm:
- 2.1
- 2.0
- 1.9.3
os:
- linux
- osx
matrix:
fast_finish: true
allow_failures:

View file

@ -22,6 +22,7 @@ module Middleman::Cli
# The init task
def init
require 'fileutils'
require 'tmpdir'
repo_path, repo_branch = if shortname?(options[:template])
@ -45,10 +46,12 @@ module Middleman::Cli
[repository_path(repo_name), repo_branch]
end
Dir.mktmpdir do |dir|
cmd = repo_branch ? "clone -b #{repo_branch}" : 'clone'
dir = Dir.mktmpdir
run("git #{cmd} #{repo_path} #{dir}")
begin
branch_cmd = repo_branch ? "-b #{repo_branch} " : ''
run("git clone --depth 1 #{branch_cmd}#{repo_path} #{dir}")
inside(target) do
thorfile = File.join(dir, 'Thorfile')
@ -64,6 +67,8 @@ module Middleman::Cli
run('bundle install') unless ENV['TEST'] || options[:'skip-bundle']
end
ensure
FileUtils.remove_entry(dir)
end
end

View file

@ -1,7 +1,7 @@
Feature: Middleman CLI
Scenario: Create a new project
Given I run `middleman init MY_PROJECT`
Given I run `middleman init --default MY_PROJECT`
Then the exit status should be 0
When I cd to "MY_PROJECT"
Then the following files should exist:
@ -9,17 +9,15 @@ Feature: Middleman CLI
| .gitignore |
| config.rb |
| source/index.html.erb |
| source/images/background.png |
| source/images/middleman.png |
| source/layouts/layout.erb |
| source/javascripts/all.js |
| source/stylesheets/all.css |
| source/stylesheets/normalize.css |
| source/stylesheets/site.css.scss |
| source/stylesheets/_normalize.scss |
Scenario: Create a new project in the current directory
Given a directory named "MY_PROJECT"
When I cd to "MY_PROJECT"
And I run `middleman init`
And I run `middleman init --default`
Then the exit status should be 0
And the following files should exist:
| Gemfile |
@ -27,13 +25,13 @@ Feature: Middleman CLI
| source/index.html.erb |
Scenario: Create a new project (alias i)
When I run `middleman i MY_PROJECT`
When I run `middleman i --default MY_PROJECT`
Then a directory named "MY_PROJECT" should exist
Scenario: Create a new project (alias new)
When I run `middleman new MY_PROJECT`
When I run `middleman new --default MY_PROJECT`
Then a directory named "MY_PROJECT" should exist
Scenario: Create a new project (alias n)
When I run `middleman n MY_PROJECT`
When I run `middleman n --default MY_PROJECT`
Then a directory named "MY_PROJECT" should exist