Sha256: 8c4dbe79866df54a06ef5190f6921183f8ffbc94c71f84f82bbf3f6f208f1d84

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

require 'opal/rspec/async'

<% if ENV['OPAL_BROWSER_PROMISE'] == 'v2' || Opal::VERSION.to_f >= 1.6 %>
  require 'promise'
  require 'promise/v2'
<% else %>
  require 'promise'

  # Polyfill #to_v1, which isn't present before Opal v1.3.0
  class Promise
    unless Promise.method_defined? :to_v1
      alias to_v1 itself
    end
  end
<% end %>

require 'browser/utils'

module Browser
  class Promise
    # Return a correct promise for opal-rspec, which for RSpec
    # < 1.0 is PromiseV1, and for >= 1.0 is PromiseV2.
    def for_rspec
      <% if Opal::RSpec::VERSION.to_f >= 1.0 %>
        to_v2
      <% else %>
        to_v1
      <% end %>
    end
  end
end

Opal::RSpec::VERSION = <%= Opal::RSpec::VERSION.inspect %> unless defined? Opal::RSpec::VERSION

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-browser-0.3.5 spec/spec_helper_promise.rb.erb
opal-browser-0.3.4 spec/spec_helper_promise.rb.erb