rspec-files 1.0.2 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f042fcdc5daea3efa16c9ba11105e0c6d741397d6e5efab694e139b324383e36
4
- data.tar.gz: 4509456eab4a81bb802da35549d340576332b9465674e5e60dc8c2c7bf0bc716
3
+ metadata.gz: 8189a3a251f6d5826050d37894fc5f0b7e4fa2bd11a268f47202452d028d3d68
4
+ data.tar.gz: d7e38ba998be441f151a652bea0a3b3c8d19ce2e8a6cbc104b2545cc0f8617df
5
5
  SHA512:
6
- metadata.gz: d590a98f1f8ca3d6843d11676221c9b388930ead5c0d663b6163eb67baf20c78dcc1d511f36da03308ad0785c5c718540b6196fb681f982554059776f9faeb27
7
- data.tar.gz: 4e84fdc62929d7dcb1f7254e00e9917fbdb8ff1355b4828b1d65910f0f91ee3f1d487cb5de0c3192a056a983c30ba0847ab51485d53733231f609e2dfbd861e8
6
+ metadata.gz: 1683a7b03a2ac426df45a54dc390615d4a3925b86ac2aa7e41456f345d2e19dbf5a69bda1d486a23cccf6f9cf85aece71fc9d3b6a3ae61d79dc72b7ee3235245
7
+ data.tar.gz: 3b679dfc4500a0d0249aeee86dde489163487430ec708489cfc0b77646cd1cc22ac31ae28d39f56553dc4271bca1451a6b8a62999a9d10b78552c2bddffd1f48
@@ -27,7 +27,12 @@ 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{|io| io.closed?}
30
+ return all_ios.reject(&:closed?)
31
+ rescue RuntimeError => error
32
+ # This occurs on JRuby.
33
+ warn error.message
34
+
35
+ return []
31
36
  end
32
37
  end
33
38
 
@@ -35,14 +40,17 @@ module RSpec
35
40
  include Leaks
36
41
 
37
42
  let(:before_ios) {current_ios}
38
- let(:after_ios) {current_ios}
43
+ let(:leaked_ios) {current_ios - before_ios}
39
44
 
40
45
  # We use around(:each) because it's the highest priority.
41
46
  around(:each) do |example|
47
+ # Here inspect is used to avoid reporting on handles that cannot
48
+ # be read from, as otherwise RSpec will attempt to test if they are
49
+ # readable and get stuck forever.
42
50
  before_ios
43
51
 
44
52
  example.run.tap do
45
- expect(after_ios).to be == before_ios
53
+ expect(leaked_ios).to be_empty
46
54
  end
47
55
  end
48
56
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module RSpec
22
22
  module Files
23
- VERSION = "1.0.2"
23
+ VERSION = "1.1.2"
24
24
  end
25
25
  end
data/lib/rspec/files.rb CHANGED
@@ -18,6 +18,8 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
+ require 'rspec/core'
22
+
21
23
  require_relative "files/version"
22
24
  require_relative "files/leaks"
23
25
  require_relative "files/buffer"
metadata CHANGED
@@ -1,14 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-files
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
- autorequire:
8
+ - Scott Tadman
9
+ - Cyril Roelandt
10
+ - Gleb Sinyavskiy
11
+ - Olle Jonsson
12
+ autorequire:
9
13
  bindir: bin
10
14
  cert_chain: []
11
- date: 2019-09-06 00:00:00.000000000 Z
15
+ date: 2022-06-03 00:00:00.000000000 Z
12
16
  dependencies:
13
17
  - !ruby/object:Gem::Dependency
14
18
  name: rspec
@@ -25,7 +29,7 @@ dependencies:
25
29
  - !ruby/object:Gem::Version
26
30
  version: '3.0'
27
31
  - !ruby/object:Gem::Dependency
28
- name: covered
32
+ name: bundler
29
33
  requirement: !ruby/object:Gem::Requirement
30
34
  requirements:
31
35
  - - ">="
@@ -39,7 +43,7 @@ dependencies:
39
43
  - !ruby/object:Gem::Version
40
44
  version: '0'
41
45
  - !ruby/object:Gem::Dependency
42
- name: bundler
46
+ name: covered
43
47
  requirement: !ruby/object:Gem::Requirement
44
48
  requirements:
45
49
  - - ">="
@@ -52,43 +56,21 @@ dependencies:
52
56
  - - ">="
53
57
  - !ruby/object:Gem::Version
54
58
  version: '0'
55
- - !ruby/object:Gem::Dependency
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:
59
+ description:
70
60
  email:
71
- - samuel.williams@oriontransfer.co.nz
72
61
  executables: []
73
62
  extensions: []
74
63
  extra_rdoc_files: []
75
64
  files:
76
- - ".editorconfig"
77
- - ".gitignore"
78
- - ".rspec"
79
- - ".travis.yml"
80
- - Gemfile
81
- - README.md
82
- - Rakefile
83
65
  - lib/rspec/files.rb
84
66
  - lib/rspec/files/buffer.rb
85
67
  - lib/rspec/files/leaks.rb
86
68
  - lib/rspec/files/version.rb
87
- - rspec-files.gemspec
88
69
  homepage: https://github.com/socketry/rspec-files
89
- licenses: []
70
+ licenses:
71
+ - MIT
90
72
  metadata: {}
91
- post_install_message:
73
+ post_install_message:
92
74
  rdoc_options: []
93
75
  require_paths:
94
76
  - lib
@@ -103,8 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
85
  - !ruby/object:Gem::Version
104
86
  version: '0'
105
87
  requirements: []
106
- rubygems_version: 3.0.6
107
- signing_key:
88
+ rubygems_version: 3.3.8
89
+ signing_key:
108
90
  specification_version: 4
109
91
  summary: RSpec helpers for buffering and detecting file descriptor leaks.
110
92
  test_files: []
data/.editorconfig DELETED
@@ -1,6 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
13
- .covered.db
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --warnings
3
- --require spec_helper
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
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rspec-files.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,95 +0,0 @@
1
- # RSpec::Files
2
-
3
- Detect leaked file descriptors and provides convenient file buffers.
4
-
5
- [![Build Status](https://travis-ci.com/socketry/rspec-files.svg?branch=master)](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
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:test)
5
-
6
- task :default => :test
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