Class: Polonium::Configuration
- Inherits:
-
Object
- Object
- Polonium::Configuration
- Defined in:
- lib/polonium/configuration.rb
Overview
Defined Under Namespace
Modules: BrowserMode
Constant Summary collapse
- FIREFOX =
"firefox"
- IEXPLORE =
"iexplore"
- SERVER_RUNNERS =
{ :webrick => ServerRunners::WebrickServerRunner, :mongrel => ServerRunners::MongrelServerRunner, :external => ServerRunners::ExternalServerRunner }
Class Attribute Summary collapse
-
.instance ⇒ Object
The instance of the Singleton Configuration.
Instance Attribute Summary collapse
-
#app_server_engine ⇒ Object
Returns the value of attribute app_server_engine.
-
#app_server_initialization ⇒ Object
Returns the value of attribute app_server_initialization.
-
#app_server_runner ⇒ Object
readonly
Returns the value of attribute app_server_runner.
-
#browser ⇒ Object
Returns the value of attribute browser.
-
#browser_mode ⇒ Object
Returns the value of attribute browser_mode.
-
#driver ⇒ Object
The Driver object, which sublcasses the Driver provided by the Selenium RC (openqa.org/selenium-rc/) project.
-
#env ⇒ Object
Returns the value of attribute env.
-
#external_app_server_host ⇒ Object
Returns the value of attribute external_app_server_host.
-
#external_app_server_port ⇒ Object
Returns the value of attribute external_app_server_port.
-
#internal_app_server_host ⇒ Object
Returns the value of attribute internal_app_server_host.
-
#internal_app_server_port ⇒ Object
Returns the value of attribute internal_app_server_port.
-
#keep_browser_open_on_failure ⇒ Object
Returns the value of attribute keep_browser_open_on_failure.
-
#rails_env ⇒ Object
Returns the value of attribute rails_env.
-
#rails_root ⇒ Object
Returns the value of attribute rails_root.
-
#selenium_server_host ⇒ Object
Returns the value of attribute selenium_server_host.
-
#selenium_server_port ⇒ Object
Returns the value of attribute selenium_server_port.
-
#server_engine ⇒ Object
Returns the value of attribute server_engine.
-
#verify_remote_app_server_is_running ⇒ Object
Returns the value of attribute verify_remote_app_server_is_running.
Instance Method Summary collapse
-
#after_driver_started(&block) ⇒ Object
A callback hook that gets run after the Selenese Interpreter is started.
-
#browser_url ⇒ Object
The http host name and port to be entered into the browser address bar.
-
#create_and_initialize_driver ⇒ Object
:nodoc:.
-
#create_app_server_runner ⇒ Object
:nodoc:.
-
#create_driver ⇒ Object
:nodoc:.
-
#formatted_browser ⇒ Object
The browser formatted for the Selenese driver.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #new_logger ⇒ Object
-
#notify_after_driver_started(driver) ⇒ Object
Notify all after_driver_started callbacks.
-
#server_root ⇒ Object
The root directory (public) of the Rails application.
-
#stop_driver?(passed) ⇒ Boolean
:nodoc:.
-
#stop_driver_if_necessary(suite_passed) ⇒ Object
:nodoc:.
-
#suite_browser_mode ⇒ Object
Sets the Test Suite to use one browser instance.
-
#suite_browser_mode? ⇒ Boolean
Does the Test Suite to use one browser instance?.
-
#test_browser_mode ⇒ Object
Sets the Test Suite to open a new browser instance for each TestCase.
-
#test_browser_mode? ⇒ Boolean
Are we going to open a new browser instance for each TestCase?.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
109 110 111 112 113 |
# File 'lib/polonium/configuration.rb', line 109 def initialize self.verify_remote_app_server_is_running = true @after_driver_started_listeners = [] @app_server_initialization = proc {} end |
Class Attribute Details
.instance ⇒ Object
The instance of the Singleton Configuration. On its initial call, the initial configuration is set. The initial configuration is based on Environment variables and defaults. The environment variables are:
-
RAILS_ENV - The Rails environment (defaults: test)
-
selenium_server_host - The host name for the Selenium RC server (default: localhost)
-
selenium_server_port - The port for the Selenium RC server (default: 4444)
-
external_app_server_host - The host name that the Rails application server will start under (default: localhost)
-
external_app_server_port - The port that the Rails application server will start under (default: 4000)
-
app_server_engine - The type of server the application will be run with (webrick or mongrel)
-
internal_app_server_host - The host name for the Application server that the Browser will access (default: localhost)
-
internal_app_server_host - The port for the Application server that the Browser will access (default: 4000)
-
keep_browser_open_on_failure - If there is a failure in the test suite, keep the browser window open (default: false)
-
verify_remote_app_server_is_running - Raise an exception if the Application Server is not running (default: true)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/polonium/configuration.rb', line 32 def instance @instance ||= begin @instance = new @instance.env = ENV @instance.browser = FIREFOX @instance.selenium_server_host = '127.0.0.1' # address of selenium RC server (java) @instance.selenium_server_port = 4444 @instance.app_server_engine = :webrick @instance.internal_app_server_host = "0.0.0.0" # internal address of app server (webrick or mongrel) @instance.internal_app_server_port = 4000 @instance.external_app_server_host = '127.0.0.1' # external address of app server (webrick or mongrel) @instance.external_app_server_port = 4000 @instance.server_engine = :webrick @instance.keep_browser_open_on_failure = false @instance.browser_mode = BrowserMode::Suite @instance.verify_remote_app_server_is_running = true establish_environment @instance end end |
Instance Attribute Details
#app_server_engine ⇒ Object
Returns the value of attribute app_server_engine.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def app_server_engine @app_server_engine end |
#app_server_initialization ⇒ Object
Returns the value of attribute app_server_initialization.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def app_server_initialization @app_server_initialization end |
#app_server_runner ⇒ Object (readonly)
Returns the value of attribute app_server_runner.
197 198 199 |
# File 'lib/polonium/configuration.rb', line 197 def app_server_runner @app_server_runner end |
#browser ⇒ Object
Returns the value of attribute browser.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def browser @browser end |
#browser_mode ⇒ Object
Returns the value of attribute browser_mode.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def browser_mode @browser_mode end |
#driver ⇒ Object
The Driver object, which sublcasses the Driver provided by the Selenium RC (openqa.org/selenium-rc/) project.
163 164 165 |
# File 'lib/polonium/configuration.rb', line 163 def driver @driver end |
#env ⇒ Object
Returns the value of attribute env.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def env @env end |
#external_app_server_host ⇒ Object
Returns the value of attribute external_app_server_host.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def external_app_server_host @external_app_server_host end |
#external_app_server_port ⇒ Object
Returns the value of attribute external_app_server_port.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def external_app_server_port @external_app_server_port end |
#internal_app_server_host ⇒ Object
Returns the value of attribute internal_app_server_host.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def internal_app_server_host @internal_app_server_host end |
#internal_app_server_port ⇒ Object
Returns the value of attribute internal_app_server_port.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def internal_app_server_port @internal_app_server_port end |
#keep_browser_open_on_failure ⇒ Object
Returns the value of attribute keep_browser_open_on_failure.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def keep_browser_open_on_failure @keep_browser_open_on_failure end |
#rails_env ⇒ Object
Returns the value of attribute rails_env.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def rails_env @rails_env end |
#rails_root ⇒ Object
Returns the value of attribute rails_root.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def rails_root @rails_root end |
#selenium_server_host ⇒ Object
Returns the value of attribute selenium_server_host.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def selenium_server_host @selenium_server_host end |
#selenium_server_port ⇒ Object
Returns the value of attribute selenium_server_port.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def selenium_server_port @selenium_server_port end |
#server_engine ⇒ Object
Returns the value of attribute server_engine.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def server_engine @server_engine end |
#verify_remote_app_server_is_running ⇒ Object
Returns the value of attribute verify_remote_app_server_is_running.
89 90 91 |
# File 'lib/polonium/configuration.rb', line 89 def verify_remote_app_server_is_running @verify_remote_app_server_is_running end |
Instance Method Details
#after_driver_started(&block) ⇒ Object
A callback hook that gets run after the Selenese Interpreter is started.
116 117 118 |
# File 'lib/polonium/configuration.rb', line 116 def after_driver_started(&block) @after_driver_started_listeners << block end |
#browser_url ⇒ Object
The http host name and port to be entered into the browser address bar
133 134 135 |
# File 'lib/polonium/configuration.rb', line 133 def browser_url "http://#{external_app_server_host}:#{external_app_server_port}" end |
#create_and_initialize_driver ⇒ Object
:nodoc:
180 181 182 183 184 185 |
# File 'lib/polonium/configuration.rb', line 180 def create_and_initialize_driver #:nodoc: driver = create_driver driver.start notify_after_driver_started(driver) driver end |
#create_app_server_runner ⇒ Object
:nodoc:
198 199 200 201 202 |
# File 'lib/polonium/configuration.rb', line 198 def create_app_server_runner #:nodoc: app_server_type = SERVER_RUNNERS[@app_server_engine.to_sym] raise "Invalid server engine #{@app_server_engine}" unless app_server_type @app_server_runner = app_server_type.new(self) end |
#create_driver ⇒ Object
:nodoc:
187 188 189 190 191 192 193 194 195 |
# File 'lib/polonium/configuration.rb', line 187 def create_driver #:nodoc: return ::Polonium::Driver.new( selenium_server_host, selenium_server_port, formatted_browser, browser_url, 15000 ) end |
#formatted_browser ⇒ Object
The browser formatted for the Selenese driver.
128 129 130 |
# File 'lib/polonium/configuration.rb', line 128 def formatted_browser @browser.index('*') == 0 ? @browser : "*#{@browser}" end |
#new_logger ⇒ Object
204 205 206 |
# File 'lib/polonium/configuration.rb', line 204 def new_logger Logger.new(StringIO.new) end |
#notify_after_driver_started(driver) ⇒ Object
Notify all after_driver_started callbacks.
121 122 123 124 125 |
# File 'lib/polonium/configuration.rb', line 121 def notify_after_driver_started(driver) for listener in @after_driver_started_listeners listener.call(driver) end end |
#server_root ⇒ Object
The root directory (public) of the Rails application
138 139 140 |
# File 'lib/polonium/configuration.rb', line 138 def server_root File.("#{rails_root}/public/") end |
#stop_driver?(passed) ⇒ Boolean
:nodoc:
175 176 177 178 |
# File 'lib/polonium/configuration.rb', line 175 def stop_driver?(passed) #:nodoc: return true if passed return !keep_browser_open_on_failure end |
#stop_driver_if_necessary(suite_passed) ⇒ Object
:nodoc:
168 169 170 171 172 173 |
# File 'lib/polonium/configuration.rb', line 168 def stop_driver_if_necessary(suite_passed) #:nodoc: if @driver && stop_driver?(suite_passed) @driver.stop @driver = nil end end |
#suite_browser_mode ⇒ Object
Sets the Test Suite to use one browser instance
153 154 155 |
# File 'lib/polonium/configuration.rb', line 153 def suite_browser_mode @browser_mode = Configuration::BrowserMode::Suite end |
#suite_browser_mode? ⇒ Boolean
Does the Test Suite to use one browser instance?
158 159 160 |
# File 'lib/polonium/configuration.rb', line 158 def suite_browser_mode? @browser_mode == Configuration::BrowserMode::Suite end |
#test_browser_mode ⇒ Object
Sets the Test Suite to open a new browser instance for each TestCase
143 144 145 |
# File 'lib/polonium/configuration.rb', line 143 def test_browser_mode @browser_mode = Configuration::BrowserMode::Test end |
#test_browser_mode? ⇒ Boolean
Are we going to open a new browser instance for each TestCase?
148 149 150 |
# File 'lib/polonium/configuration.rb', line 148 def test_browser_mode? @browser_mode == Configuration::BrowserMode::Test end |