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