Sha256: e75f23c02613ed83e47dea76aad11b2b601a385bec1baa33d513594656c6cc46

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 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

class Spec::ExampleGroup
  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

1 entries across 1 versions & 1 rubygems

Version Path
screw-unit-0.3.3 spec/functional/functional_spec_helper.rb