Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
NoopPackager should never run.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Oct 28, 2011
1 parent c45df04 commit ccfa677
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
11 changes: 3 additions & 8 deletions features/kumade_executable.feature
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
8 changes: 2 additions & 6 deletions features/kumade_without_jammit.feature
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions features/no_op_packager.feature
Expand Up @@ -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"
5 changes: 2 additions & 3 deletions features/rake_task_before_asset_compilation.feature
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/git_steps.rb
Expand Up @@ -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
8 changes: 5 additions & 3 deletions lib/kumade/packager.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/kumade/packager_spec.rb
Expand Up @@ -9,15 +9,15 @@
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
end

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
Expand Down

0 comments on commit ccfa677

Please sign in to comment.