rspec-files 1.0.2 → 1.1.0
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/lib/rspec/files/leaks.rb +6 -3
- data/lib/rspec/files/version.rb +1 -1
- metadata +11 -33
- data/.editorconfig +0 -6
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.travis.yml +0 -19
- data/Gemfile +0 -4
- data/README.md +0 -95
- data/Rakefile +0 -6
- data/rspec-files.gemspec +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a57ef89fe557aa8a4f4835f33f098fd9fd80622332ec7c771393f25603317bec
|
4
|
+
data.tar.gz: 945faf4c968a80915c1d15be7a8244eed824c0c23484300e2780a738badd60d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f439683c0f001af66dd6a7873a066b354cf12860a552e59395a3ae1c635b723cd4c5d711acf734c671da44360d5eb887573e1652640a4f50cf660d51677972
|
7
|
+
data.tar.gz: 546190f6d23127763f282e5010b5f9c5a3952f42451473292730fa9fbfeb51217bc249e8c30595e14b431915e12316221e62fcf090cca459acdf6a3bdf7ea7ff
|
data/lib/rspec/files/leaks.rb
CHANGED
@@ -27,7 +27,7 @@ module RSpec
|
|
27
27
|
all_ios = ObjectSpace.each_object(::IO).to_a.sort_by(&:object_id)
|
28
28
|
|
29
29
|
# We are not interested in ios that have been closed already:
|
30
|
-
return all_ios.reject
|
30
|
+
return all_ios.reject(&:closed?)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -35,14 +35,17 @@ module RSpec
|
|
35
35
|
include Leaks
|
36
36
|
|
37
37
|
let(:before_ios) {current_ios}
|
38
|
-
let(:
|
38
|
+
let(:leaked_ios) {current_ios - before_ios}
|
39
39
|
|
40
40
|
# We use around(:each) because it's the highest priority.
|
41
41
|
around(:each) do |example|
|
42
|
+
# Here inspect is used to avoid reporting on handles that cannot
|
43
|
+
# be read from, as otherwise RSpec will attempt to test if they are
|
44
|
+
# readable and get stuck forever.
|
42
45
|
before_ios
|
43
46
|
|
44
47
|
example.run.tap do
|
45
|
-
expect(
|
48
|
+
expect(leaked_ios).to be_empty
|
46
49
|
end
|
47
50
|
end
|
48
51
|
end
|
data/lib/rspec/files/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: covered
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -52,43 +52,21 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
|
56
|
-
name: rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '10.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '10.0'
|
69
|
-
description:
|
55
|
+
description:
|
70
56
|
email:
|
71
|
-
- samuel.williams@oriontransfer.co.nz
|
72
57
|
executables: []
|
73
58
|
extensions: []
|
74
59
|
extra_rdoc_files: []
|
75
60
|
files:
|
76
|
-
- ".editorconfig"
|
77
|
-
- ".gitignore"
|
78
|
-
- ".rspec"
|
79
|
-
- ".travis.yml"
|
80
|
-
- Gemfile
|
81
|
-
- README.md
|
82
|
-
- Rakefile
|
83
61
|
- lib/rspec/files.rb
|
84
62
|
- lib/rspec/files/buffer.rb
|
85
63
|
- lib/rspec/files/leaks.rb
|
86
64
|
- lib/rspec/files/version.rb
|
87
|
-
- rspec-files.gemspec
|
88
65
|
homepage: https://github.com/socketry/rspec-files
|
89
|
-
licenses:
|
66
|
+
licenses:
|
67
|
+
- MIT
|
90
68
|
metadata: {}
|
91
|
-
post_install_message:
|
69
|
+
post_install_message:
|
92
70
|
rdoc_options: []
|
93
71
|
require_paths:
|
94
72
|
- lib
|
@@ -103,8 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
81
|
- !ruby/object:Gem::Version
|
104
82
|
version: '0'
|
105
83
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
107
|
-
signing_key:
|
84
|
+
rubygems_version: 3.1.2
|
85
|
+
signing_key:
|
108
86
|
specification_version: 4
|
109
87
|
summary: RSpec helpers for buffering and detecting file descriptor leaks.
|
110
88
|
test_files: []
|
data/.editorconfig
DELETED
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
|
4
|
-
matrix:
|
5
|
-
include:
|
6
|
-
- rvm: 2.3
|
7
|
-
- rvm: 2.4
|
8
|
-
- rvm: 2.5
|
9
|
-
- rvm: 2.6
|
10
|
-
- rvm: 2.6
|
11
|
-
env: COVERAGE=BriefSummary,Coveralls
|
12
|
-
- rvm: ruby-head
|
13
|
-
- rvm: jruby-head
|
14
|
-
env: JRUBY_OPTS="--debug -X+O"
|
15
|
-
- rvm: truffleruby
|
16
|
-
allow_failures:
|
17
|
-
- rvm: ruby-head
|
18
|
-
- rvm: jruby-head
|
19
|
-
- rvm: truffleruby
|
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
# RSpec::Files
|
2
|
-
|
3
|
-
Detect leaked file descriptors and provides convenient file buffers.
|
4
|
-
|
5
|
-
[](https://travis-ci.com/socketry/rspec-files)
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'rspec-files'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install rspec-files
|
22
|
-
|
23
|
-
Finally, add this require statement to the top of `spec/spec_helper.rb`
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
require 'rspec/files'
|
27
|
-
```
|
28
|
-
|
29
|
-
## Usage
|
30
|
-
|
31
|
-
### Leaks
|
32
|
-
|
33
|
-
Leaking sockets and other kinds of IOs are a problem for long running services. `RSpec::Files::Leaks` tracks all open sockets both before and after the spec. If any are left open, a `RuntimeError` is raised and the spec fails.
|
34
|
-
|
35
|
-
```ruby
|
36
|
-
RSpec.describe "leaky ios" do
|
37
|
-
include_context RSpec::Files::Leaks
|
38
|
-
|
39
|
-
# The following fails:
|
40
|
-
it "leaks io" do
|
41
|
-
@input, @output = IO.pipe
|
42
|
-
end
|
43
|
-
end
|
44
|
-
```
|
45
|
-
|
46
|
-
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.
|
47
|
-
|
48
|
-
### Buffers
|
49
|
-
|
50
|
-
File buffers are useful for specs which implement I/O operations. This context automatically manages a disk-based file which can be used for buffering.
|
51
|
-
|
52
|
-
```ruby
|
53
|
-
RSpec.describe "buffer" do
|
54
|
-
include_context RSpec::Files::Buffer
|
55
|
-
|
56
|
-
it "can read and write data" do
|
57
|
-
buffer.write("Hello World")
|
58
|
-
buffer.seek(0)
|
59
|
-
|
60
|
-
expect(buffer.read).to be == "Hello World"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
```
|
64
|
-
|
65
|
-
## Contributing
|
66
|
-
|
67
|
-
1. Fork it
|
68
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
69
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
70
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
71
|
-
5. Create new Pull Request
|
72
|
-
|
73
|
-
## License
|
74
|
-
|
75
|
-
Released under the MIT license.
|
76
|
-
|
77
|
-
Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
78
|
-
|
79
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
80
|
-
of this software and associated documentation files (the "Software"), to deal
|
81
|
-
in the Software without restriction, including without limitation the rights
|
82
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
83
|
-
copies of the Software, and to permit persons to whom the Software is
|
84
|
-
furnished to do so, subject to the following conditions:
|
85
|
-
|
86
|
-
The above copyright notice and this permission notice shall be included in
|
87
|
-
all copies or substantial portions of the Software.
|
88
|
-
|
89
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
90
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
91
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
92
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
93
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
94
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
95
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/rspec-files.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative 'lib/rspec/files/version'
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "rspec-files"
|
6
|
-
spec.version = RSpec::Files::VERSION
|
7
|
-
spec.authors = ["Samuel Williams"]
|
8
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
9
|
-
|
10
|
-
spec.summary = "RSpec helpers for buffering and detecting file descriptor leaks."
|
11
|
-
spec.homepage = "https://github.com/socketry/rspec-files"
|
12
|
-
|
13
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
14
|
-
f.match(%r{^(test|spec|features)/})
|
15
|
-
end
|
16
|
-
|
17
|
-
spec.require_paths = ["lib"]
|
18
|
-
|
19
|
-
spec.add_dependency "rspec", "~> 3.0"
|
20
|
-
|
21
|
-
spec.add_development_dependency "covered"
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
end
|