Sha256: df4e4bb09b347602079be23bffd08b4b92988ff4e5a436e009f5fcc006a61dfa

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

require "rubygems"
require "spec"

dir = File.dirname(__FILE__)
$LOAD_PATH.unshift "#{dir}/../../lib"
require "screw_unit"
require "hpricot"
require "lsof"

Spec::Runner.configure do |config|
  config.mock_with :rr
end

Thin::Logging.silent = false
Thin::Logging.debug = true

module WaitFor
  extend self
  def wait_for(time=5)
    Timeout.timeout(time) do
      loop do
        value = yield
        return value if value
      end
    end
  end
end

module Spec::Example::ExampleMethods
  include WaitFor
  attr_reader :spec_root_path, :implementation_root_path, :public_path
  before(:all) do
    Lsof.kill(8080)
    wait_for do
      !Lsof.running?(8080)
    end
    dir = File.dirname(__FILE__)
    @spec_root_path = "#{dir}/../example_specs"
    @public_path = "#{dir}/../example_public"
    @implementation_root_path = "#{public_path}/javascripts"
    unless $screw_unit_server_started
      Thread.start do
        ScrewUnit::Server.run(spec_root_path, implementation_root_path, public_path)
      end
      $screw_unit_server_started = true
    end
    wait_for do
      Lsof.running?(8080)
    end
  end

  def root_url
    "http://#{ScrewUnit::DEFAULT_HOST}:#{ScrewUnit::DEFAULT_PORT}"
  end
end

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
btakita-screw-unit-server-0.3.0 spec/functional/functional_spec_helper.rb
btakita-screw_unit-0.1.0 spec/functional/functional_spec_helper.rb
btakita-screw_unit-0.3.0 spec/functional/functional_spec_helper.rb
screw-unit-0.3.1 spec/functional/functional_spec_helper.rb
screw-unit-server-0.3.0 spec/functional/functional_spec_helper.rb