Sha256: c8dc704bff882d2df3c8ee8f954d6eb2fedc9e09adb663eacc86b29cab9eeba8

Contents?: true

Size: 1.93 KB

Versions: 3

Compression:

Stored size: 1.93 KB

Contents

# -*- ruby -*-
# frozen_string_literal: true

require_relative '../../helpers'

require 'rspec'
require 'mongrel2'
require 'mongrel2/config'


#####################################################################
###	C O N T E X T S
#####################################################################

describe Mongrel2::Config::Directory, :db do

	before( :each ) do
		@dir = Mongrel2::Config::Directory.new(
			:base          => 'var/www/public/',
			:index_file    => 'index.html',
			:default_ctype => 'text/plain'
		)
	end


	it "is valid if its base, index_file, and default_ctype are all valid" do
		expect( @dir ).to be_valid()
	end


	it "isn't valid if it doesn't have a base" do
		@dir.base = nil
		expect( @dir ).to_not be_valid()
		expect( @dir.errors.full_messages.first ).to match( /missing or nil/i )
	end


	it "isn't valid when its base starts with '/'" do
		@dir.base = '/var/www/public/'
		expect( @dir ).to_not be_valid()
		expect( @dir.errors.full_messages.first ).to match( %r{shouldn't start with '/'}i )
	end


	it "isn't valid when its base doesn't end with '/'" do
		@dir.base = 'var/www/public'
		expect( @dir ).to_not be_valid()
		expect( @dir.errors.full_messages.first ).to match( %r{must end with '/'}i )
	end


	it "isn't valid if it doesn't have an index file" do
		@dir.index_file = nil
		expect( @dir ).to_not be_valid()
		expect( @dir.errors.full_messages.first ).to match( /must not be nil/i )
	end


	it "isn't valid if it doesn't have a default content-type" do
		@dir.default_ctype = nil
		expect( @dir ).to_not be_valid()
		expect( @dir.errors.full_messages.first ).to match( /must not be nil/i )
	end


	it "isn't valid if its cache TTL is set to a negative value" do
		@dir.cache_ttl = -5
		expect( @dir ).to_not be_valid()
		expect( @dir.errors.full_messages.first ).to match( /not a positive integer/i )
	end


	it "is valid if its cache TTL is set to zero" do
		@dir.cache_ttl = 0
		expect( @dir ).to be_valid()
	end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongrel2-0.55.0 spec/mongrel2/config/directory_spec.rb
mongrel2-0.54.0 spec/mongrel2/config/directory_spec.rb
mongrel2-0.53.0 spec/mongrel2/config/directory_spec.rb