8000 Modernize gem. · socketry/async-rspec@69a66fe · GitHub
[go: up one dir, main page]

Skip to content

Commit 69a66fe

Browse files
committed
Modernize gem.
1 parent ced78e1 commit 69a66fe

File tree

8 files changed

+102
-92
lines changed

8 files changed

+102
-92
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ root = true
33
[*]
44
indent_style = tab
55
indent_size = 2
6-

.github/workflows/development.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Development
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ${{matrix.os}}-latest
8+
continue-on-error: ${{matrix.experimental}}
9+
10+
strategy:
11+
matrix:
12+
os:
13+
- ubuntu
14+
- macos
15+
16+
ruby:
17+
- 2.5
18+
- 2.6
19+
- 2.7
20+
21+
experimental: [false]
22+
env: [""]
23+
24+
include:
25+
- os: ubuntu
26+
ruby: truffleruby
27+
experimental: true
28+
- os: ubuntu
29+
ruby: jruby
30+
experimental: true
31+
- os: ubuntu
32+
ruby: head
33+
experimental: true
34+
35+
steps:
36+
- uses: actions/checkout@v2
37+
- uses: ruby/setup-ruby@master
38+
with:
39+
ruby-version: ${{matrix.ruby}}
40+
bundler-cache: true
41+
42+
- name: Run tests
43+
timeout-minutes: 5
44+
run: ${{matrix.env}} bundle exec rspec

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/.bundle/
22
/.yardoc
3-
/Gemfile.lock
3+
/gems.locked
44
/_yardoc/
55
/coverage/
66
/doc/

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

README.md

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
# Async::RSpec
22

3-
Provides useful `RSpec.shared_context`s for testing code that builds on top of [async].
3+
Provides useful `RSpec.shared_context`s for testing code that builds on top of [async](https://github.com/socketry/async).
44

5-
[async]: https://github.com/socketry/async
6-
7-
[![Build Status](https://travis-ci.com/socketry/async-rspec.svg?branch=master)](https://travis-ci.com/socketry/async-rspec)
8-
[![Code Climate](https://codeclimate.com/github/socketry/async-rspec.svg)](https://codeclimate.com/github/socketry/async-rspec)
9-
[![Coverage Status](https://coveralls.io/repos/socketry/async-rspec/badge.svg)](https://coveralls.io/r/socketry/async-rspec)
5+
[![Development Status](https://github.com/socketry/async-rspec/workflows/Development/badge.svg)](https://github.com/socketry/async-rspec/actions?workflow=Development)
106

117
## Installation
128

13-
Add this line to your application's Gemfile:
14-
15-
```ruby
16-
gem 'async-rspec'
9+
``` shell
10+
$ bundle add async-rspec
1711
```
1812

19-
And then execute:
20-
21-
$ bundle
22-
23-
Or install it yourself as:
13+
Then add this require statement to the top of `spec/spec_helper.rb`
2414

25-
$ gem install async-rspec
26-
27-
Finally, add this require statement to the top of `spec/spec_helper.rb`
28-
29-
```ruby
15+
``` ruby
3016
require 'async/rspec'
3117
```
3218

@@ -36,58 +22,58 @@ require 'async/rspec'
3622

3723
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.
3824

39-
```ruby
25+
``` ruby
4026
require 'async/io'
4127

4228
RSpec.describe Async::IO do
43-
include_context Async::RSpec::Reactor
29+
include_context Async::RSpec::Reactor
30+
31+
let(:pipe) {IO.pipe}
32+
let(:input) {Async::IO::Generic.new(pipe.first)}
33+
let(:output) {Async::IO::Generic.new(pipe.last)}
4434

45-
let(:pipe) {IO.pipe}
46-
let(:input) {Async::IO::Generic.new(pipe.first)}
47-
let(:output) {Async::IO::Generic.new(pipe.last)}
48-
49-
it "should send and receive data within the same reactor" do
50-
message = nil
35+
i 10000 t "should send and receive data within the same reactor" do
36+
message = nil
5137

52-
output_task = reactor.async do
53-
message = input.read(1024)
54-
end
38+
output_task = reactor.async do
39+
message = input.read(1024)
40+
end
5541

56-
reactor.async do
57-
output.write("Hello World")
58-
end
42+
reactor.async do
43+
output.write("Hello World")
44+
end
5945

60-
output_task.wait
61-
expect(message).to be == "Hello World"
46+
output_task.wait
47+
expect(message).to be == "Hello World"
6248

63-
input.close
64-
output.close
65-
end
49+
input.close
50+
output.close
51+
end
6652
end
6753
```
6854

6955
### Changing Timeout
7056

7157
You can change the timeout by specifying it as an option:
7258

73-
```ruby
59+
``` ruby
7460
RSpec.describe MySlowThing, timeout: 60 do
75-
# ...
61+
# ...
7662
end
7763
```
7864

7965
### File Descriptor Leaks
8066

8167
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.
8268

83-
```ruby
69+
``` ruby
8470
RSpec.describe "leaky ios" do
85-
include_context Async::RSpec::Leaks
71+
include_context Async::RSpec::Leaks
8672

87-
# The following fails:
88-
it "leaks io" do
89-
@input, @output = IO.pipe
90-
end
73+
# The following fails:
74+
it "leaks io" do
75+
@input, @output = IO.pipe
76+
end
9177
end
9278
```
9379

@@ -99,11 +85,11 @@ This functionality was moved to [`rspec-memory`](https://github.com/socketry/rsp
9985

10086
## Contributing
10187

102-
1. Fork it
103-
2. Create your feature branch (`git checkout -b my-new-feature`)
104-
3. Commit your changes (`git commit -am 'Add some feature'`)
105-
4. Push to the branch (`git push origin my-new-feature`)
106-
5. Create new Pull Request
88+
1. Fork it
89+
2. Create your feature branch (`git checkout -b my-new-feature 179B `)
90+
3. Commit your changes (`git commit -am 'Add some feature'`)
91+
4. Push to the branch (`git push origin my-new-feature`)
92+
5. Create new Pull Request
10793

10894
## License
10995

async-rspec.gemspec

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
# coding: utf-8
2-
require_relative 'lib/async/rspec/version'
31

4-
Gem::Specification.new do |spec|
5-
spec.name = "async-rspec"
6-
spec.version = Async::RSpec::VERSION
7-
spec.licenses = ["MIT"]
8-
spec.authors = ["Samuel Williams"]
9-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
10-
11-
spec.summary = "Helpers for writing specs against the async gem."
12-
spec.homepage = "https://github.com/socketry/async-rspec"
2+
require_relative "lib/async/rspec/version"
133

14-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
15-
f.match(%r{^(test|spec|features)/})
16-
end
4+
Gem::Specification.new do |spec|
5+
spec.name = "async-rspec"
6+
spec.version = Async::RSpec::VERSION
7+
8+
spec.summary = "Helpers for writing specs against the async gem."
9+
spec.authors = ["Samuel Williams"]
10+
spec.license = "MIT"
11+
12+
spec.homepage = "https://github.com/socketry/async-rspec"
1713

18-
spec.require_paths = ["lib"]
14+
spec.files = Dir.glob('{lib}/**/*', File::FNM_DOTMATCH, base: __dir__)
1915

2016
spec.add_dependency "rspec", "~> 3.0"
21-
spec.add_dependency "rspec-memory", "~> 1.0"
2217
spec.add_dependency "rspec-files", "~> 1.0"
18+
spec.add_dependency "rspec-memory", "~> 1.0"
2319

24-
# Since we test the shared contexts, we need some bits of async:
2520
spec.add_development_dependency "async", "~> 1.24"
26-
27-
spec.add_development_dependency "covered"
2821
spec.add_development_dependency "bundler"
22+
spec.add_development_dependency "covered"
2923
spec.add_development_dependency "rake", "~> 10.0"
3024
end

Gemfile renamed to gems.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
# gem "async", path: "../async"
77

8+
group :maintenance, optional: true do
9+
gem "bake-modernize"
10+
gem "bake-bundler"
11+
end
12+
813
group :test do
914
gem "ruby-prof", git: "https://github.com/ruby-prof/ruby-prof"
1015
end

spec/async/rspec/ssl_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
expect(certificate_store.verify(certificate)).to be_truthy
3737
end
3838
end
39-
39+
4040
context Async::RSpec::SSL::InvalidCertificate do
4141
include_context Async::RSpec::SSL::InvalidCertificate
4242

0 commit comments

Comments
 (0)
0