<commit_before>$LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
require 'mod_rails/application_spawner'
require 'abstract_server_spec'
include ModRails

describe ApplicationSpawner do
	before :each do
		@spawner = ApplicationSpawner.new('stub/railsapp')
		@spawner.start
		@server = @spawner
	end
	
	after :each do
		@spawner.stop
	end
	
	it_should_behave_like "AbstractServer"
	
	it "should be able to spawn our stub application" do
		app = @spawner.spawn_application
		app.pid.should_not == 0
		app.app_root.should_not be_nil
	end
	
	it "should be able to spawn an arbitary number of applications" do
		last_pid = 0
		4.times do
			app = @spawner.spawn_application
			app.pid.should_not == last_pid
			app.app_root.should_not be_nil
			last_pid = app.pid
		end
	end
	
	it "should raise a SpawnError if something went wrong" do
		pid = @spawner.instance_eval { @pid }
		Process.kill('SIGABRT', pid)
		spawning = lambda { @spawner.spawn_application }
		spawning.should raise_error(ApplicationSpawner::SpawnError)
	end
	
	it "should work correctly after a restart, if something went wrong" do
		pid = @spawner.instance_eval { @pid }
		Process.kill('SIGABRT', pid)
		spawning = lambda { @spawner.spawn_application }
		spawning.should raise_error(ApplicationSpawner::SpawnError)
		
		@spawner.stop
		@spawner.start
		app = @spawner.spawn_application
		app.pid.should_not == 0
		app.app_root.should_not be_nil
	end
	
	it "should be able to spawn an application as a different user" do
		violated "not implemented yet"
	end
	
	it "should be able to spawn an application as a different group" do
		violated "not implemented yet"
	end
	
	it "should be able to spawn an application as a different user and group" do
		violated "not implemented yet"
	end
end<commit_msg>Don't forget to close spawned applications.<commit_after>$LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
require 'mod_rails/application_spawner'
require 'abstract_server_spec'
include ModRails

describe ApplicationSpawner do
	before :each do
		@spawner = ApplicationSpawner.new('stub/railsapp')
		@spawner.start
		@server = @spawner
	end
	
	after :each do
		@spawner.stop
	end
	
	it_should_behave_like "AbstractServer"
	
	it "should be able to spawn our stub application" do
		app = @spawner.spawn_application
		app.pid.should_not == 0
		app.app_root.should_not be_nil
	end
	
	it "should be able to spawn an arbitary number of applications" do
		last_pid = 0
		4.times do
			app = @spawner.spawn_application
			app.pid.should_not == last_pid
			app.app_root.should_not be_nil
			last_pid = app.pid
			app.close
		end
	end
	
	it "should raise a SpawnError if something went wrong" do
		pid = @spawner.instance_eval { @pid }
		Process.kill('SIGABRT', pid)
		spawning = lambda { @spawner.spawn_application }
		spawning.should raise_error(ApplicationSpawner::SpawnError)
	end
	
	it "should work correctly after a restart, if something went wrong" do
		pid = @spawner.instance_eval { @pid }
		Process.kill('SIGABRT', pid)
		spawning = lambda { @spawner.spawn_application }
		spawning.should raise_error(ApplicationSpawner::SpawnError)
		
		@spawner.stop
		@spawner.start
		app = @spawner.spawn_application
		app.pid.should_not == 0
		app.app_root.should_not be_nil
		app.close
	end
	
	it "should be able to spawn an application as a different user" do
		violated "not implemented yet"
	end
	
	it "should be able to spawn an application as a different group" do
		violated "not implemented yet"
	end
	
	it "should be able to spawn an application as a different user and group" do
		violated "not implemented yet"
	end
end
{'fraction_non_alphanumeric': 0.08051439753983786, 'fraction_numerical': 0.0022365110427732737, 'mean_word_length': 4.096866096866097, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6938429', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1207, 'n_words': 364}