From ccfa677278337e7db0d5adbc59d8e47a9c585a9f Mon Sep 17 00:00:00 2001 From: Gabe Berke-Williams Date: Fri, 28 Oct 2011 11:01:35 -0400 Subject: [PATCH] NoopPackager should never run. --- features/kumade_executable.feature | 11 +++-------- features/kumade_without_jammit.feature | 8 ++------ features/no_op_packager.feature | 8 ++++---- features/rake_task_before_asset_compilation.feature | 5 ++--- features/step_definitions/git_steps.rb | 4 ++++ lib/kumade/packager.rb | 8 +++++--- spec/kumade/packager_spec.rb | 4 ++-- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/features/kumade_executable.feature b/features/kumade_executable.feature index cfb84b7..8b3c0c9 100644 --- a/features/kumade_executable.feature +++ b/features/kumade_executable.feature @@ -5,13 +5,8 @@ Feature: Kumade executable So I can have a better experience than Rake provides Background: - Given a directory named "executable" - And I cd to "executable" - And I set up the Gemfile with kumade - And I add "jammit" to the Gemfile - And I bundle - When I set up a git repo - And I create a Heroku remote named "pretend-staging" + Given a new Rails application with Kumade and Jammit + When I create a Heroku remote named "pretend-staging" And I create a Heroku remote named "staging" And I create a non-Heroku remote named "bad-remote" @@ -46,7 +41,7 @@ Feature: Kumade executable Then the output should match /==> ! Cannot deploy: "bad-remote" remote does not point to Heroku/ Scenario: Deploy from a branch that isn't "master" - When I run `git checkout -b new_branch` + When I switch to the "new_branch" branch And I run kumade with "pretend-staging -p" Then the output should contain "==> Pushed new_branch -> origin" And the output should contain "==> Deployed to: pretend-staging" diff --git a/features/kumade_without_jammit.feature b/features/kumade_without_jammit.feature index 0b0a714..ef599cb 100644 --- a/features/kumade_without_jammit.feature +++ b/features/kumade_without_jammit.feature @@ -2,12 +2,8 @@ Feature: Kumade without jammit Background: - Given a directory named "executable" - And I cd to "executable" - And I set up the Gemfile with kumade - And I bundle - When I set up a git repo - And I create a Heroku remote named "pretend-staging" + Given a directory set up for kumade + When I create a Heroku remote named "pretend-staging" Scenario: Jammit packager does not run if Jammit is not installed When I run kumade with "pretend-staging" diff --git a/features/no_op_packager.feature b/features/no_op_packager.feature index 306134b..7a4cc7e 100644 --- a/features/no_op_packager.feature +++ b/features/no_op_packager.feature @@ -8,11 +8,11 @@ Feature: No-op packager Given a new Rails application with Kumade When I create a Heroku remote named "staging" - Scenario: No-op packager runs in pretend mode if Jammit is not installed + Scenario: No-op packager does not run in pretend mode if Jammit is not installed When I run kumade with "staging -p" - Then the output should contain "==> Packaged with Kumade::NoopPackager" + Then the output should not contain "==> Packaged with Kumade::NoopPackager" - Scenario: No-op packager runs in normal mode if Jammit is not installed + Scenario: No-op packager does not run in normal mode if Jammit is not installed When I add the origin remote And I run kumade - Then the output should contain "==> Packaged with Kumade::NoopPackager" + Then the output should not contain "==> Packaged with Kumade::NoopPackager" diff --git a/features/rake_task_before_asset_compilation.feature b/features/rake_task_before_asset_compilation.feature index 8954647..28570b3 100644 --- a/features/rake_task_before_asset_compilation.feature +++ b/features/rake_task_before_asset_compilation.feature @@ -12,13 +12,12 @@ Feature: Rake task that runs before asset compilation Then the output should contain "kumade:before_asset_compilation" And the output should contain "Hi!" - Scenario: Custom task runs if Jammit is not installed + Scenario: Custom task runs does not run if Jammit is not installed Given a new Rails application with Kumade When I create a Heroku remote named "pretend-staging" And I add a pre-compilation rake task that prints "Hi!" And I run kumade with "pretend-staging" - Then the output should contain "kumade:before_asset_compilation" - And the output should contain "Hi!" + Then the output should not contain "kumade:before_asset_compilation" Scenario: Pre-asset compilation task does not run when pretending Given a new Rails application with Kumade and Jammit diff --git a/features/step_definitions/git_steps.rb b/features/step_definitions/git_steps.rb index ddc56d5..996b33c 100644 --- a/features/step_definitions/git_steps.rb +++ b/features/step_definitions/git_steps.rb @@ -29,3 +29,7 @@ When /^I add the origin remote$/ do add_origin_remote end + +When /^I switch to the "([^"]+)" branch$/ do |branch_name| + run_simple("git checkout -b #{branch_name}") +end diff --git a/lib/kumade/packager.rb b/lib/kumade/packager.rb index 31f3326..205bb34 100644 --- a/lib/kumade/packager.rb +++ b/lib/kumade/packager.rb @@ -6,8 +6,10 @@ def initialize(git, packager = Packager.available_packager) end def run - precompile_assets - package + if @packager.installed? + precompile_assets + package + end end def self.available_packager @@ -21,7 +23,7 @@ def precompile_assets end def package - return Kumade.configuration.outputter.success(success_message) if Kumade.configuration.pretending? || @packager == NoopPackager + return Kumade.configuration.outputter.success(success_message) if Kumade.configuration.pretending? begin @packager.package diff --git a/spec/kumade/packager_spec.rb b/spec/kumade/packager_spec.rb index 1144455..d7c0b92 100644 --- a/spec/kumade/packager_spec.rb +++ b/spec/kumade/packager_spec.rb @@ -9,7 +9,7 @@ Kumade::Packager.available_packager.should == packager_1 end - it "returns nil if no packagers are availabke" do + it "returns nil if no packagers are available" do Kumade::PackagerList.stubs(:new => []) Kumade::Packager.available_packager.should be_nil end @@ -17,7 +17,7 @@ describe Kumade::Packager, "#run", :with_mock_outputter do let(:git) { stub("git", :dirty? => true, :add_and_commit_all_assets_in => true) } - let(:packager) { stub("packager", :name => "MyPackager", :package => true, :assets_path => 'fake_assets_path') } + let(:packager) { stub("packager", :name => "MyPackager", :package => true, :assets_path => 'fake_assets_path', :installed? => true) } let(:rake_task_runner) { stub("RakeTaskRunner", :invoke => true) } before do