more testing setup
This commit is contained in:
parent
815775860b
commit
c28918d905
3
Rakefile
3
Rakefile
@ -17,6 +17,7 @@ namespace :spec do
|
||||
Spec::Rake::SpecTask.new('rcov') do |t|
|
||||
t.spec_files = FileList['spec/*.rb']
|
||||
t.rcov = true
|
||||
t.rcov_opts = ['--exclude', 'spec']
|
||||
t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems']
|
||||
t.spec_opts = ['-b']
|
||||
end
|
||||
end
|
||||
|
@ -9,12 +9,10 @@ module Apache
|
||||
include Apache::Quoteize
|
||||
include Apache::Permissions
|
||||
|
||||
def build(target, &block)
|
||||
def build(target = nil, &block)
|
||||
reset!
|
||||
|
||||
self.instance_eval(&block)
|
||||
|
||||
puts @config * "\n"
|
||||
end
|
||||
|
||||
# Reset the current settings
|
||||
|
@ -1,7 +1,7 @@
|
||||
module Apache
|
||||
module Master
|
||||
def modules(*modules, &block)
|
||||
@config << Modules.build(*modules, &block)
|
||||
@config += Modules.build(*modules, &block)
|
||||
end
|
||||
|
||||
def runner(user, group = nil)
|
||||
|
@ -5,8 +5,14 @@ module Apache
|
||||
class << self
|
||||
include Apache::Quoteize
|
||||
|
||||
def build(*modules, &block)
|
||||
attr_accessor :modules
|
||||
|
||||
def reset!
|
||||
@modules = []
|
||||
end
|
||||
|
||||
def build(*modules, &block)
|
||||
reset!
|
||||
|
||||
modules.each { |m| self.send(m) }
|
||||
self.instance_eval(&block) if block
|
||||
|
@ -47,4 +47,14 @@ describe Apache::Config, "should handle the basics of Apache config" do
|
||||
something "goes here"
|
||||
end.should == ['<Tag "part">', ' Something "goes here"', '</Tag>']
|
||||
end
|
||||
|
||||
it "should handle a build" do
|
||||
Apache::Config.build do
|
||||
my_test "this"
|
||||
end
|
||||
|
||||
Apache::Config.config.should == [
|
||||
'MyTest "this"'
|
||||
]
|
||||
end
|
||||
end
|
||||
|
19
spec/master_spec.rb
Normal file
19
spec/master_spec.rb
Normal 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
23
spec/modules_spec.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user