spec/defer_spec.rb in libuv-0.11.5 vs spec/defer_spec.rb in libuv-0.11.7
- old
+ new
@@ -28,11 +28,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:foo]
+ expect(@log).to eq([:foo])
end
it "should be able to resolve the callback after it has already been resolved" do
@@ -50,11 +50,11 @@
@loop.next_tick do
@loop.stop
end
end
}
- @log.should == [:foo, :foo]
+ expect(@log).to eq([:foo, :foo])
end
it "should fulfill success callbacks in the registration order" do
@@ -71,19 +71,19 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:first, :second]
+ expect(@log).to eq([:first, :second])
end
it "should do nothing if a promise was previously resolved" do
@loop.run {
@promise.then nil, @default_fail do |result|
@log << result
- @log.should == [:foo]
+ expect(@log).to eq([:foo])
@deferred.resolve(:bar)
end
@deferred.resolve(:foo)
@deferred.reject(:baz)
@@ -99,11 +99,11 @@
end
end
end
end
}
- @log.should == [:foo]
+ expect(@log).to eq([:foo])
end
it "should allow deferred resolution with a new promise" do
deferred2 = @loop.defer
@@ -114,11 +114,11 @@
end
@deferred.resolve(deferred2.promise)
deferred2.resolve(:foo)
}
- @log.should == [:foo]
+ expect(@log).to eq([:foo])
end
it "should not break if a callbacks registers another callback" do
@loop.run {
@@ -136,11 +136,11 @@
@loop.stop
end
end
}
- @log.should == [:outer, :inner]
+ expect(@log).to eq([:outer, :inner])
end
it "can modify the result of a promise before returning" do
@@ -156,11 +156,11 @@
@log << greeting
@loop.stop
end
}
- @log.should == ['Hello Robin Hood', 'Hello Robin Hood?']
+ expect(@log).to eq(['Hello Robin Hood', 'Hello Robin Hood?'])
end
end
@@ -179,11 +179,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:first, :second]
+ expect(@log).to eq([:first, :second])
end
it "should do nothing if a promise was previously rejected" do
@loop.run {
@@ -206,11 +206,11 @@
end
end
end
end
}
- @log.should == [:baz]
+ expect(@log).to eq([:baz])
end
it "should not defer rejection with a new promise" do
deferred2 = @loop.defer
@@ -222,11 +222,11 @@
@log << e.is_a?(ArgumentError)
@loop.stop
end
}
- @log.should == [true]
+ expect(@log).to eq([true])
end
end
@@ -246,11 +246,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:first, :second]
+ expect(@log).to eq([:first, :second])
end
it "should do nothing if a promise was previously resolved" do
@loop.run {
@@ -274,11 +274,11 @@
end
end
end
}
- @log.should == []
+ expect(@log).to eq([])
end
it "should do nothing if a promise was previously rejected" do
@loop.run {
@@ -302,11 +302,11 @@
end
end
end
}
- @log.should == []
+ expect(@log).to eq([])
end
it "should not apply any special treatment to promises passed to notify" do
@loop.run {
@@ -320,11 +320,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [true]
+ expect(@log).to eq([true])
end
it "should call the progress callbacks in the next turn" do
@loop.run {
@@ -340,11 +340,11 @@
@log << @log.length # Has notify run in this tick
@loop.stop # Stop will run through the next tick before stopping
}
- @log.should == [0, :first, :second]
+ expect(@log).to eq([0, :first, :second])
end
it "should ignore notifications sent out in the same turn before listener registration" do
@loop.run {
@deferred.notify(:foo)
@@ -360,11 +360,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == []
+ expect(@log).to eq([])
end
end
describe Libuv::Q::Promise do
@@ -382,11 +382,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:foo]
+ expect(@log).to eq([:foo])
end
it "should allow registration of a success callback without an errback and reject" do
@loop.run {
@@ -399,11 +399,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == []
+ expect(@log).to eq([])
end
it "should allow registration of an errback without a success callback and reject" do
@loop.run {
@@ -416,11 +416,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:foo]
+ expect(@log).to eq([:foo])
end
it "should allow registration of an errback without a success callback and resolve" do
@loop.run {
@@ -433,11 +433,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == []
+ expect(@log).to eq([])
end
it "should resolve all callbacks with the original value" do
@loop.run {
@@ -463,11 +463,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:foo, :foo, :foo, :foo]
+ expect(@log).to eq([:foo, :foo, :foo, :foo])
end
it "should notify all callbacks with the original value" do
@loop.run { |loop_promise|
@@ -502,11 +502,11 @@
end
end
end
}
- @log.should == [:foo, :foo, :foo, :foo]
+ expect(@log).to eq([:foo, :foo, :foo, :foo])
end
it "should reject all callbacks with the original reason" do
@loop.run {
@@ -532,11 +532,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:foo, :foo, :foo, :foo]
+ expect(@log).to eq([:foo, :foo, :foo, :foo])
end
it "should propagate resolution and rejection between dependent promises" do
@loop.run {
@@ -571,11 +571,11 @@
end
end
end
}
- @log.should == [:foo, :bar, 'baz', 'bob', :done]
+ expect(@log).to eq([:foo, :bar, 'baz', 'bob', :done])
end
it "should propagate notification between dependent promises" do
@loop.run { |loop_promise|
@@ -617,11 +617,11 @@
end
end
end
}
- @log.should == [:foo, :bar, :bar, :bar, :done]
+ expect(@log).to eq([:foo, :bar, :bar, :bar, :done])
end
it "should stop notification propagation in case of error" do
@loop.run { |loop_logger|
@@ -662,11 +662,11 @@
end
end
end
}
- @log.should == [:foo, :bar, :q_progress_cb]
+ expect(@log).to eq([:foo, :bar, :q_progress_cb])
end
it "should call error callback in the next turn even if promise is already rejected" do
@loop.run {
@@ -679,11 +679,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:foo]
+ expect(@log).to eq([:foo])
end
end
@@ -703,11 +703,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [:finally]
+ expect(@log).to eq([:finally])
end
it "should fulfill with the original value" do
@loop.run {
@promise.finally(proc {
@@ -725,11 +725,11 @@
@loop.stop
end
end
}
- @log.should == [:finally, :foo]
+ expect(@log).to eq([:finally, :foo])
end
it "should fulfill with the original value (larger test)" do
@loop.run {
@promise.then(proc { |result|
@@ -773,11 +773,11 @@
end
end
end
}
- @log.should == [:foo, :finally, :foo, :change, :finally, :change]
+ expect(@log).to eq([:foo, :finally, :foo, :change, :finally, :change])
end
describe "when the callback throws an exception" do
it "should reject with this new exception" do
@loop.run {
@@ -795,11 +795,11 @@
@loop.stop
end
end
}
- @log.should == [:finally, true]
+ expect(@log).to eq([:finally, true])
end
end
describe "when the callback returns a promise" do
it "should fulfill with the original reason after that promise resolves" do
@@ -830,11 +830,11 @@
end
end
end
}
- @log.should == [:finally, :resolving, :foo]
+ expect(@log).to eq([:finally, :resolving, :foo])
end
it "should reject with the new reason when it is rejected" do
@loop.run {
@@ -864,11 +864,11 @@
end
end
end
}
- @log.should == [:finally, :rejecting, :rejected]
+ expect(@log).to eq([:finally, :rejecting, :rejected])
end
end
end
@@ -893,11 +893,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == ['not gonna happen']
+ expect(@log).to eq(['not gonna happen'])
end
it "should return a promise that forwards callbacks if the callbacks are missing" do
@loop.run {
@@ -914,11 +914,11 @@
@loop.stop
end
end
}
- @log.should == ['not gonna happen']
+ expect(@log).to eq(['not gonna happen'])
end
end
@@ -934,11 +934,11 @@
@loop.next_tick do
@loop.stop
end
}
- @log.should == [[]]
+ expect(@log).to eq([[]])
end
it "should take an array of promises and return a promise for an array of results" do
@loop.run {
deferred1 = @loop.defer
@@ -952,11 +952,11 @@
@loop.work { @deferred.resolve(:foo) }
@loop.work { deferred2.resolve(:baz) }
@loop.work { deferred1.resolve(:bar) }
}
- @log.should == [:foo, :bar, :baz]
+ expect(@log).to eq([:foo, :bar, :baz])
end
it "should reject the derived promise if at least one of the promises in the array is rejected" do
@loop.run {
@@ -970,10 +970,10 @@
@loop.work { @deferred.resolve(:foo) }
@loop.work { deferred2.reject(:baz) }
}
- @log.should == [:baz]
+ expect(@log).to eq([:baz])
end
end
end