async-rspec 1.12.0 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +6 -0
- data/.travis.yml +5 -9
- data/README.md +23 -12
- data/async-rspec.gemspec +1 -0
- data/lib/async/rspec/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f433e1d62ca61d5912dbd87faa8b040bd0ae84f178f53da363c95b2e78ddab42
|
4
|
+
data.tar.gz: ae690667bbcdf40bab65fdf7555b1e066de9a3e38770e0e5aeec6c3659b34710
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f43505247ce2d331e5683c409c6cae1db98fd8b566471c3963dd65e11975126c100a1167689718efe81999c33b7c386dc3b78c2c0fdc47feeb9798eb49ef8e67
|
7
|
+
data.tar.gz: aca076025b7cedb20339bb2327caa648eca21915c6e6f7740880fb06131462efeb022cb8463f58305614d15e19325491e8cb58cd1e937c95eec6bea99046550e
|
data/.editorconfig
ADDED
data/.travis.yml
CHANGED
@@ -1,23 +1,19 @@
|
|
1
1
|
language: ruby
|
2
|
-
sudo: false
|
3
|
-
dist: trusty
|
4
2
|
cache: bundler
|
5
3
|
|
6
|
-
before_script:
|
7
|
-
- gem update --system
|
8
|
-
- gem install bundler
|
9
|
-
|
10
4
|
matrix:
|
11
5
|
include:
|
12
6
|
- rvm: 2.3
|
13
7
|
- rvm: 2.4
|
14
8
|
- rvm: 2.5
|
15
9
|
- rvm: 2.6
|
10
|
+
- rvm: 2.6
|
11
|
+
env: COVERAGE=BriefSummary,Coveralls
|
12
|
+
- rvm: ruby-head
|
16
13
|
- rvm: jruby-head
|
17
14
|
env: JRUBY_OPTS="--debug -X+O"
|
18
|
-
- rvm:
|
19
|
-
- rvm: rbx-3
|
15
|
+
- rvm: truffleruby
|
20
16
|
allow_failures:
|
21
17
|
- rvm: ruby-head
|
22
18
|
- rvm: jruby-head
|
23
|
-
- rvm:
|
19
|
+
- rvm: truffleruby
|
data/README.md
CHANGED
@@ -23,12 +23,18 @@ And then execute:
|
|
23
23
|
Or install it yourself as:
|
24
24
|
|
25
25
|
$ gem install async-rspec
|
26
|
+
|
27
|
+
Finally, add this require statement to the top of `spec/spec_helper.rb`
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'async/rspec'
|
31
|
+
```
|
26
32
|
|
27
33
|
## Usage
|
28
34
|
|
29
35
|
### Leaks
|
30
36
|
|
31
|
-
Leaking sockets and other kinds of IOs
|
37
|
+
Leaking sockets and other kinds of IOs are a problem for long running services. `Async::RSpec::Leaks` tracks all open sockets both before and after the spec. If any are left open, a `RuntimeError` is raised and the spec fails.
|
32
38
|
|
33
39
|
```ruby
|
34
40
|
RSpec.describe "leaky ios" do
|
@@ -41,7 +47,7 @@ RSpec.describe "leaky ios" do
|
|
41
47
|
end
|
42
48
|
```
|
43
49
|
|
44
|
-
In some cases, the Ruby garbage collector will close IOs. In the above case, it's possible
|
50
|
+
In some cases, the Ruby garbage collector will close IOs. In the above case, it's possible that just writing `IO.pipe` will not leak as Ruby will garbage collect the resulting IOs immediately. It's still incorrect to not close IOs, so don't depend on this behaviour.
|
45
51
|
|
46
52
|
### Allocations
|
47
53
|
|
@@ -60,42 +66,47 @@ RSpec.describe "memory allocations" do
|
|
60
66
|
it "limits allocation counts (hash)" do
|
61
67
|
expect do
|
62
68
|
6.times{String.new}
|
63
|
-
end.to limit_allocations(String => {
|
69
|
+
end.to limit_allocations(String => {count: 10}) # 10 strings can be allocated
|
64
70
|
end
|
65
71
|
|
66
72
|
it "limits allocation size" do
|
67
73
|
expect do
|
68
74
|
6.times{String.new("foo")}
|
69
|
-
end.to limit_allocations(String => {
|
75
|
+
end.to limit_allocations(String => {size: 1024}) # 1 KB of strings can be allocated
|
70
76
|
end
|
71
77
|
end
|
72
78
|
```
|
73
79
|
|
74
80
|
### Reactor
|
75
81
|
|
76
|
-
Many specs need to run within a reactor. A shared context is provided which includes all the relevant bits, including the above leaks checks.
|
82
|
+
Many specs need to run within a reactor. A shared context is provided which includes all the relevant bits, including the above leaks checks. If your spec fails to run in less than 10 seconds, an `Async::TimeoutError` raises to prevent your test suite from hanging.
|
77
83
|
|
78
84
|
```ruby
|
79
|
-
|
85
|
+
require 'async/io'
|
86
|
+
|
87
|
+
RSpec.describe Async::IO do
|
80
88
|
include_context Async::RSpec::Reactor
|
81
89
|
|
82
90
|
let(:pipe) {IO.pipe}
|
83
|
-
let(:input) {pipe.
|
84
|
-
let(:output) {pipe.
|
91
|
+
let(:input) {Async::IO::Generic.new(pipe.first)}
|
92
|
+
let(:output) {Async::IO::Generic.new(pipe.last)}
|
85
93
|
|
86
94
|
it "should send and receive data within the same reactor" do
|
87
95
|
message = nil
|
88
96
|
|
89
|
-
output_task = reactor.
|
90
|
-
message =
|
97
|
+
output_task = reactor.async do
|
98
|
+
message = input.read(1024)
|
91
99
|
end
|
92
100
|
|
93
|
-
reactor.
|
94
|
-
|
101
|
+
reactor.async do
|
102
|
+
output.write("Hello World")
|
95
103
|
end
|
96
104
|
|
97
105
|
output_task.wait
|
98
106
|
expect(message).to be == "Hello World"
|
107
|
+
|
108
|
+
input.close
|
109
|
+
output.close
|
99
110
|
end
|
100
111
|
end
|
101
112
|
```
|
data/async-rspec.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
# Since we test the shared contexts, we need some bits of async:
|
22
22
|
spec.add_development_dependency "async", "~> 1.8"
|
23
23
|
|
24
|
+
spec.add_development_dependency "covered"
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.13"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
27
|
end
|
data/lib/async/rspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: covered
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +87,7 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
90
|
+
- ".editorconfig"
|
76
91
|
- ".gitignore"
|
77
92
|
- ".rspec"
|
78
93
|
- ".travis.yml"
|
@@ -108,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
123
|
- !ruby/object:Gem::Version
|
109
124
|
version: '0'
|
110
125
|
requirements: []
|
111
|
-
|
112
|
-
rubygems_version: 2.7.7
|
126
|
+
rubygems_version: 3.0.2
|
113
127
|
signing_key:
|
114
128
|
specification_version: 4
|
115
129
|
summary: Helpers for writing specs against the async gem.
|