Sha256: 9124ca6e73417e1e8e278b5e1699a51cb49b854cb5206d09eac72438b41bf306
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
require 'spec_helper' def count_occurences(str, find) count = 0 loop do index = str.index(find) break unless index count += 1 str = str[index+1..-1] end count end describe Promise do it 'should allow you to call methods that will be called on the resolved value and return a new promise' do a = Promise.new.resolve(5) float_promise = a.to_f expect(float_promise.class).to eq(Promise) float_promise.then do |val| expect(val).to eq(5) end end it 'should patch inspect on Promise so that nested Promise are shown as a single promise' do a = Promise.new b = Promise.new.then { a } a.resolve(1) b.resolve(2) # There is currently an infinity loop in scan in opal. # https://github.com/opal/opal/issues/457 # TODO: Remove when opal 0.8 comes out. # expect(b.inspect.scan('Promise').size).to eq(1) expect(count_occurences(b.inspect, 'Promise')).to eq(1) end it 'should not respond to comparitors' do [:>, :<].each do |comp| a = Promise.new expect do a.send(comp, 5) end.to raise_error(NoMethodError) end end it 'should proxy methods on promises' do a = Promise.new expect do a.something end.not_to raise_error end end
Version data entries
5 entries across 5 versions & 1 rubygems