rspec-sorbet 1.0.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 +7 -0
- data/.gitignore +19 -0
- data/.reek.yml +32 -0
- data/.rspec +3 -0
- data/.rubocop.yml +66 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +25 -0
- data/LICENSE.txt +21 -0
- data/README.md +30 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/generate_require_files.rb +48 -0
- data/lib/rspec/all.rb +7 -0
- data/lib/rspec/sorbet/all.rb +6 -0
- data/lib/rspec/sorbet/instance_doubles.rb +40 -0
- data/lib/rspec/sorbet/version.rb +7 -0
- data/lib/rspec/sorbet.rb +9 -0
- data/rspec-sorbet.gemspec +33 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dfa6e3ee8be246791457ead7ccfadfb915bc17def59dec8f615287e8cbda3aba
|
4
|
+
data.tar.gz: 34c42b3831bc5712a67e544bc56d768c8617e917ede3f2251ad5a22000e50629
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a1b97aa16c1923938827dc55a7e2b8574dd116ed5c88c43530ff47758bee34f9e8b401275b743fb5cd667427307cf0791218d2c33315605da6478798a4f11d48
|
7
|
+
data.tar.gz: 831e6e1f418ac631a7ec9ffc774a682e70ffe7908600d3c20253d6612b4d8d58368e53bcc7c912c10f5b153edab7c9e3825790d7eebb2cb29b0de5b2d0baec95
|
data/.gitignore
ADDED
data/.reek.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
detectors:
|
3
|
+
IrresponsibleModule:
|
4
|
+
enabled: false
|
5
|
+
TooManyStatements:
|
6
|
+
enabled: true
|
7
|
+
max_statements: 10
|
8
|
+
NilCheck:
|
9
|
+
enabled: false
|
10
|
+
directories:
|
11
|
+
app/controllers:
|
12
|
+
NestedIterators:
|
13
|
+
max_allowed_nesting: 2
|
14
|
+
UnusedPrivateMethod:
|
15
|
+
enabled: false
|
16
|
+
app/helpers:
|
17
|
+
UtilityFunction:
|
18
|
+
enabled: false
|
19
|
+
exclude_paths:
|
20
|
+
- app/assets
|
21
|
+
- bin
|
22
|
+
- client/node_modules
|
23
|
+
- config
|
24
|
+
- coverage
|
25
|
+
- data
|
26
|
+
- db
|
27
|
+
- dw
|
28
|
+
- log
|
29
|
+
- phrase
|
30
|
+
- public
|
31
|
+
- tmp
|
32
|
+
- vendor
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
---
|
2
|
+
Documentation:
|
3
|
+
Enabled: false
|
4
|
+
Rails:
|
5
|
+
Enabled: true
|
6
|
+
AllCops:
|
7
|
+
Include:
|
8
|
+
- app/**/*.rb
|
9
|
+
- lib/**/*.rb
|
10
|
+
- spec/**/*.rb
|
11
|
+
Exclude:
|
12
|
+
- app/assets/**/*
|
13
|
+
- bin/**/*
|
14
|
+
- client/node_modules/**/*
|
15
|
+
- config/**/*
|
16
|
+
- coverage/**/*
|
17
|
+
- data/**/*
|
18
|
+
- db/**/*
|
19
|
+
- db_*/**/*
|
20
|
+
- dw/**/*
|
21
|
+
- log/**/*
|
22
|
+
- phrase/**/*
|
23
|
+
- public/**/*
|
24
|
+
- tmp/**/*
|
25
|
+
- vendor/**/*
|
26
|
+
TargetRubyVersion: 2.5
|
27
|
+
Metrics/LineLength:
|
28
|
+
Max: 100
|
29
|
+
Layout/MultilineMethodCallIndentation:
|
30
|
+
EnforcedStyle: indented
|
31
|
+
Style/PercentLiteralDelimiters:
|
32
|
+
PreferredDelimiters:
|
33
|
+
"%w": "[]"
|
34
|
+
RSpec/ExampleLength:
|
35
|
+
Enabled: false
|
36
|
+
Max: 10
|
37
|
+
RSpec/MultipleExpectations:
|
38
|
+
Enabled: false
|
39
|
+
Max: 10
|
40
|
+
RSpec/NestedGroups:
|
41
|
+
Enabled: false
|
42
|
+
Max: 10
|
43
|
+
RSpec/MessageExpectation:
|
44
|
+
Enabled: false
|
45
|
+
RSpec/MissingExampleGroupArgument:
|
46
|
+
Enabled: false
|
47
|
+
require:
|
48
|
+
- rubocop-performance
|
49
|
+
- rubocop-rspec
|
50
|
+
- test_prof/rubocop
|
51
|
+
Metrics/BlockLength:
|
52
|
+
Enabled: false
|
53
|
+
RSpec/MessageSpies:
|
54
|
+
Enabled: false
|
55
|
+
RSpec/ExpectInHook:
|
56
|
+
Enabled: false
|
57
|
+
RSpec/AggregateFailures:
|
58
|
+
Enabled: true
|
59
|
+
Include:
|
60
|
+
- spec/**/*.rb
|
61
|
+
Rails/InverseOf:
|
62
|
+
Enabled: false
|
63
|
+
Rails/Present:
|
64
|
+
Enabled: false
|
65
|
+
Rails/TimeZone:
|
66
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.5
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in rspec-sorbet.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem 'guard-livereload', require: false
|
8
|
+
gem 'guard-rspec'
|
9
|
+
gem 'pry-byebug'
|
10
|
+
gem 'rb-fsevent', require: false
|
11
|
+
gem 'rb-readline'
|
12
|
+
gem 'reek'
|
13
|
+
gem 'rspec'
|
14
|
+
gem 'rubocop'
|
15
|
+
gem 'rubocop-rspec'
|
16
|
+
gem 'shoulda-matchers', require: false
|
17
|
+
gem 'sqlite3'
|
18
|
+
gem 'stackprof'
|
19
|
+
gem 'timecop'
|
20
|
+
end
|
21
|
+
|
22
|
+
group :test do
|
23
|
+
gem 'ffaker'
|
24
|
+
gem 'simplecov'
|
25
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Samuel Giles
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# RSpec Sorbet
|
2
|
+
|
3
|
+
A small gem consisting of helpers for using Sorbet & RSpec together.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
`gem 'rspec-sorbet'`
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
In your `spec_helper.rb` you need to first add a `require`:
|
12
|
+
```ruby
|
13
|
+
require 'rspec/sorbet'
|
14
|
+
```
|
15
|
+
|
16
|
+
### Allowing Instance Doubles
|
17
|
+
|
18
|
+
Out of the box if your using `instance_double`'s in your tests you'll encounter errors such as the following:
|
19
|
+
|
20
|
+
```
|
21
|
+
TypeError:
|
22
|
+
Parameter 'my_parameter': Expected type MyObject, got type RSpec::Mocks::InstanceVerifyingDouble with value #<InstanceDouble(MyObject) (anonymous)>
|
23
|
+
Caller: /Users/samuelgiles/Documents/Projects/Clients/Bellroy/bellroy/spec/lib/checkout/use_cases/my_use_case.rb:9
|
24
|
+
```
|
25
|
+
|
26
|
+
Drop the following into your `spec_helper.rb` to allow instance doubles to be used:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
RSpec::Sorbet.allow_instance_doubles!
|
30
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rspec/sorbet'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
BASE_FOLDER_PATH = 'rspec'
|
4
|
+
|
5
|
+
def directories_in(root)
|
6
|
+
Dir.entries(root).sort.select do |entry|
|
7
|
+
fully_qualified_entry = File.join(root, entry)
|
8
|
+
File.directory?(fully_qualified_entry) && !['.', '..'].include?(entry.to_s)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def files_in(root)
|
13
|
+
Dir.entries(root).sort.reject do |entry|
|
14
|
+
fully_qualified_entry = File.join(root, entry)
|
15
|
+
File.directory?(fully_qualified_entry) || entry.to_s == 'all.rb' || entry[-3..-1] != '.rb'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def recursive_files_in(root)
|
20
|
+
full_paths = Dir.glob(File.join(root, '**', '*')).sort.reject do |entry|
|
21
|
+
fully_qualified_entry = File.join(root, entry)
|
22
|
+
File.directory?(fully_qualified_entry) || entry[-7..-1] == '/all.rb' || entry[-3..-1] != '.rb'
|
23
|
+
end
|
24
|
+
|
25
|
+
remove_path = root.split('/')[0..-2].join('/') + '/'
|
26
|
+
full_paths.map { |full_path| full_path.gsub(remove_path, '') }
|
27
|
+
end
|
28
|
+
|
29
|
+
def write_require_file(root, require_directories, require_files)
|
30
|
+
require_file_path = File.join(root, 'all.rb')
|
31
|
+
File.open(require_file_path, 'w') do |file|
|
32
|
+
file.write("# frozen_string_literal: true\n\n")
|
33
|
+
file.write("# THIS FILE IS AUTOGENERATED AND SHOULD NOT BE MANUALLY MODIFIED\n\n")
|
34
|
+
require_directories.each do |require_directory|
|
35
|
+
file.write("require '#{BASE_FOLDER_PATH}/#{require_directory}/all'\n")
|
36
|
+
end
|
37
|
+
file.write("\n") unless require_directories.empty?
|
38
|
+
require_files.each { |require_file| file.write("require '#{BASE_FOLDER_PATH}/#{require_file[0..-4]}'\n") }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
root = File.join(__dir__, 'lib', BASE_FOLDER_PATH)
|
43
|
+
directories = directories_in(root)
|
44
|
+
write_require_file(root, directories, files_in(root))
|
45
|
+
directories.each do |directory|
|
46
|
+
fully_qualified_directory = File.join(root, directory)
|
47
|
+
write_require_file(fully_qualified_directory, [], recursive_files_in(fully_qualified_directory))
|
48
|
+
end
|
data/lib/rspec/all.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sorbet-runtime'
|
4
|
+
|
5
|
+
module RSpec
|
6
|
+
module Sorbet
|
7
|
+
module InstanceDoubles
|
8
|
+
WHITELISTED_ERROR_MESSAGES = [
|
9
|
+
'RSpec::Mocks::InstanceVerifyingDouble',
|
10
|
+
'InstanceDouble'
|
11
|
+
].freeze
|
12
|
+
|
13
|
+
def allow_instance_doubles!
|
14
|
+
T::Configuration.inline_type_error_handler = proc do |error|
|
15
|
+
inline_type_error_handler(error)
|
16
|
+
end
|
17
|
+
|
18
|
+
T::Configuration.call_validation_error_handler = proc do |signature, opts|
|
19
|
+
call_validation_error_handler(signature, opts)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def inline_type_error_handler(error)
|
26
|
+
raise error unless error.is_a?(TypeError) && message_is_whitelisted?(error.message)
|
27
|
+
end
|
28
|
+
|
29
|
+
def call_validation_error_handler(_signature, opts)
|
30
|
+
raise TypeError, opts[:pretty_message] unless message_is_whitelisted?(opts[:message])
|
31
|
+
end
|
32
|
+
|
33
|
+
def message_is_whitelisted?(message)
|
34
|
+
WHITELISTED_ERROR_MESSAGES.any? do |whitelisted_message|
|
35
|
+
message.include?(whitelisted_message)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/rspec/sorbet.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'rspec/sorbet'
|
5
|
+
require 'rspec/sorbet/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'rspec-sorbet'
|
9
|
+
spec.version = RSpec::Sorbet::VERSION
|
10
|
+
spec.authors = ['Samuel Giles']
|
11
|
+
spec.email = ['samuel.giles@bellroy.com']
|
12
|
+
|
13
|
+
spec.summary = 'A small gem consisting of helpers for using Sorbet & RSpec together.'
|
14
|
+
spec.homepage = 'https://github.com/tricycle/rspec-sorbet'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^spec/}) && !f.match(%r{^spec/support/factories/})
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_dependency 'sorbet'
|
27
|
+
spec.add_dependency 'sorbet-runtime'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
30
|
+
spec.add_development_dependency 'pry'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-sorbet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Giles
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sorbet
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sorbet-runtime
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.17'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.17'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- samuel.giles@bellroy.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".reek.yml"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".ruby-version"
|
109
|
+
- CHANGELOG.md
|
110
|
+
- Gemfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- generate_require_files.rb
|
117
|
+
- lib/rspec/all.rb
|
118
|
+
- lib/rspec/sorbet.rb
|
119
|
+
- lib/rspec/sorbet/all.rb
|
120
|
+
- lib/rspec/sorbet/instance_doubles.rb
|
121
|
+
- lib/rspec/sorbet/version.rb
|
122
|
+
- rspec-sorbet.gemspec
|
123
|
+
homepage: https://github.com/tricycle/rspec-sorbet
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.7.6.2
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: A small gem consisting of helpers for using Sorbet & RSpec together.
|
147
|
+
test_files: []
|