Skip to content

Commit 2581b07

Browse files
committed
Improve sync+async test reporting
Wrap all example executions in a promise to avoid awkward pauses in result reporting with a mix of sync/async tests
1 parent 75920ef commit 2581b07

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* Arity checking enabled by default
66
* Dropped support for PhantomJS < 2.0
77

8+
## 0.5.1
9+
* Wrap all example executions in a promise to avoid awkward pauses in result reporting with a mix of sync/async tests
10+
811
## 0.5.0 (2015-12-08)
912

1013
* By default, any subject, it example block, before(:each), after(:each), and around that returns a promise will be executed asynchronously. Async is NOT yet supported for context level hooks. Async approach from < 0.4.3 will still work.

opal/opal/rspec/async/async_example.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
class ::RSpec::Core::Example
22
def core_block_run
3-
example_promise = Promise.value(@example_group_instance.instance_exec(self, &@example_block))
4-
example_promise.then do |result|
5-
result
6-
end.rescue do |ex|
7-
ex ||= Exception.new 'Async promise failed for unspecified reason'
8-
ex = Exception.new ex unless ex.kind_of?(Exception)
9-
ex
3+
# Use EG's method to avoid awkward pauses in result reporting with mix of sync/async examples
4+
@example_group_instance.delay_with_promise 0 do
5+
example_promise = Promise.value(@example_group_instance.instance_exec(self, &@example_block))
6+
example_promise.then do |result|
7+
result
8+
end.rescue do |ex|
9+
ex ||= Exception.new 'Async promise failed for unspecified reason'
10+
ex = Exception.new ex unless ex.kind_of?(Exception)
11+
ex
12+
end
1013
end
1114
end
1215

0 commit comments

Comments
 (0)