From 65aebc1887502e99aa21565de6ddd753bd8aa873 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 19 Jan 2016 14:55:47 -0800 Subject: [PATCH] Move some tests around --- middleman-cli/features/.gitkeep | 0 .../features/cli_extension.feature | 0 .../features/cli_init.feature | 5 +---- .../features}/preview_server-hook.feature | 0 .../features}/preview_server.feature | 0 middleman-cli/features/support/env.rb | 19 +++++++++++++++++++ middleman-cli/fixtures/.gitkeep | 0 .../preview-server-app/bin/dns_server.rb | 0 .../fixtures/preview-server-app/config.rb | 0 .../preview-server-app/source/index.html.erb | 0 .../preview-server-app/source/layout.erb | 0 .../source/layouts/custom.erb | 0 .../preview-server-app/source/real.html | 0 .../source/real/index.html.erb | 0 .../source/should_be_ignored.html | 0 .../source/should_be_ignored2.html | 0 .../source/should_be_ignored3.html | 0 .../preview-server-app/source/static.html | 0 .../preview-server-hook-app/config.rb | 0 .../source/index.html.erb | 0 middleman-cli/lib/middleman-cli/init.rb | 10 +++++----- 21 files changed, 25 insertions(+), 9 deletions(-) delete mode 100644 middleman-cli/features/.gitkeep rename {middleman-core => middleman-cli}/features/cli_extension.feature (100%) rename {middleman-core => middleman-cli}/features/cli_init.feature (94%) rename {middleman-core/features/cli => middleman-cli/features}/preview_server-hook.feature (100%) rename {middleman-core/features/cli => middleman-cli/features}/preview_server.feature (100%) create mode 100644 middleman-cli/features/support/env.rb delete mode 100644 middleman-cli/fixtures/.gitkeep rename {middleman-core => middleman-cli}/fixtures/preview-server-app/bin/dns_server.rb (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/config.rb (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/index.html.erb (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/layout.erb (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/layouts/custom.erb (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/real.html (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/real/index.html.erb (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/should_be_ignored.html (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/should_be_ignored2.html (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/should_be_ignored3.html (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-app/source/static.html (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-hook-app/config.rb (100%) rename {middleman-core => middleman-cli}/fixtures/preview-server-hook-app/source/index.html.erb (100%) diff --git a/middleman-cli/features/.gitkeep b/middleman-cli/features/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman-core/features/cli_extension.feature b/middleman-cli/features/cli_extension.feature similarity index 100% rename from middleman-core/features/cli_extension.feature rename to middleman-cli/features/cli_extension.feature diff --git a/middleman-core/features/cli_init.feature b/middleman-cli/features/cli_init.feature similarity index 94% rename from middleman-core/features/cli_init.feature rename to middleman-cli/features/cli_init.feature index 8591d1be..96595422 100644 --- a/middleman-core/features/cli_init.feature +++ b/middleman-cli/features/cli_init.feature @@ -65,10 +65,7 @@ Feature: Middleman CLI Scenario: Create an invalid project using Middleman directory When I run `middleman init MY_PROJECT -T does-not-exist-for-reals` - Then a directory named "MY_PROJECT" should exist - When I cd to "MY_PROJECT" - And the file "Gemfile" should contain "middleman-blog" - And the file ".gitignore" should exist + Then the exit status should be 1 Scenario: Create a new project using github(user/repository) When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default` interactively diff --git a/middleman-core/features/cli/preview_server-hook.feature b/middleman-cli/features/preview_server-hook.feature similarity index 100% rename from middleman-core/features/cli/preview_server-hook.feature rename to middleman-cli/features/preview_server-hook.feature diff --git a/middleman-core/features/cli/preview_server.feature b/middleman-cli/features/preview_server.feature similarity index 100% rename from middleman-core/features/cli/preview_server.feature rename to middleman-cli/features/preview_server.feature diff --git a/middleman-cli/features/support/env.rb b/middleman-cli/features/support/env.rb new file mode 100644 index 00000000..8044deab --- /dev/null +++ b/middleman-cli/features/support/env.rb @@ -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') diff --git a/middleman-cli/fixtures/.gitkeep b/middleman-cli/fixtures/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman-core/fixtures/preview-server-app/bin/dns_server.rb b/middleman-cli/fixtures/preview-server-app/bin/dns_server.rb similarity index 100% rename from middleman-core/fixtures/preview-server-app/bin/dns_server.rb rename to middleman-cli/fixtures/preview-server-app/bin/dns_server.rb diff --git a/middleman-core/fixtures/preview-server-app/config.rb b/middleman-cli/fixtures/preview-server-app/config.rb similarity index 100% rename from middleman-core/fixtures/preview-server-app/config.rb rename to middleman-cli/fixtures/preview-server-app/config.rb diff --git a/middleman-core/fixtures/preview-server-app/source/index.html.erb b/middleman-cli/fixtures/preview-server-app/source/index.html.erb similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/index.html.erb rename to middleman-cli/fixtures/preview-server-app/source/index.html.erb diff --git a/middleman-core/fixtures/preview-server-app/source/layout.erb b/middleman-cli/fixtures/preview-server-app/source/layout.erb similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/layout.erb rename to middleman-cli/fixtures/preview-server-app/source/layout.erb diff --git a/middleman-core/fixtures/preview-server-app/source/layouts/custom.erb b/middleman-cli/fixtures/preview-server-app/source/layouts/custom.erb similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/layouts/custom.erb rename to middleman-cli/fixtures/preview-server-app/source/layouts/custom.erb diff --git a/middleman-core/fixtures/preview-server-app/source/real.html b/middleman-cli/fixtures/preview-server-app/source/real.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/real.html rename to middleman-cli/fixtures/preview-server-app/source/real.html diff --git a/middleman-core/fixtures/preview-server-app/source/real/index.html.erb b/middleman-cli/fixtures/preview-server-app/source/real/index.html.erb similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/real/index.html.erb rename to middleman-cli/fixtures/preview-server-app/source/real/index.html.erb diff --git a/middleman-core/fixtures/preview-server-app/source/should_be_ignored.html b/middleman-cli/fixtures/preview-server-app/source/should_be_ignored.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/should_be_ignored.html rename to middleman-cli/fixtures/preview-server-app/source/should_be_ignored.html diff --git a/middleman-core/fixtures/preview-server-app/source/should_be_ignored2.html b/middleman-cli/fixtures/preview-server-app/source/should_be_ignored2.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/should_be_ignored2.html rename to middleman-cli/fixtures/preview-server-app/source/should_be_ignored2.html diff --git a/middleman-core/fixtures/preview-server-app/source/should_be_ignored3.html b/middleman-cli/fixtures/preview-server-app/source/should_be_ignored3.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/should_be_ignored3.html rename to middleman-cli/fixtures/preview-server-app/source/should_be_ignored3.html diff --git a/middleman-core/fixtures/preview-server-app/source/static.html b/middleman-cli/fixtures/preview-server-app/source/static.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/static.html rename to middleman-cli/fixtures/preview-server-app/source/static.html diff --git a/middleman-core/fixtures/preview-server-hook-app/config.rb b/middleman-cli/fixtures/preview-server-hook-app/config.rb similarity index 100% rename from middleman-core/fixtures/preview-server-hook-app/config.rb rename to middleman-cli/fixtures/preview-server-hook-app/config.rb diff --git a/middleman-core/fixtures/preview-server-hook-app/source/index.html.erb b/middleman-cli/fixtures/preview-server-hook-app/source/index.html.erb similarity index 100% rename from middleman-core/fixtures/preview-server-hook-app/source/index.html.erb rename to middleman-cli/fixtures/preview-server-hook-app/source/index.html.erb diff --git a/middleman-cli/lib/middleman-cli/init.rb b/middleman-cli/lib/middleman-cli/init.rb index 86e2ef91..f1c1927e 100644 --- a/middleman-cli/lib/middleman-cli/init.rb +++ b/middleman-cli/lib/middleman-cli/init.rb @@ -4,7 +4,7 @@ module Middleman::Cli class Init < Thor::Group include Thor::Actions - GIT_CMD = 'git' + GIT_CMD = 'git'.freeze check_unknown_options! @@ -27,8 +27,8 @@ module Middleman::Cli require 'fileutils' require 'tmpdir' - if !git_present? - msg = "You need to install the git command line tool to initialize a new project. " + unless git_present? + 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" say msg, :red exit 1 @@ -63,7 +63,7 @@ module Middleman::Cli git_path = "#{branch_cmd}#{repo_path}" 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 exit 1 end @@ -92,7 +92,7 @@ module Middleman::Cli # Copied from Bundler def 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 # Copied from Bundler