Permalink
Browse files

switched tests to bacon

  • Loading branch information...
cldwalker committed Jun 10, 2010
1 parent af1d8c3 commit 8b9ee6fca3e035bc4f09884cad4b12ce0ec9cca0
Showing with 32 additions and 32 deletions.
  1. +20 −20 test/local_gem_test.rb
  2. +6 −6 test/override_test.rb
  3. +6 −6 test/test_helper.rb
View
@@ -1,70 +1,70 @@
require File.join(File.dirname(__FILE__), 'test_helper')
class LocalGem::Test < Test::Unit::TestCase
before(:each) {
describe "LocalGem" do
before {
LocalGem::Singleton.config = { :gems=>{
'gem1'=>'path1', 'gem2'=>['path2','path3']}
}
}
test "local_gem adds gem's one path to $:" do
it "local_gem adds gem's one path to $:" do
full_gem_path = File.expand_path(LocalGem::Singleton.config[:gems]['gem1'])
assert !$:.include?(full_gem_path)
!$:.should.not.include?(full_gem_path)
LocalGem.local_gem('gem1')
assert $:.include?(full_gem_path)
$:.should.include?(full_gem_path)
end
test "local_gem adds gem's multiple paths to $:" do
it "local_gem adds gem's multiple paths to $:" do
full_gem_paths = LocalGem::Singleton.config[:gems]['gem2'].map {|e| File.expand_path(e) }
assert ($: & full_gem_paths).empty?
($: & full_gem_paths).should.be.empty?
LocalGem.local_gem('gem2')
assert !($: & full_gem_paths).empty?
($: & full_gem_paths).should.not.be.empty?
end
test "local_gem defaults to gem if no local gem found" do
it "local_gem defaults to gem if no local gem found" do
LocalGem::Singleton.expects(:gem).once
LocalGem.local_gem('invalid')
end
test "local_gem calls load_local_gem for a valid gem" do
it "local_gem calls load_local_gem for a valid gem" do
LocalGem::Singleton.expects(:load_local_gem).once.returns(true)
LocalGem.local_gem('blah')
end
test "local_require calls load_local_gem and require" do
it "local_require calls load_local_gem and require" do
LocalGem::Singleton.expects(:require).once
LocalGem::Singleton.expects(:load_local_gem).once
LocalGem.local_require('blah')
end
test "setup_config with hash initializes config" do
it "setup_config with hash initializes config" do
config = {:gems=>{'blah_gem'=>'blah_path'}}
LocalGem::Singleton.setup_config(config)
assert_equal config, LocalGem::Singleton.config
LocalGem::Singleton.config.should == config
end
test "setup_config with block initializes config" do
it "setup_config with block initializes config" do
config = {:gems=>{'blah_gem'=>'blah_path'}}
LocalGem::Singleton.setup_config do |c|
c.gems = config[:gems]
end
assert_equal config, LocalGem::Singleton.config
LocalGem::Singleton.config.should == config
end
test "read_config uses existing config_file" do
it "read_config uses existing config_file" do
LocalGem::Singleton.config_file = 'blah'
File.expects(:new)
YAML::expects(:load)
LocalGem::Singleton.read_config
assert_equal 'blah', LocalGem::Singleton.config_file
LocalGem::Singleton.config_file.should == 'blah'
end
test "read_config uses config_file it detects" do
it "read_config uses config_file it detects" do
LocalGem::Singleton.config_file = nil
File.expects(:new)
YAML::expects(:load)
File.expects(:exists?).times(2).returns(false, true)
LocalGem::Singleton.read_config
assert 'local_gem.yml', File.basename(LocalGem::Singleton.config_file)
File.basename(LocalGem::Singleton.config_file).should == '.local_gem.yml'
end
end
end
View
@@ -1,20 +1,20 @@
require File.join(File.dirname(__FILE__), 'test_helper')
class LocalGem::OverrideTest < Test::Unit::TestCase
before(:all) { require 'local_gem/override' }
test "gem calls old_gem and load_local_gem" do
describe "Override" do
before_all { require 'local_gem/override' }
it "gem calls old_gem and load_local_gem" do
LocalGem::Singleton.expects(:load_local_gem).once
self.expects(:old_gem).once
gem('blah')
end
test "require calls old_require and load_local_gem" do
it "require calls old_require and load_local_gem" do
LocalGem::Singleton.expects(:load_local_gem).once
self.expects(:old_require).once
require('blah')
end
test "loading override should have included LocalGem in self" do
assert self.instance_eval("class<<self; self; end").ancestors.include?(LocalGem)
it "loading override should have included LocalGem in self" do
self.instance_eval("class<<self; self; end").ancestors.should.include?(LocalGem)
end
end
View
@@ -1,9 +1,9 @@
require 'rubygems'
require 'test/unit'
require 'context' #gem install jeremymcanally-context -s http://gems.github.com
require 'rubygems' # needed for override tests
require 'bacon'
require 'mocha'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'mocha-on-bacon'
require 'local_gem'
class Test::Unit::TestCase
end
class Bacon::Context
def before_all; yield; end
end

0 comments on commit 8b9ee6f

Please sign in to comment.