Permalink
Browse files

bundled the setup of the local git repo into a helper method

  • Loading branch information...
1 parent 435d7e5 commit d721bf8e09504e5c07262f96c2296c913b515b2f @ejdraper committed Jul 12, 2009
Showing with 52 additions and 3 deletions.
  1. +2 −0 Manifest.txt
  2. +2 −0 lib/appsta.rb
  3. +10 −0 lib/appsta/git.rb
  4. +1 −3 lib/template.rb
  5. +37 −0 test/test_git.rb
View
@@ -7,10 +7,12 @@ bin/appsta
lib/appsta.rb
lib/appsta/heroku.rb
lib/appsta/github.rb
+lib/appsta/git.rb
lib/template.rb
script/console
script/destroy
script/generate
test/test_heroku.rb
test/test_github.rb
+test/test_git.rb
test/test_helper.rb
View
@@ -1,9 +1,11 @@
require File.join(File.dirname(__FILE__), "appsta", "heroku")
require File.join(File.dirname(__FILE__), "appsta", "github")
+require File.join(File.dirname(__FILE__), "appsta", "git")
module Appsta
VERSION = "0.0.1"
include Appsta::Heroku
include Appsta::GitHub
+ include Appsta::Git
end
View
@@ -0,0 +1,10 @@
+module Appsta
+ module Git
+ # This sets up the git repo, optionally with a custom message
+ def git_setup(message = "initial commit by Appsta")
+ git(:init)
+ git(:add => ".")
+ git(:commit => "-a -m '#{message}'")
+ end
+ end
+end
View
@@ -11,9 +11,7 @@
run "curl -s -L http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js > public/javascripts/jquery.js"
# Setup the Git repo
-git :init
-git :add => "."
-git :commit => "-a -m 'initial commit by Appsta'"
+git_setup
# Setup the app on Heroku
[:production, :staging].each { |env| heroku(env) }
View
@@ -0,0 +1,37 @@
+require File.join(File.dirname(__FILE__), "test_helper")
+
+class RunGit
+ include Appsta::Git
+end
+
+class TestGit < Test::Unit::TestCase
+ context "Setting up Git repo" do
+ setup do
+ setup_base_mocks
+ RunGit.any_instance.expects(:git).with(:commit => "-a -m 'initial commit by Appsta'")
+ end
+
+ should "not fail" do
+ assert true, RunGit.new.git_setup
+ end
+ end
+
+ context "Setting up Git repo with a custom commit message" do
+ CUSTOM_MESSAGE = "my test commit message"
+
+ setup do
+ setup_base_mocks
+ RunGit.any_instance.expects(:git).with(:commit => "-a -m '#{CUSTOM_MESSAGE}'")
+ end
+
+ should "not fail" do
+ assert true, RunGit.new.git_setup(CUSTOM_MESSAGE)
+ end
+ end
+
+ # This sets up the mocks common to all contexts
+ def setup_base_mocks
+ RunGit.any_instance.expects(:git).with(:init)
+ RunGit.any_instance.expects(:git).with(:add => ".")
+ end
+end

0 comments on commit d721bf8

Please sign in to comment.