Skip to content
Browse files

added a few tests for dry runs, removed unused code

  • Loading branch information...
1 parent 38535cf commit a8e42104877f9d18b1291c576edf9020f6996272 @hsume2 committed Oct 5, 2009
Showing with 26 additions and 33 deletions.
  1. +1 −0 Rakefile
  2. +0 −31 lib/cap-taffy.rb
  3. +1 −0 lib/cap-taffy/db.rb
  4. +1 −1 lib/cap-taffy/parse.rb
  5. +20 −1 spec/cap-taffy/db_spec.rb
  6. +3 −0 spec/cap-taffy_spec.rb
View
1 Rakefile
@@ -32,3 +32,4 @@ PROJ.summary = "Capistrano recipes for deploying databases (managing database.ym
PROJ.ignore_file = '.gitignore'
PROJ.spec.opts << '--color'
PROJ.exclude << "bin"
+PROJ.rcov.opts << IO.readlines("spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
View
31 lib/cap-taffy.rb
@@ -1,4 +1,3 @@
-
module CapTaffy
# :stopdoc:
@@ -12,34 +11,4 @@ module CapTaffy
def self.version
VERSION
end
-
- # Returns the library path for the module. If any arguments are given,
- # they will be joined to the end of the libray path using
- # <tt>File.join</tt>.
- #
- def self.libpath( *args )
- args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
- end
-
- # Returns the lpath for the module. If any arguments are given,
- # they will be joined to the end of the path using
- # <tt>File.join</tt>.
- #
- def self.path( *args )
- args.empty? ? PATH : ::File.join(PATH, args.flatten)
- end
-
- # Utility method used to require all files ending in .rb that lie in the
- # directory below this file that has the same name as the filename passed
- # in. Optionally, a specific _directory_ name can be passed in such that
- # the _filename_ does not have to be equivalent to the directory.
- #
- def self.require_all_libs_relative_to( fname, dir = nil )
- dir ||= ::File.basename(fname, '.*')
- search_me = ::File.expand_path(
- ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
-
- Dir.glob(search_me).sort.each {|rb| require rb}
- end
-
end
View
1 lib/cap-taffy/db.rb
@@ -1,3 +1,4 @@
+p self
require 'rubygems'
begin
gem 'taps', '>= 0.2.8', '< 0.3.0'
View
2 lib/cap-taffy/parse.rb
@@ -4,7 +4,7 @@
require 'heroku/commands/base'
require 'heroku/commands/db'
rescue LoadError
- error "Install the Heroku gem. On most systems this will be:\nsudo gem install taps"
+ error "Install the Heroku gem. On most systems this will be:\nsudo gem install heroku"
end
module CapTaffy
View
21 spec/cap-taffy/db_spec.rb
@@ -32,6 +32,25 @@ module CapTaffy
@namespace.instance_variable_get(:@local_database_url).should == "local_db_url"
end
+ for_task :detect, :roles => :app, :in => :Db, :it => "should be safe if dry run" do
+ @mod.expects(:remote_database_url).raises Exception
+ @mod.expects(:local_database_url).raises Exception
+ @namespace.stubs(:dry_run).returns(true)
+
+ load 'lib/cap-taffy/db.rb'
+
+ @namespace.instance_variable_get(:@remote_database_url).should == ""
+ @namespace.instance_variable_get(:@local_database_url).should == ""
+ end
+
+ for_task :detect, :roles => :app, :in => :Db, :it => "should raise as usual if not dry run" do
+ class SpecialError < StandardError; end
+ @mod.expects(:remote_database_url).raises SpecialError
+ @namespace.stubs(:dry_run).returns(false)
+
+ lambda { load 'lib/cap-taffy/db.rb' }.should raise_error(SpecialError)
+ end
+
def load_taffy_db # :nodoc:
with_logger do
load 'lib/cap-taffy/db.rb'
@@ -83,7 +102,7 @@ def load_taffy_db # :nodoc:
end
end
- context "after capistrano" do
+ context "after capistrano loaded" do
include CapistranoHelpers
include TaffyHelpers
View
3 spec/cap-taffy_spec.rb
@@ -1,4 +1,7 @@
require File.join(File.dirname(__FILE__), %w[spec_helper])
describe CapTaffy do
+ it "should get the version" do
+ CapTaffy::VERSION.should == CapTaffy.version
+ end
end

0 comments on commit a8e4210

Please sign in to comment.
Something went wrong with that request. Please try again.