opal-rspec 0.3.0.beta2 → 0.3.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/lib/opal/rspec/version.rb +1 -1
- data/opal/opal/rspec/async.rb +32 -7
- data/spec/async_spec.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84230cf1d8509f28c633e0e882d33c09f1246b24
|
4
|
+
data.tar.gz: aec3b03f1a636f28f306cac7fda0dc96a1315d93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cdd2b63ace9e719b2c96af8e81120086c7840d5169b5691732bdd71b56b84731cfeb6d4a07abb4bd4ff6f6d4e984b802b00bdd7b0f66015e617a4041bc0d1ca
|
7
|
+
data.tar.gz: fa734e9b5618dc8d10944f253f6028d1e7850223b2919d44b32677bea6f53dbd42de1b04c09623bdd420958b1553148a1250642b36d1f4d099da1fb26ee12ea9
|
data/CHANGELOG.md
CHANGED
data/lib/opal/rspec/version.rb
CHANGED
data/opal/opal/rspec/async.rb
CHANGED
@@ -8,14 +8,18 @@ module Opal
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module AsyncHelpers
|
11
|
-
def
|
12
|
-
|
11
|
+
def async(&block)
|
12
|
+
@example.continue_async(block)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
alias run_async async
|
16
|
+
|
17
|
+
def delay(duration, &block)
|
18
|
+
`setTimeout(block, duration * 1000)`
|
17
19
|
self
|
18
20
|
end
|
21
|
+
|
22
|
+
alias set_timeout delay
|
19
23
|
end
|
20
24
|
|
21
25
|
class AsyncRunner
|
@@ -70,14 +74,18 @@ module Opal
|
|
70
74
|
@examples ||= []
|
71
75
|
end
|
72
76
|
|
77
|
+
include AsyncHelpers
|
78
|
+
|
73
79
|
def run(example_group_instance, reporter, &after_run_block)
|
74
80
|
@example_group_instance = example_group_instance
|
75
|
-
@reporter
|
76
|
-
@after_run_block
|
81
|
+
@reporter = reporter
|
82
|
+
@after_run_block = after_run_block
|
83
|
+
@finished = false
|
77
84
|
|
78
85
|
should_wait = true
|
79
86
|
|
80
87
|
::RSpec.current_example = self
|
88
|
+
example_group_instance.instance_variable_set :@example, self
|
81
89
|
|
82
90
|
start(reporter)
|
83
91
|
|
@@ -89,10 +97,21 @@ module Opal
|
|
89
97
|
should_wait = false
|
90
98
|
end
|
91
99
|
|
92
|
-
|
100
|
+
if should_wait
|
101
|
+
delay options[:timeout] || 10 do
|
102
|
+
next if finished?
|
103
|
+
|
104
|
+
set_exception RuntimeError.new("timeout")
|
105
|
+
async_example_finished
|
106
|
+
end
|
107
|
+
else
|
108
|
+
async_example_finished
|
109
|
+
end
|
93
110
|
end
|
94
111
|
|
95
112
|
def continue_async(block)
|
113
|
+
return if finished?
|
114
|
+
|
96
115
|
begin
|
97
116
|
block.call
|
98
117
|
rescue Exception => e
|
@@ -102,7 +121,13 @@ module Opal
|
|
102
121
|
async_example_finished
|
103
122
|
end
|
104
123
|
|
124
|
+
def finished?
|
125
|
+
@finished
|
126
|
+
end
|
127
|
+
|
105
128
|
def async_example_finished
|
129
|
+
@finished = true
|
130
|
+
|
106
131
|
begin
|
107
132
|
run_after_each
|
108
133
|
rescue Exception => e
|
data/spec/async_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe "Asynchronous helpers" do
|
|
22
22
|
async "can finish running after a long delay" do
|
23
23
|
obj = [1, 2, 3, 4]
|
24
24
|
|
25
|
-
|
25
|
+
delay(1) do
|
26
26
|
run_async { obj.should == [1, 2, 3, 4] }
|
27
27
|
end
|
28
28
|
end
|
@@ -32,7 +32,7 @@ describe "Asynchronous helpers" do
|
|
32
32
|
expect(:foo).to eq(:baz)
|
33
33
|
}.to raise_error(Exception)
|
34
34
|
|
35
|
-
|
35
|
+
delay(0) do
|
36
36
|
run_async { expect(42).to eq(42) }
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0.
|
4
|
+
version: 0.3.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: 1.3.1
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.0.3
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: RSpec for Opal
|