Sha256: e67f5cc1c6f93c7b37e848098c296748560b3adf38dcb4529159bfcfbb2ed89d

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

#!/usr/bin/env ruby

require_relative '../../helpers'

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


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

describe Mongrel2::Config::Directory do

	before( :all ) do
		setup_config_db()
	end

	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

2 entries across 2 versions & 1 rubygems

Version Path
mongrel2-0.45.1 spec/mongrel2/config/directory_spec.rb
mongrel2-0.45.0 spec/mongrel2/config/directory_spec.rb