a few more tweaks

This commit is contained in:
John Bintz 2010-05-19 10:34:49 -04:00
parent d3b4747704
commit da679f87da
2 changed files with 13 additions and 2 deletions

View File

@ -266,7 +266,7 @@ module Apache
end
def initial_blank!
@conditions.empty ? nil : ''
@conditions.empty? ? nil : ''
end
def to_s
@ -274,11 +274,12 @@ module Apache
end
def to_a
[ intial_blank!, @conditions.collect(&:to_s), super ].flatten
[ initial_blank!, @conditions.collect(&:to_s), super ].flatten
end
# Test this RewriteRule, ensuring the RewriteConds also match
def test(from, opts = {})
ensure_opts!(opts)
opts[:request_uri] = from
result = from
@ -287,7 +288,13 @@ module Apache
result.replace_placeholderize(opts)
end
def ensure_opts!(opts)
raise "Options must be a hash" if !opts
raise "Options must be a hash" if !opts.kind_of? ::Hash
end
def match?(from, opts = {})
ensure_opts!(opts)
opts[:request_uri] = from
@conditions.each do |cond|

View File

@ -88,6 +88,10 @@ describe Apache::RewriteRule, "a RewriteRule" do
it "should not the test" do
subject.test('/test', :request_filename => 'test').should == '/test2'
end
it "should fail if opts is not provided" do
lambda { subject.match?('test', nil) }.should raise_error
end
end
describe Apache::RewriteCondition, "a RewriteCond" do