Sha256: dc7308c5e01365da07259c4f003ac819b66c8ca9cdfa000572d5228a5bfda298

Contents?: true

Size: 997 Bytes

Versions: 3

Compression:

Stored size: 997 Bytes

Contents

require 'scales-core'

Scales.env = "test"

module Helpers
  
  def async
    if EM.reactor_running?
      yield
    else
      out = nil
      EM.synchrony do
        out = yield
        EM.stop
      end
      out
    end
  end
  
  def fixture(file)
    File.read(File.expand_path("../fixtures/#{file}", __FILE__))
  end
  
  def in_app_folder
    pwd = Dir.pwd
    Dir.chdir File.expand_path("../../../spec/app", __FILE__)
    yield
    Dir.chdir(pwd)
  end
  
  def in_temp_folder
    pwd = Dir.pwd
    Dir.mkdir "spec/tmp"
    Dir.chdir "spec/tmp"
    begin
      yield
    rescue Exception => e
      raise e
    ensure
      Dir.chdir(pwd)
      FileUtils.rm_rf("spec/tmp")
    end
  end
  
  def squeeze string
    string.gsub(/(\n|\t|\r)/, ' ').gsub(/>\s*</, '><').squeeze(' ').strip
  end
  
end

RSpec.configure do |config|
  config.include Helpers
  config.treat_symbols_as_metadata_keys_with_true_values = true
  config.before(:suite) do
    Scales::Storage::Sync.flushall!
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scales-core-0.0.4 spec/helper.rb
scales-core-0.0.1.beta.2 spec/helper.rb
scales-core-0.0.1.beta.1 spec/helper.rb