spec/config_spec.rb in jbox-gitolite-1.2.0 vs spec/config_spec.rb in jbox-gitolite-1.2.1
- old
+ new
@@ -1,23 +1,24 @@
-require 'gratr'
-require 'gitolite/config'
require 'spec_helper'
describe Gitolite::Config do
- conf_dir = File.join(File.dirname(__FILE__),'configs')
+ conf_dir = File.join(File.dirname(__FILE__), 'fixtures', 'configs')
+ output_dir = '/tmp'
+ # output_dir = File.join(File.dirname(File.dirname(__FILE__)), 'tmp')
+
describe "#new" do
it 'should read a simple configuration' do
c = Gitolite::Config.new(File.join(conf_dir, 'simple.conf'))
c.repos.length.should == 2
c.groups.length.should == 0
end
it 'should read a complex configuration' do
c = Gitolite::Config.new(File.join(conf_dir, 'complicated.conf'))
c.groups.length.should == 5
- c.repos.length.should == 12
+ c.repos.length.should == 13
end
describe 'gitweb operations' do
before :all do
@config = Gitolite::Config.new(File.join(conf_dir, 'complicated.conf'))
@@ -325,21 +326,27 @@
end
describe "#to_file" do
it 'should create a file at the given path with the config\'s file name' do
c = Gitolite::Config.init
- file = c.to_file('/tmp')
- File.file?(File.join('/tmp', c.filename)).should be true
+ file = c.to_file(output_dir)
+ File.file?(File.join(output_dir, c.filename)).should be true
File.unlink(file)
end
+ it 'should create a file at the given path with the config file passed' do
+ c = Gitolite::Config.new(File.join(conf_dir, 'complicated.conf'))
+ file = c.to_file(output_dir)
+ File.file?(File.join(output_dir, c.filename)).should be true
+ end
+
it 'should create a file at the given path when a different filename is specified' do
filename = "test.conf"
c = Gitolite::Config.init
c.filename = filename
- file = c.to_file('/tmp')
- File.file?(File.join('/tmp', filename)).should be true
+ file = c.to_file(output_dir)
+ File.file?(File.join(output_dir, filename)).should be true
File.unlink(file)
end
it 'should raise an ArgumentError when an invalid path is specified' do
c = Gitolite::Config.init
@@ -371,11 +378,11 @@
g = Gitolite::Config::Group.new "groupd"
g.add_users "larry", "@groupc"
c.add_group(g)
# Write the config to a file
- file = c.to_file('/tmp')
+ file = c.to_file(output_dir)
# Read the conf and make sure our order is correct
f = File.read(file)
lines = f.lines.map {|l| l.strip}
@@ -409,11 +416,11 @@
g = Gitolite::Config::Group.new "groupd"
g.add_users "larry", "@groupc"
c.add_group(g)
# Attempt to write the config file
- lambda{ c.to_file('/tmp')}.should raise_error(Gitolite::Config::GroupDependencyError)
+ lambda{ c.to_file(output_dir)}.should raise_error(Gitolite::Config::GroupDependencyError)
end
it 'should resolve group dependencies even when there are disconnected portions of the graph' do
c = Gitolite::Config.init
c.filename = "test_deptree.conf"
@@ -434,10 +441,10 @@
g = Gitolite::Config::Group.new "groupd"
g.add_users "larry", "chris", "emily"
c.add_group(g)
# Write the config to a file
- file = c.to_file('/tmp')
+ file = c.to_file(output_dir)
# Read the conf and make sure our order is correct
f = File.read(file)
lines = f.lines.map {|l| l.strip}