Skip to content

Commit

Permalink
Test Jammit packager against a real Rails app.
Browse files Browse the repository at this point in the history
It now detects untracked asset files and commits them.
  • Loading branch information
Gabe Berke-Williams committed Oct 22, 2011
1 parent 867594d commit 810a832
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 24 deletions.
29 changes: 9 additions & 20 deletions features/jammit.feature
@@ -1,31 +1,20 @@
@creates-remote @disable-bundler
@slow @creates-remote @disable-bundler
Feature: Jammit
As a user
I want Kumade to auto-package with Jammit
So that I don't have to remember to package assets

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 configure my Rails app for Jammit
And I create a Heroku remote named "staging"

Scenario: Jammit packager runs if Jammit is installed
When I run kumade with "pretend-staging"
Then the output from "bundle exec kumade pretend-staging" should contain "==> ! Error: Jammit::MissingConfiguration"
When I run kumade
Then the output should contain "==> Packaged with Kumade::JammitPackager"

Scenario: Run custom task before jammit
Given I write to "Rakefile" with:
"""
namespace :kumade do
task :before_asset_compilation do
puts 'Hi!'
end
end
"""
When I run kumade with "pretend-staging -p"
When I add a pre-compilation rake task that prints "Hi!"
And I run kumade
Then the output should contain "kumade:before_asset_compilation"
And the output should contain "==> Packaged with Kumade::JammitPackager"
And the output should contain "Hi!"
3 changes: 3 additions & 0 deletions features/step_definitions/jammit_steps.rb
@@ -0,0 +1,3 @@
When /^I set up Jammit$/ do
set_up_jammit
end
4 changes: 4 additions & 0 deletions features/step_definitions/kumade_steps.rb
@@ -1,3 +1,7 @@
When /^I run kumade$/ do
run_simple("bundle exec kumade")
end

When /^I run kumade with "([^"]+)"$/ do |args|
run_simple("bundle exec kumade #{args}")
end
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/rails_steps.rb
Expand Up @@ -5,3 +5,9 @@
Given /^a new Rails application with Kumade and Jammit$/ do
create_rails_app_with_kumade_and_jammit
end

When /^I configure my Rails app for Jammit$/ do
run_bundler#_from_vendor
set_up_jammit
add_origin_remote
end
3 changes: 2 additions & 1 deletion features/support/bundler.rb
@@ -1,6 +1,7 @@
module BundlerHelpers
def run_bundler
run_simple('bundle --gemfile=./Gemfile --local || bundle --gemfile=./Gemfile')
bundle = 'bundle install'
run_simple("#{bundle} --local || #{bundle}")
end

def add_jammit_to_gemfile
Expand Down
6 changes: 3 additions & 3 deletions features/support/git.rb
Expand Up @@ -5,15 +5,15 @@ def set_up_git_repo
end
end

def commit_everything_in_repo
['git add .', 'git commit -am MY_MESSAGE'].each do |git_command|
def commit_everything_in_repo(message = "MY_MESSAGE")
['git add .', "git commit -am '#{message}'"].each do |git_command|
run_simple(git_command)
end
end

def modify_tracked_file
write_file('tracked-file', 'clean')
commit_everything_in_repo
commit_everything_in_repo('modify tracked file')
append_to_file('tracked-file', 'dirty it up')
end
end
Expand Down
11 changes: 11 additions & 0 deletions features/support/git_remotes.rb
Expand Up @@ -20,6 +20,17 @@ def add_non_heroku_remote_named(remote_name)
run_simple("git remote add #{remote_name} git@github.com:gabebw/kumade.git")
@@created_remotes << remote_name
end

def add_origin_remote
original_dir = current_dir
create_dir("../origin")
cd("../origin")
run_simple("git init --bare")

cd("../#{File.basename(original_dir)}")
run_simple("git remote add origin ../origin")
@@created_remotes << 'origin'
end
end

World(GitRemoteHelpers)
14 changes: 14 additions & 0 deletions features/support/jammit.rb
@@ -0,0 +1,14 @@
module JammitHelpers
def set_up_jammit
assets_yaml = <<-YAML.strip
javascripts:
default:
- public/javascripts/application.js
YAML
write_file('public/javascripts/application.js', 'var foo = 3;')
write_file('config/assets.yml', assets_yaml)
commit_everything_in_repo('add Jammit files')
end
end

World(JammitHelpers)

0 comments on commit 810a832

Please sign in to comment.