spec/polonium/configuration_spec.rb in polonium-0.1.1 vs spec/polonium/configuration_spec.rb in polonium-0.2.0

- old
+ new

@@ -1,26 +1,8 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") module Polonium - describe Configuration, ".instance" do - attr_reader :configuration - before(:each) do - Configuration.instance = nil - @configuration = Configuration.new - end - - it "should create a new Configuration if it hasn't been called yet" do - mock(Configuration).new.returns(configuration) - Configuration.instance.should == configuration - end - - it "should reuse the existing Configuration if it has been called. So new/establish_environment should only be called once." do - Configuration.instance.should_not be_nil - dont_allow(Configuration).new - end - end - describe Configuration do attr_reader :configuration before(:each) do @configuration = Configuration.new @old_rails_root = RAILS_ROOT if Object.const_defined? :RAILS_ROOT @@ -84,74 +66,31 @@ driver = configuration.create_and_initialize_driver driver.should == stub_driver passed_driver.should == driver start_called.should == true end + end - it "creates a Webrick Server Runner" do - configuration.selenium_server_port = 4000 - configuration.selenium_server_host = "localhost" - dir = File.dirname(__FILE__) - configuration.rails_root = dir - configuration.rails_env = "test" - - runner = configuration.create_webrick_runner - runner.should be_an_instance_of(WebrickSeleniumServerRunner) - runner.configuration.should == configuration - runner.thread_class.should == Thread - runner.socket.should == Socket - runner.dispatch_servlet.should == DispatchServlet - runner.environment_path.should == File.expand_path("#{dir}/config/environment") + describe ".instance" do + attr_reader :configuration + before(:each) do + Configuration.instance = nil + @configuration = Configuration.new end - it "creates webrick http server" do - configuration.internal_app_server_port = 4000 - configuration.internal_app_server_host = "localhost" - - mock_logger = "logger" - mock(configuration).new_logger {mock_logger} - mock(WEBrick::HTTPServer).new({ - :Port => 4000, - :BindAddress => "localhost", - :ServerType => WEBrick::SimpleServer, - :MimeTypes => WEBrick::HTTPUtils::DefaultMimeTypes, - :Logger => mock_logger, - :AccessLog => [] - }) - server = configuration.create_webrick_server + it "should create a new Configuration if it hasn't been called yet" do + mock(Configuration).new.returns(configuration) + Configuration.instance.should == configuration end - it "creates Mongrel Server Runner" do - server = configuration.create_mongrel_runner - server.should be_instance_of(MongrelSeleniumServerRunner) - server.configuration.should == configuration - server.thread_class.should == Thread + it "should reuse the existing Configuration if it has been called. So new/establish_environment should only be called once." do + Configuration.instance.should_not be_nil + dont_allow(Configuration).new end - - it "creates Mongrel configurator" do - configuration.internal_app_server_host = "localhost" - configuration.internal_app_server_port = 4000 - configuration.rails_env = "test" - configuration.rails_root = rails_root = File.dirname(__FILE__) - - configurator = configuration.create_mongrel_configurator - configurator.defaults[:host].should == "localhost" - configurator.defaults[:port].should == 4000 - configurator.defaults[:cwd].should == configuration.rails_root - configurator.defaults[:log_file].should == "#{configuration.rails_root}/log/mongrel.log" - configurator.defaults[:pid_file].should == "#{configuration.rails_root}/log/mongrel.pid" - configurator.defaults[:environment].should == "test" - configurator.defaults[:docroot].should == "#{rails_root}/public" - configurator.defaults[:mime_map].should be_nil - configurator.defaults[:daemon].should == false - configurator.defaults[:debug].should == false - configurator.defaults[:includes].should == ["mongrel"] - configurator.defaults[:config_script].should be_nil - end end - describe Configuration, "#establish_environment" do + describe "#establish_environment" do attr_reader :configuration before(:each) do @old_configuration = Configuration.instance Configuration.instance = nil @configuration = Configuration.instance @@ -294,11 +233,11 @@ object.send("#{method_name}=", test_object) object.send(method_name).should == test_object end end - describe Configuration, "#stop_driver_if_necessary" do + describe "#stop_driver_if_necessary" do attr_reader :configuration before(:each) do @configuration = Configuration.new end @@ -328,32 +267,35 @@ configuration.stop_driver_if_necessary false end end - describe Configuration, "#create_server_runner where application server engine is mongrel" do - it "creates a mongrel server runner" do - configuration = Configuration.new - configuration.app_server_engine = :mongrel - runner = configuration.create_server_runner - runner.should be_instance_of(MongrelSeleniumServerRunner) + describe "#create_app_server_runner" do + describe "when server engine in mongrel" do + it "creates a mongrel server runner" do + configuration = Configuration.new + configuration.app_server_engine = :mongrel + runner = configuration.create_app_server_runner + runner.class.should == ServerRunners::MongrelServerRunner + runner.configuration.should == configuration + end end - end - describe Configuration, "#create_server_runner where application server engine is webrick" do - before do - Object.const_set :RAILS_ROOT, "foobar" - require 'webrick_server' - end + describe "when server engine is webrick" do + before do + Object.const_set :RAILS_ROOT, "foobar" + end - after do - Object.instance_eval {remove_const :RAILS_ROOT} - end + after do + Object.instance_eval {remove_const :RAILS_ROOT} + end - it "creates a webrick server runner" do - configuration = Configuration.new - configuration.app_server_engine = :webrick - runner = configuration.create_server_runner - runner.should be_instance_of(WebrickSeleniumServerRunner) + it "creates a webrick server runner" do + configuration = Configuration.new + configuration.app_server_engine = :webrick + runner = configuration.create_app_server_runner + runner.class.should == ServerRunners::WebrickServerRunner + runner.configuration.should == configuration + end end end end