rspec-dry-types 0.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 +7 -0
- data/.circleci/config.yml +43 -0
- data/.gitignore +321 -0
- data/.rspec +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rspec/dry/types/version.rb +7 -0
- data/lib/rspec/matchers/be_of_type.rb +33 -0
- data/rspec-dry-types.gemspec +33 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d8daa09bdaa2d2ca76e4004efe4d0a2a970e89e94d07968f876bab4c0299bc28
|
4
|
+
data.tar.gz: '0855703be6b330f8c48b4692729d67a91ce3a9f38b9634a821185677d1204d48'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a15f1fb512a673f3f54714df15746e77ae373d31d829bd33c9f433fa89f806588230a6f11dd0b29442daf5283ca5ed617e6b807596a06e9151f7f52471e6c08
|
7
|
+
data.tar.gz: f71d4816024b5195715919515934114d9542da3d3b8cf0163979a6ae57f1ae9c1ebda51ed0afa3188b1e616c9cbf51b672a68763dba3a0139548d3413d249602
|
@@ -0,0 +1,43 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
parallelism: 1
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:2.6.3
|
7
|
+
environment:
|
8
|
+
BUNDLE_JOBS: 2
|
9
|
+
BUNDLE_RETRY: 3
|
10
|
+
BUNDLE_PATH: ~/.cache/bundler
|
11
|
+
steps:
|
12
|
+
- checkout
|
13
|
+
- run:
|
14
|
+
name: bundle lock
|
15
|
+
command: mkdir -p ~/.cache; bundle lock --update
|
16
|
+
- restore_cache:
|
17
|
+
key: bundle-{{ checksum "Gemfile.lock" }}
|
18
|
+
- run:
|
19
|
+
name: bundle install
|
20
|
+
command: bundle check &>/dev/null || bundle install
|
21
|
+
- save_cache:
|
22
|
+
key: bundle-{{ checksum "Gemfile.lock" }}
|
23
|
+
paths:
|
24
|
+
- ~/.cache/bundler
|
25
|
+
- run:
|
26
|
+
name: rspec
|
27
|
+
path: .
|
28
|
+
command: |
|
29
|
+
mkdir -p ~/rspec
|
30
|
+
bundle exec rspec --profile 10 \
|
31
|
+
--out ~/rspec/rspec.xml \
|
32
|
+
--format progress \
|
33
|
+
$( circleci tests glob "spec/**/*_spec.rb" | \
|
34
|
+
circleci tests split --split-by=timings )
|
35
|
+
- store_test_results:
|
36
|
+
path: ~/rspec
|
37
|
+
- store_artifacts:
|
38
|
+
path: ~/rspec
|
39
|
+
workflows:
|
40
|
+
version: 2
|
41
|
+
workflow:
|
42
|
+
jobs:
|
43
|
+
- build
|
data/.gitignore
ADDED
@@ -0,0 +1,321 @@
|
|
1
|
+
# rspec failure tracking
|
2
|
+
.rspec_status
|
3
|
+
### Node template
|
4
|
+
# Logs
|
5
|
+
logs
|
6
|
+
*.log
|
7
|
+
npm-debug.log*
|
8
|
+
yarn-debug.log*
|
9
|
+
yarn-error.log*
|
10
|
+
lerna-debug.log*
|
11
|
+
|
12
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
13
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
14
|
+
|
15
|
+
# Runtime data
|
16
|
+
pids
|
17
|
+
*.pid
|
18
|
+
*.seed
|
19
|
+
*.pid.lock
|
20
|
+
|
21
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
22
|
+
lib-cov
|
23
|
+
|
24
|
+
# Coverage directory used by tools like istanbul
|
25
|
+
coverage
|
26
|
+
*.lcov
|
27
|
+
|
28
|
+
# nyc test coverage
|
29
|
+
.nyc_output
|
30
|
+
|
31
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
32
|
+
.grunt
|
33
|
+
|
34
|
+
# Bower dependency directory (https://bower.io/)
|
35
|
+
bower_components
|
36
|
+
|
37
|
+
# node-waf configuration
|
38
|
+
.lock-wscript
|
39
|
+
|
40
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
41
|
+
build/Release
|
42
|
+
|
43
|
+
# Dependency directories
|
44
|
+
node_modules/
|
45
|
+
jspm_packages/
|
46
|
+
|
47
|
+
# TypeScript v1 declaration files
|
48
|
+
typings/
|
49
|
+
|
50
|
+
# TypeScript cache
|
51
|
+
*.tsbuildinfo
|
52
|
+
|
53
|
+
# Optional npm cache directory
|
54
|
+
.npm
|
55
|
+
|
56
|
+
# Optional eslint cache
|
57
|
+
.eslintcache
|
58
|
+
|
59
|
+
# Optional REPL history
|
60
|
+
.node_repl_history
|
61
|
+
|
62
|
+
# Output of 'npm pack'
|
63
|
+
*.tgz
|
64
|
+
|
65
|
+
# Yarn Integrity file
|
66
|
+
.yarn-integrity
|
67
|
+
|
68
|
+
# dotenv environment variables file
|
69
|
+
.env
|
70
|
+
.env.test
|
71
|
+
|
72
|
+
# parcel-bundler cache (https://parceljs.org/)
|
73
|
+
.cache
|
74
|
+
|
75
|
+
# next.js build output
|
76
|
+
.next
|
77
|
+
|
78
|
+
# nuxt.js build output
|
79
|
+
.nuxt
|
80
|
+
|
81
|
+
# vuepress build output
|
82
|
+
.vuepress/dist
|
83
|
+
|
84
|
+
# Serverless directories
|
85
|
+
.serverless/
|
86
|
+
|
87
|
+
# FuseBox cache
|
88
|
+
.fusebox/
|
89
|
+
|
90
|
+
# DynamoDB Local files
|
91
|
+
.dynamodb/
|
92
|
+
|
93
|
+
### Ruby template
|
94
|
+
*.gem
|
95
|
+
*.rbc
|
96
|
+
/.config
|
97
|
+
/coverage/
|
98
|
+
/InstalledFiles
|
99
|
+
/pkg/
|
100
|
+
/spec/reports/
|
101
|
+
/spec/examples.txt
|
102
|
+
/test/tmp/
|
103
|
+
/test/version_tmp/
|
104
|
+
/tmp/
|
105
|
+
|
106
|
+
# Used by dotenv library to load environment variables.
|
107
|
+
# .env
|
108
|
+
|
109
|
+
# Ignore Byebug command history file.
|
110
|
+
.byebug_history
|
111
|
+
|
112
|
+
## Specific to RubyMotion:
|
113
|
+
.dat*
|
114
|
+
.repl_history
|
115
|
+
build/
|
116
|
+
*.bridgesupport
|
117
|
+
build-iPhoneOS/
|
118
|
+
build-iPhoneSimulator/
|
119
|
+
|
120
|
+
## Specific to RubyMotion (use of CocoaPods):
|
121
|
+
#
|
122
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
123
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
124
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
125
|
+
#
|
126
|
+
# vendor/Pods/
|
127
|
+
|
128
|
+
## Documentation cache and generated files:
|
129
|
+
/.yardoc/
|
130
|
+
/_yardoc/
|
131
|
+
/doc/
|
132
|
+
/rdoc/
|
133
|
+
|
134
|
+
## Environment normalization:
|
135
|
+
/.bundle/
|
136
|
+
/vendor/bundle
|
137
|
+
/lib/bundler/man/
|
138
|
+
|
139
|
+
# for a library or gem, you might want to ignore these files since the code is
|
140
|
+
# intended to run in multiple environments; otherwise, check them in:
|
141
|
+
# Gemfile.lock
|
142
|
+
# .ruby-version
|
143
|
+
# .ruby-gemset
|
144
|
+
|
145
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
146
|
+
.rvmrc
|
147
|
+
|
148
|
+
### Jekyll template
|
149
|
+
_site/
|
150
|
+
.sass-cache/
|
151
|
+
.jekyll-cache/
|
152
|
+
.jekyll-metadata
|
153
|
+
|
154
|
+
### macOS template
|
155
|
+
# General
|
156
|
+
.DS_Store
|
157
|
+
.AppleDouble
|
158
|
+
.LSOverride
|
159
|
+
|
160
|
+
# Icon must end with two \r
|
161
|
+
Icon
|
162
|
+
|
163
|
+
# Thumbnails
|
164
|
+
._*
|
165
|
+
|
166
|
+
# Files that might appear in the root of a volume
|
167
|
+
.DocumentRevisions-V100
|
168
|
+
.fseventsd
|
169
|
+
.Spotlight-V100
|
170
|
+
.TemporaryItems
|
171
|
+
.Trashes
|
172
|
+
.VolumeIcon.icns
|
173
|
+
.com.apple.timemachine.donotpresent
|
174
|
+
|
175
|
+
# Directories potentially created on remote AFP share
|
176
|
+
.AppleDB
|
177
|
+
.AppleDesktop
|
178
|
+
Network Trash Folder
|
179
|
+
Temporary Items
|
180
|
+
.apdisk
|
181
|
+
|
182
|
+
### JetBrains template
|
183
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
184
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
185
|
+
|
186
|
+
# User-specific stuff
|
187
|
+
.idea/**/workspace.xml
|
188
|
+
.idea/**/tasks.xml
|
189
|
+
.idea/**/usage.statistics.xml
|
190
|
+
.idea/**/dictionaries
|
191
|
+
.idea/**/shelf
|
192
|
+
|
193
|
+
# Generated files
|
194
|
+
.idea/**/contentModel.xml
|
195
|
+
|
196
|
+
# Sensitive or high-churn files
|
197
|
+
.idea/**/dataSources/
|
198
|
+
.idea/**/dataSources.ids
|
199
|
+
.idea/**/dataSources.local.xml
|
200
|
+
.idea/**/sqlDataSources.xml
|
201
|
+
.idea/**/dynamic.xml
|
202
|
+
.idea/**/uiDesigner.xml
|
203
|
+
.idea/**/dbnavigator.xml
|
204
|
+
|
205
|
+
# Gradle
|
206
|
+
.idea/**/gradle.xml
|
207
|
+
.idea/**/libraries
|
208
|
+
|
209
|
+
# Gradle and Maven with auto-import
|
210
|
+
# When using Gradle or Maven with auto-import, you should exclude module files,
|
211
|
+
# since they will be recreated, and may cause churn. Uncomment if using
|
212
|
+
# auto-import.
|
213
|
+
# .idea/modules.xml
|
214
|
+
# .idea/*.iml
|
215
|
+
# .idea/modules
|
216
|
+
# *.iml
|
217
|
+
# *.ipr
|
218
|
+
|
219
|
+
# CMake
|
220
|
+
cmake-build-*/
|
221
|
+
|
222
|
+
# Mongo Explorer plugin
|
223
|
+
.idea/**/mongoSettings.xml
|
224
|
+
|
225
|
+
# File-based project format
|
226
|
+
*.iws
|
227
|
+
|
228
|
+
# IntelliJ
|
229
|
+
out/
|
230
|
+
|
231
|
+
# mpeltonen/sbt-idea plugin
|
232
|
+
.idea_modules/
|
233
|
+
|
234
|
+
# JIRA plugin
|
235
|
+
atlassian-ide-plugin.xml
|
236
|
+
|
237
|
+
# Cursive Clojure plugin
|
238
|
+
.idea/replstate.xml
|
239
|
+
|
240
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
241
|
+
com_crashlytics_export_strings.xml
|
242
|
+
crashlytics.properties
|
243
|
+
crashlytics-build.properties
|
244
|
+
fabric.properties
|
245
|
+
|
246
|
+
# Editor-based Rest Client
|
247
|
+
.idea/httpRequests
|
248
|
+
|
249
|
+
# Android studio 3.1+ serialized cache file
|
250
|
+
.idea/caches/build_file_checksums.ser
|
251
|
+
|
252
|
+
### Rails template
|
253
|
+
*.rbc
|
254
|
+
capybara-*.html
|
255
|
+
.rspec
|
256
|
+
/db/*.sqlite3
|
257
|
+
/db/*.sqlite3-journal
|
258
|
+
/public/system
|
259
|
+
/coverage/
|
260
|
+
/spec/tmp
|
261
|
+
*.orig
|
262
|
+
rerun.txt
|
263
|
+
pickle-email-*.html
|
264
|
+
|
265
|
+
# Ignore all logfiles and tempfiles.
|
266
|
+
/log/*
|
267
|
+
/tmp/*
|
268
|
+
!/log/.keep
|
269
|
+
!/tmp/.keep
|
270
|
+
|
271
|
+
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
|
272
|
+
config/initializers/secret_token.rb
|
273
|
+
config/master.key
|
274
|
+
|
275
|
+
# Only include if you have production secrets in this file, which is no longer a Rails default
|
276
|
+
# config/secrets.yml
|
277
|
+
|
278
|
+
# dotenv
|
279
|
+
# TODO Comment out this rule if environment variables can be committed
|
280
|
+
.env
|
281
|
+
|
282
|
+
## Environment normalization:
|
283
|
+
/.bundle
|
284
|
+
/vendor/bundle
|
285
|
+
|
286
|
+
# these should all be checked in to normalize the environment:
|
287
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
288
|
+
|
289
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
290
|
+
.rvmrc
|
291
|
+
|
292
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
293
|
+
/vendor/assets/bower_components
|
294
|
+
*.bowerrc
|
295
|
+
bower.json
|
296
|
+
|
297
|
+
# Ignore pow environment settings
|
298
|
+
.powenv
|
299
|
+
|
300
|
+
# Ignore Byebug command history file.
|
301
|
+
.byebug_history
|
302
|
+
|
303
|
+
# Ignore node_modules
|
304
|
+
node_modules/
|
305
|
+
|
306
|
+
# Ignore precompiled javascript packs
|
307
|
+
/public/packs
|
308
|
+
/public/packs-test
|
309
|
+
/public/assets
|
310
|
+
|
311
|
+
# Ignore yarn files
|
312
|
+
/yarn-error.log
|
313
|
+
yarn-debug.log*
|
314
|
+
.yarn-integrity
|
315
|
+
|
316
|
+
# Ignore uploaded files in development
|
317
|
+
/storage/*
|
318
|
+
!/storage/.keep
|
319
|
+
|
320
|
+
/.idea/
|
321
|
+
/Gemfile.lock
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rspec-dry-types
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.6.4
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at patrick.clery@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 patrickclery
|
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,78 @@
|
|
1
|
+
[](https://circleci.com/gh/patrickclery/rspec-dry-types)
|
2
|
+
|
3
|
+
# Dry::Types for RSpec
|
4
|
+
|
5
|
+
`rspec-dry-types` makes type-checking in Test-Driven Development easier by replacing RSpec's default type checkers with ones that check values using the [dry-types gem](http://dry-rb.org/gems/dry-types/).
|
6
|
+
|
7
|
+
This:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
expect(subject).to be_a(String)
|
11
|
+
```
|
12
|
+
|
13
|
+
Becomes this:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
expect(subject).to be_a(Dry::Types['strict.string'])
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
RSpec.describe "check types using be_of_type" do
|
23
|
+
include RSpec::Matchers::DryTypes
|
24
|
+
|
25
|
+
it 'can use a symbol to expect a dry-type' do
|
26
|
+
expect('a string').to be_of_type(:string)
|
27
|
+
expect(123).to be_of_type(:integer)
|
28
|
+
expect(0.123).to be_of_type(:float)
|
29
|
+
expect("123").to be_of_type(:integer, strict: false)
|
30
|
+
expect(nil).to be_of_type(:string, strict: false)
|
31
|
+
expect(nil).to be_of_type(:nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Strings must reference the dry-types docs
|
35
|
+
it 'can use string to expect a dry-type' do
|
36
|
+
expect('a string').to be_of_type('string')
|
37
|
+
expect('a string').to be_of_type('strict.string')
|
38
|
+
expect(123).to be_of_type('integer')
|
39
|
+
expect(123).to be_of_type('strict.integer')
|
40
|
+
expect(0.123).to be_of_type('float')
|
41
|
+
expect(0.123).to be_of_type('coercible.integer')
|
42
|
+
expect("123").to be_of_type('integer', strict: false)
|
43
|
+
expect(nil).to be_of_type('string', strict: false)
|
44
|
+
expect(nil).to be_of_type('nil')
|
45
|
+
end
|
46
|
+
|
47
|
+
# Strings must reference the dry-types docs
|
48
|
+
it 'is backwards compat with be_a' do
|
49
|
+
expect('a string').to be_a(String)
|
50
|
+
expect('a string').to be_a_kind_of('strict.string')
|
51
|
+
expect(123).to be_an(Integer)
|
52
|
+
expect(123).to be_an('integer')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'can use a class to check if its a type' do
|
56
|
+
# Check inheritance
|
57
|
+
expect(String).to be_of_type(Object)
|
58
|
+
expect('a string').to be_of_type(Object)
|
59
|
+
|
60
|
+
# Check coercion
|
61
|
+
expect(123).to be_of_type(String, strict: false)
|
62
|
+
expect(0.123).not_to be_of_type(Integer)
|
63
|
+
expect(0.123).to be_of_type(Integer, strict: false)
|
64
|
+
|
65
|
+
expect(123).to be_of_type(Object)
|
66
|
+
expect(123).to be_of_type(Object)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rspec-dry-types. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
75
|
+
|
76
|
+
## Code of Conduct
|
77
|
+
|
78
|
+
Everyone interacting in the Rspec::Dry::Types project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rspec-dry-types/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rspec/dry/types"
|
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,33 @@
|
|
1
|
+
require 'dry/types'
|
2
|
+
require 'rspec/expectations'
|
3
|
+
|
4
|
+
module RSpec::Matchers
|
5
|
+
module DryTypes
|
6
|
+
extend RSpec::Matchers::DSL
|
7
|
+
|
8
|
+
matcher :be_of_type do |expected, strict: true|
|
9
|
+
# If you provide a string value, it will use dry-types,
|
10
|
+
# if you provide anything else, it will use RSpec-expectations
|
11
|
+
ref = expected.to_s.downcase
|
12
|
+
ref = "coercible.#{ref}" unless strict or ref === 'nil'
|
13
|
+
match do |actual|
|
14
|
+
# Let it throw errors if it has to
|
15
|
+
if Dry::Types.type_keys.include?(ref)
|
16
|
+
# Only use dry-types if a valid key is given
|
17
|
+
constraint = Dry::Types[ref]
|
18
|
+
constraint.valid?(actual)
|
19
|
+
else
|
20
|
+
# Otherwise fallback to default
|
21
|
+
actual.kind_of?(expected)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
alias_method :be_a, :be_of_type
|
26
|
+
alias_method :be_an, :be_of_type
|
27
|
+
alias_method :be_a_kind_of, :be_of_type
|
28
|
+
|
29
|
+
alias_matcher :be_of_type, :be_a
|
30
|
+
alias_matcher :be_of_type, :be_a_kind_of
|
31
|
+
alias_matcher :be_of_type, :be_an
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "rspec/dry/types/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "rspec-dry-types"
|
7
|
+
spec.version = Rspec::Dry::Types::VERSION
|
8
|
+
spec.authors = ["patrickclery"]
|
9
|
+
spec.email = ["patrick.clery@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Run your tests using Dry::Types for type expectations"
|
12
|
+
spec.description = %q{Dry::Types for RSpec}
|
13
|
+
spec.homepage = "https://github.com/patrickclery/rspec-dry-types"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency "bundler"
|
30
|
+
spec.add_dependency "dry-types", "~> 1.0"
|
31
|
+
spec.add_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_dependency "rspec", "~> 3.8"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-dry-types
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- patrickclery
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
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: dry-types
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.8'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.8'
|
69
|
+
description: Dry::Types for RSpec
|
70
|
+
email:
|
71
|
+
- patrick.clery@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".circleci/config.yml"
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".ruby-gemset"
|
80
|
+
- ".ruby-version"
|
81
|
+
- ".travis.yml"
|
82
|
+
- CODE_OF_CONDUCT.md
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- bin/console
|
88
|
+
- bin/setup
|
89
|
+
- lib/rspec/dry/types/version.rb
|
90
|
+
- lib/rspec/matchers/be_of_type.rb
|
91
|
+
- rspec-dry-types.gemspec
|
92
|
+
homepage: https://github.com/patrickclery/rspec-dry-types
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata:
|
96
|
+
homepage_uri: https://github.com/patrickclery/rspec-dry-types
|
97
|
+
source_code_uri: https://github.com/patrickclery/rspec-dry-types
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubygems_version: 3.0.6
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Run your tests using Dry::Types for type expectations
|
117
|
+
test_files: []
|