Sha256: f553c0220f857fa0de080b0117da01cca16062ca01059bb9bfbbdf8d263364cd

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

require "opal-rspec"
require "opal-pouchdb"

def with_new_database(add_failure_handler = true)
  database_name = "test_opal_pouchdb_database-#{rand(1337)}-#{rand(7331)}"
  promise = yield PouchDB::Database.new(name: database_name)

  if add_failure_handler
    promise = promise.fail do |error|
      run_async do
        fail error
      end
    end
  end

  promise.always do
    destroy_database(database_name)
  end
end

def destroy_database(name)
  %x{
      var db = new PouchDB(name);
      db.destroy()
    }
end

def delayed(delay_by, &blk)
  promise = Promise.new
  $global.setTimeout(-> { blk.call(promise) }, delay_by * 1000)
  promise
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-pouchdb-0.1.1 spec/spec_helper.rb