more testing setup

This commit is contained in:
John Bintz 2010-05-04 17:04:44 -04:00
parent 815775860b
commit c28918d905
7 changed files with 63 additions and 6 deletions

View File

@ -17,6 +17,7 @@ namespace :spec do
Spec::Rake::SpecTask.new('rcov') do |t| Spec::Rake::SpecTask.new('rcov') do |t|
t.spec_files = FileList['spec/*.rb'] t.spec_files = FileList['spec/*.rb']
t.rcov = true t.rcov = true
t.rcov_opts = ['--exclude', 'spec'] t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems']
t.spec_opts = ['-b']
end end
end end

View File

@ -9,12 +9,10 @@ module Apache
include Apache::Quoteize include Apache::Quoteize
include Apache::Permissions include Apache::Permissions
def build(target, &block) def build(target = nil, &block)
reset! reset!
self.instance_eval(&block) self.instance_eval(&block)
puts @config * "\n"
end end
# Reset the current settings # Reset the current settings

View File

@ -1,7 +1,7 @@
module Apache module Apache
module Master module Master
def modules(*modules, &block) def modules(*modules, &block)
@config << Modules.build(*modules, &block) @config += Modules.build(*modules, &block)
end end
def runner(user, group = nil) def runner(user, group = nil)

View File

@ -5,8 +5,14 @@ module Apache
class << self class << self
include Apache::Quoteize include Apache::Quoteize
def build(*modules, &block) attr_accessor :modules
def reset!
@modules = [] @modules = []
end
def build(*modules, &block)
reset!
modules.each { |m| self.send(m) } modules.each { |m| self.send(m) }
self.instance_eval(&block) if block self.instance_eval(&block) if block

View File

@ -47,4 +47,14 @@ describe Apache::Config, "should handle the basics of Apache config" do
something "goes here" something "goes here"
end.should == ['<Tag "part">', ' Something "goes here"', '</Tag>'] end.should == ['<Tag "part">', ' Something "goes here"', '</Tag>']
end end
it "should handle a build" do
Apache::Config.build do
my_test "this"
end
Apache::Config.config.should == [
'MyTest "this"'
]
end
end end

19
spec/master_spec.rb Normal file
View File

@ -0,0 +1,19 @@
require 'apache/config'
describe Apache::Master, "should provide basic helpers for configuration" do
before do
Apache::Config.reset!
end
it "should build the modules with the provided block" do
Apache::Config.modules(:this, :that) do
my "is here"
end
Apache::Config.config.should == [
'LoadModule "this_module" "modules/mod_this.so"',
'LoadModule "that_module" "modules/mod_that.so"',
'LoadModule "my_module" "is here"',
]
end
end

23
spec/modules_spec.rb Normal file
View File

@ -0,0 +1,23 @@
require 'apache/modules'
describe Apache::Modules, "should build a list of modules" do
before do
Apache::Modules.reset!
end
it "should handle method_missing" do
Apache::Modules.mine
Apache::Modules.modules.should == [ 'LoadModule "mine_module" "modules/mod_mine.so"' ]
end
it "should build a set of modules" do
Apache::Modules.build(:this, :that) do
mine "my_path"
end.should == [
'LoadModule "this_module" "modules/mod_this.so"',
'LoadModule "that_module" "modules/mod_that.so"',
'LoadModule "mine_module" "my_path"'
]
end
end