Class: JsSpec::Resources::Runners::FirefoxRunner
- Inherits:
-
Object
- Object
- JsSpec::Resources::Runners::FirefoxRunner
- Includes:
- FileUtils
- Defined in:
- lib/js_spec/resources/runners/firefox_runner.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#profile_dir ⇒ Object
readonly
Returns the value of attribute profile_dir.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #finalize(text) ⇒ Object
-
#initialize(request, response) ⇒ FirefoxRunner
constructor
A new instance of FirefoxRunner.
- #post(request, response) ⇒ Object
Constructor Details
#initialize(request, response) ⇒ FirefoxRunner
Returns a new instance of FirefoxRunner.
24 25 26 27 28 29 30 31 32 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 24 def initialize(request, response) profile_base = "#{::Dir.tmpdir}/js_spec/firefox" mkdir_p profile_base @profile_dir = "#{profile_base}/#{Time.now.to_i}" @guid = UUID.new @request = request @response = response @connection = Server.connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
22 23 24 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 22 def connection @connection end |
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
22 23 24 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 22 def driver @driver end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
22 23 24 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 22 def guid @guid end |
#profile_dir ⇒ Object (readonly)
Returns the value of attribute profile_dir.
22 23 24 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 22 def profile_dir @profile_dir end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
22 23 24 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 22 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
22 23 24 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 22 def response @response end |
Class Method Details
.register_instance(runner) ⇒ Object
11 12 13 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 11 def register_instance(runner) instances[runner.guid] = runner end |
.resume(guid, text) ⇒ Object
6 7 8 9 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 6 def resume(guid, text) runner = instances.delete(guid) runner.finalize(text) end |
Instance Method Details
#finalize(text) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 52 def finalize(text) driver.stop response.status = 200 response.body = text connection.send_response(*response.finish) end |
#post(request, response) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/js_spec/resources/runners/firefox_runner.rb', line 34 def post(request, response) FirefoxRunner.register_instance self spec_url = (request && request['spec_url']) ? request['spec_url'] : spec_suite_url parsed_spec_url = URI.parse(spec_url) @driver = Selenium::SeleniumDriver.new( request['selenium_host'] || 'localhost', (request['selenium_port'] || 4444).to_i, '*firefox', "#{parsed_spec_url.scheme}://#{parsed_spec_url.host}:#{parsed_spec_url.port}" ) driver.start Thread.start do url = "#{spec_url}?guid=#{guid}" driver.open(url) end response.status = nil end |