Thorfile in berkshelf-2.0.0.beta vs Thorfile in berkshelf-2.0.0

- old
+ new

@@ -1,89 +1,70 @@ # encoding: utf-8 -$:.push File.expand_path("../lib", __FILE__) +$:.unshift File.expand_path('../lib', __FILE__) require 'bundler' -require 'bundler/setup' - -require 'berkshelf' require 'thor/rake_compat' -class Default < Thor - class Gem < Thor - include Thor::RakeCompat - Bundler::GemHelper.install_tasks +class Gem < Thor + include Thor::RakeCompat + Bundler::GemHelper.install_tasks - namespace :gem + desc 'build', "Build berkshelf-#{Berkshelf::VERSION}.gem into the pkg directory" + def build + Rake::Task['build'].execute + end - desc "build", "Build berkshelf-#{Berkshelf::VERSION}.gem into the pkg directory" - def build - Rake::Task["build"].execute - end + desc 'install', "Build and install berkshelf-#{Berkshelf::VERSION}.gem into system gems" + def install + Rake::Task['install'].execute + end - desc "release", "Create tag v#{Berkshelf::VERSION} and build and push berkshelf-#{Berkshelf::VERSION}.gem to Rubygems" - def release - Rake::Task["release"].execute - end + desc 'release', "Create tag v#{Berkshelf::VERSION} and build and push berkshelf-#{Berkshelf::VERSION}.gem to Rubygems" + def release + Rake::Task['release'].execute + end +end - desc "install", "Build and install berkshelf-#{Berkshelf::VERSION}.gem into system gems" - def install - Rake::Task["install"].execute - end +class Spec < Thor + include Thor::Actions + default_task :all + + desc 'all', 'Run all specs and features' + def all + exit(units_command && acceptance_command && quality_command) end - class Spec < Thor - include Thor::Actions + desc 'ci', 'Run tests on Travis' + def ci + ENV['CI'] = 'true' # Travis-CI also sets this, but set it here for local testing + all + end - namespace :spec - default_task :all + desc 'unit', 'Run unit tests' + def unit + exit(units_command) + end - desc "all", "Run all tests" - def all - unless run_unit && run_acceptance && run_quality - exit 1 - end - end + desc 'acceptance', 'Run acceptance tests' + def acceptance + exit(acceptance_command) + end - desc "ci", "Run all possible tests on Travis-CI" - def ci - ENV['CI'] = 'true' # Travis-CI also sets this, but set it here for local testing - unless run_unit("--tag ~chef_server") && run_acceptance("--tags ~@chef_server") && run_quality - exit 1 - end - end + desc 'quality', 'Run code quality tests' + def quality + exit(quality_command) + end - desc "unit", "Run unit tests" - def unit - unless run_unit - exit 1 - end + no_tasks do + def units_command + run('rspec --color --format=documentation spec/unit') end - desc "acceptance", "Run acceptance tests" - def acceptance - unless run_acceptance - exit 1 - end + def acceptance_command + run('cucumber --color --format pretty --tags ~@no_run') end - desc "quality", "Run quality tests" - def quality - unless run_quality - exit 1 - end - end - - no_tasks do - def run_unit(*flags) - run "rspec --color --format=documentation #{flags.join(' ')} spec" - end - - def run_acceptance(*flags) - run "cucumber --color --format pretty --tags ~@no_run #{flags.join(' ')}" - end - - def run_quality - run "cane --gte coverage/.last_run.json,90" - end + def quality_command + run('cane --gte coverage/.last_run.json,90') end end end