test/test_helper.rb in rip-0.0.1 vs test/test_helper.rb in rip-0.0.2
- old
+ new
@@ -10,10 +10,31 @@
require 'mock_git'
require 'fakefs'
require 'test/unit'
require 'test/spec/mini'
+begin; require 'redgreen'; rescue LoadError; end
+
+# For super rudimentary mocking...
+def fake(object, method_name, options={})
+ method = object.method(method_name)
+ metaclass = class << object; self end
+ return_value = options[:with]
+
+ metaclass.class_eval do
+ define_method(method_name) { |*args| return_value }
+ end
+
+ begin
+ yield
+ ensure
+ metaclass.class_eval do
+ define_method(method_name, method)
+ end
+ end
+end
+
def repo_path(repo_name)
RealFile.expand_path(RealFile.dirname(__FILE__) + '/repos/' + repo_name)
end
begin
@@ -26,10 +47,14 @@
define_method :setup do
FakeFS::FileSystem.clear
Rip::Env.create('other')
Rip::Setup.setup_ripenv(Rip.dir)
Rip::Env.create('base')
+
+ Rip::PackageManager.new('other').save
+ Rip::PackageManager.new('base').save
+
setup_block
end
define_method(:setup_block, &block)
end
@@ -43,9 +68,19 @@
end
def fresh_local_dir(repo_name)
FakeFS::FileSystem.clone(repo_path(repo_name))
Rip::DirPackage.new(repo_path(repo_name))
+ end
+
+ def fresh_local_file(repo_name)
+ FakeFS::FileSystem.clone(repo_path(repo_name))
+ Rip::FilePackage.new(repo_path(repo_name))
+ end
+
+ def fresh_ripfile(repo_name)
+ FakeFS::FileSystem.clone(repo_path(''))
+ Rip::RipfilePackage.new(repo_path(repo_name))
end
end
module Rip
class GitPackage