File: framework_spawner_spec.rb

package info (click to toggle)
ruby-passenger 3.0.13debian-1%2Bdeb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 15,920 kB
  • sloc: cpp: 99,104; ruby: 18,098; ansic: 9,846; sh: 8,632; python: 141; makefile: 30
file content (38 lines) | stat: -rw-r--r-- 1,089 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')

module PhusionPassenger

shared_examples_for "a ClassicRails::FrameworkSpawner" do
	it "raises FrameworkInitError if the framework could not be loaded" do
		block = lambda do
			load_nonexistant_framework("print_framework_loading_exceptions" => false).close
		end
		block.should raise_error(FrameworkInitError)
	end
	
	it "prints the exception to STDERR if the framework could not be loaded" do
		old_stderr = STDERR
		file = File.new('output.tmp', 'w+')
		begin
			Object.send(:remove_const, "STDERR") rescue nil
			Object.const_set("STDERR", file)
			
			block = lambda do
				load_nonexistant_framework.close
			end
			block.should raise_error(FrameworkInitError)
			
			file.rewind
			data = file.read
			data.should =~ /load_nonexistant_framework/
			data.should =~ /framework_spawner_spec\.rb/
		ensure
			Object.send(:remove_const, "STDERR") rescue nil
			Object.const_set("STDERR", old_stderr)
			file.close rescue nil
			File.unlink('output.tmp') rescue nil
		end
	end
end

end # module PhusionPassenger