Sha256: a85757b546db911aa5606070218cf10a015c4b75dbca4971ee0c9a73e5b6c3f4

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

require "webrat/selenium/application_servers/base"

module Webrat
  module Selenium
    module ApplicationServers
      class Rack < Webrat::Selenium::ApplicationServers::Base

        def start
          @pid = fork do
            if File.exist?("log")
              redirect_io(STDOUT, File.join("log", "webrat.webrick.stdout.log"))
              redirect_io(STDERR, File.join("log", "webrat.webrick.stderr.log"))
            end
            exec start_command
          end
        end

        def stop
          Process.kill("INT", @pid)
        end

        def fail
          $stderr.puts
          $stderr.puts
          $stderr.puts "==> Failed to boot the application server... exiting!"
          $stderr.puts
          $stderr.puts "Verify you can start a server on port #{Webrat.configuration.application_port} with the following command:"
          $stderr.puts
          $stderr.puts "    #{start_command}"
          exit
        end

        def start_command
          "#{bundler} rackup -s webrick --port #{Webrat.configuration.application_port} --env #{Webrat.configuration.application_environment}".strip
        end

      private

        def bundler
          File.exist?("./Gemfile") ? "bundle exec " : ""
        end

        def redirect_io(io, path)
          File.open(path, 'ab') { |fp| io.reopen(fp) } if path
          io.sync = true
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
radiant-1.0.0 ruby-debug/ruby/1.8/gems/webrat-0.7.3/lib/webrat/selenium/application_servers/rack.rb
indirect-webrat-0.7.5 lib/webrat/selenium/application_servers/rack.rb
indirect-webrat-0.7.4 lib/webrat/selenium/application_servers/rack.rb
webrat-0.7.3 lib/webrat/selenium/application_servers/rack.rb
jbd-webrat-0.7.2.rails3 lib/webrat/selenium/application_servers/rack.rb
webrat-0.7.2 lib/webrat/selenium/application_servers/rack.rb
webrat-0.7.2.beta.2 lib/webrat/selenium/application_servers/rack.rb