assertable 0.1.1
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 +8 -0
- data/.rubocop.yml +93 -0
- data/.ruby_version +1 -0
- data/.travis.yml +24 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +100 -0
- data/Guardfile +46 -0
- data/LICENSE.txt +21 -0
- data/Makefile +8 -0
- data/README.md +83 -0
- data/Rakefile +12 -0
- data/assertable.gemspec +47 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/assertable.rb +82 -0
- data/lib/assertable/version.rb +5 -0
- metadata +234 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 60c0e6f37af3495b4b11fd75e75ed6e5e1843f125a3e731ac9e8d2d9ed9cb8be
|
|
4
|
+
data.tar.gz: e591e775d542407c89c16281895f999b58892f5d4e3b587f0b3eb46ec52013c7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b2f93d1e48130807cc5f002a0671fd86a1a06f05916a54dfedca9d4b7f5c668f5b098777db864ce187a4520902a1282b2306d884ac15b7ee7e87c102b35a29a7
|
|
7
|
+
data.tar.gz: 80ba343bbc98c2128289e154d79981c4d2697a1e0da0ab8d3568adc4fb1428c62259b8257c770fc706cf8646b127b03027f34bdbaa56b74b058d05505f5c92fe
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-performance
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 2.7
|
|
6
|
+
|
|
7
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
8
|
+
Enabled: true
|
|
9
|
+
|
|
10
|
+
Layout/HeredocIndentation:
|
|
11
|
+
Enabled: true
|
|
12
|
+
|
|
13
|
+
Layout/LineLength:
|
|
14
|
+
Max: 80
|
|
15
|
+
|
|
16
|
+
Layout/MultilineArrayLineBreaks:
|
|
17
|
+
Enabled: true
|
|
18
|
+
|
|
19
|
+
Layout/MultilineHashKeyLineBreaks:
|
|
20
|
+
Enabled: true
|
|
21
|
+
|
|
22
|
+
# Enabled means "no space" around call operators
|
|
23
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
24
|
+
Enabled: true
|
|
25
|
+
|
|
26
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
27
|
+
Enabled: true
|
|
28
|
+
|
|
29
|
+
Lint/MixedRegexpCaptureTypes:
|
|
30
|
+
Enabled: true
|
|
31
|
+
|
|
32
|
+
Lint/StructNewOverride:
|
|
33
|
+
Enabled: true
|
|
34
|
+
|
|
35
|
+
# Meaning you cannot: raise Exception
|
|
36
|
+
Lint/RaiseException:
|
|
37
|
+
Enabled: true
|
|
38
|
+
|
|
39
|
+
Metrics/ClassLength:
|
|
40
|
+
Max: 110
|
|
41
|
+
|
|
42
|
+
# Would give us false positives on all private(*delegate)
|
|
43
|
+
Style/AccessModifierDeclarations:
|
|
44
|
+
Enabled: false
|
|
45
|
+
|
|
46
|
+
Style/RegexpLiteral:
|
|
47
|
+
EnforcedStyle: percent_r
|
|
48
|
+
|
|
49
|
+
Style/ClassAndModuleChildren:
|
|
50
|
+
Enabled: false
|
|
51
|
+
|
|
52
|
+
Style/DateTime:
|
|
53
|
+
Enabled: false
|
|
54
|
+
|
|
55
|
+
Style/Documentation:
|
|
56
|
+
Enabled: false
|
|
57
|
+
|
|
58
|
+
Style/ExponentialNotation:
|
|
59
|
+
Enabled: true
|
|
60
|
+
|
|
61
|
+
# Currently gives false positive with e.g. generator.date.strftime '%Y%m%d'
|
|
62
|
+
# https://github.com/bbatsov/rubocop/issues/5398
|
|
63
|
+
#
|
|
64
|
+
Style/FormatStringToken:
|
|
65
|
+
Enabled: false
|
|
66
|
+
|
|
67
|
+
Style/HashEachMethods:
|
|
68
|
+
Enabled: true
|
|
69
|
+
|
|
70
|
+
Style/HashTransformKeys:
|
|
71
|
+
Enabled: true
|
|
72
|
+
|
|
73
|
+
Style/HashTransformValues:
|
|
74
|
+
Enabled: true
|
|
75
|
+
|
|
76
|
+
Style/NumericPredicate:
|
|
77
|
+
EnforcedStyle: comparison
|
|
78
|
+
|
|
79
|
+
Style/RedundantRegexpCharacterClass:
|
|
80
|
+
Enabled: true
|
|
81
|
+
|
|
82
|
+
Style/RedundantRegexpEscape:
|
|
83
|
+
Enabled: true
|
|
84
|
+
|
|
85
|
+
Style/SlicingWithRange:
|
|
86
|
+
Enabled: true
|
|
87
|
+
|
|
88
|
+
# Metrics/ClassLength:
|
|
89
|
+
# Max: 250
|
|
90
|
+
|
|
91
|
+
Metrics/BlockLength:
|
|
92
|
+
Exclude:
|
|
93
|
+
- 'assertable.gemspec'
|
data/.ruby_version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.7.1
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
sudo: false
|
|
3
|
+
dist: xenial
|
|
4
|
+
language: ruby
|
|
5
|
+
cache: bundler
|
|
6
|
+
rvm:
|
|
7
|
+
- 2.6.6
|
|
8
|
+
- 2.7.0
|
|
9
|
+
before_install:
|
|
10
|
+
- gem install bundler -v 2.1.4
|
|
11
|
+
- bundle update --bundler
|
|
12
|
+
- bundle --version
|
|
13
|
+
env:
|
|
14
|
+
- build_type=ruby
|
|
15
|
+
script:
|
|
16
|
+
- cat Gemfile.lock
|
|
17
|
+
- bundle exec rubocop -V
|
|
18
|
+
- bundle exec rubocop -S
|
|
19
|
+
- bundle exec rubocop -d
|
|
20
|
+
- RAILS_ENV=test bundle exec rake test
|
|
21
|
+
|
|
22
|
+
after_script:
|
|
23
|
+
- ps -ejf --forest
|
|
24
|
+
- ssh-agent -k
|
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 cedric.degremont@facilecomm.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 [https://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: https://contributor-covenant.org
|
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
assertable (0.1.1)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ansi (1.5.0)
|
|
10
|
+
ast (2.4.0)
|
|
11
|
+
builder (3.2.4)
|
|
12
|
+
byebug (11.1.3)
|
|
13
|
+
coderay (1.1.3)
|
|
14
|
+
docile (1.3.2)
|
|
15
|
+
ffi (1.13.0)
|
|
16
|
+
formatador (0.2.5)
|
|
17
|
+
guard (2.16.2)
|
|
18
|
+
formatador (>= 0.2.4)
|
|
19
|
+
listen (>= 2.7, < 4.0)
|
|
20
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
21
|
+
nenv (~> 0.1)
|
|
22
|
+
notiffany (~> 0.0)
|
|
23
|
+
pry (>= 0.9.12)
|
|
24
|
+
shellany (~> 0.0)
|
|
25
|
+
thor (>= 0.18.1)
|
|
26
|
+
guard-compat (1.2.1)
|
|
27
|
+
guard-minitest (2.4.6)
|
|
28
|
+
guard-compat (~> 1.2)
|
|
29
|
+
minitest (>= 3.0)
|
|
30
|
+
listen (3.2.1)
|
|
31
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
32
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
33
|
+
lumberjack (1.2.5)
|
|
34
|
+
method_source (1.0.0)
|
|
35
|
+
minitest (5.14.1)
|
|
36
|
+
minitest-reporters (1.4.2)
|
|
37
|
+
ansi
|
|
38
|
+
builder
|
|
39
|
+
minitest (>= 5.0)
|
|
40
|
+
ruby-progressbar
|
|
41
|
+
mocha (1.11.2)
|
|
42
|
+
nenv (0.3.0)
|
|
43
|
+
notiffany (0.1.3)
|
|
44
|
+
nenv (~> 0.1)
|
|
45
|
+
shellany (~> 0.0)
|
|
46
|
+
parallel (1.19.1)
|
|
47
|
+
parser (2.7.1.3)
|
|
48
|
+
ast (~> 2.4.0)
|
|
49
|
+
pry (0.13.1)
|
|
50
|
+
coderay (~> 1.1)
|
|
51
|
+
method_source (~> 1.0)
|
|
52
|
+
rainbow (3.0.0)
|
|
53
|
+
rake (12.3.3)
|
|
54
|
+
rb-fsevent (0.10.4)
|
|
55
|
+
rb-inotify (0.10.1)
|
|
56
|
+
ffi (~> 1.0)
|
|
57
|
+
regexp_parser (1.7.0)
|
|
58
|
+
rexml (3.2.4)
|
|
59
|
+
rubocop (0.85.0)
|
|
60
|
+
parallel (~> 1.10)
|
|
61
|
+
parser (>= 2.7.0.1)
|
|
62
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
63
|
+
regexp_parser (>= 1.7)
|
|
64
|
+
rexml
|
|
65
|
+
rubocop-ast (>= 0.0.3)
|
|
66
|
+
ruby-progressbar (~> 1.7)
|
|
67
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
68
|
+
rubocop-ast (0.0.3)
|
|
69
|
+
parser (>= 2.7.0.1)
|
|
70
|
+
rubocop-performance (1.6.0)
|
|
71
|
+
rubocop (>= 0.71.0)
|
|
72
|
+
ruby-progressbar (1.10.1)
|
|
73
|
+
shellany (0.0.1)
|
|
74
|
+
simplecov (0.18.5)
|
|
75
|
+
docile (~> 1.1)
|
|
76
|
+
simplecov-html (~> 0.11)
|
|
77
|
+
simplecov-html (0.12.2)
|
|
78
|
+
thor (1.0.1)
|
|
79
|
+
unicode-display_width (1.7.0)
|
|
80
|
+
|
|
81
|
+
PLATFORMS
|
|
82
|
+
ruby
|
|
83
|
+
|
|
84
|
+
DEPENDENCIES
|
|
85
|
+
assertable!
|
|
86
|
+
bundler (~> 2.1, >= 2.1.4)
|
|
87
|
+
byebug (~> 11.1)
|
|
88
|
+
guard (~> 2.16)
|
|
89
|
+
guard-minitest (~> 2.4)
|
|
90
|
+
minitest (~> 5.0)
|
|
91
|
+
minitest-reporters (~> 1.4)
|
|
92
|
+
mocha (~> 1.11)
|
|
93
|
+
pry (~> 0.13)
|
|
94
|
+
rake (~> 12.0)
|
|
95
|
+
rubocop (~> 0.85)
|
|
96
|
+
rubocop-performance (~> 1.5)
|
|
97
|
+
simplecov (~> 0.18.5)
|
|
98
|
+
|
|
99
|
+
BUNDLED WITH
|
|
100
|
+
2.1.4
|
data/Guardfile
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'byebug'
|
|
4
|
+
|
|
5
|
+
# A sample Guardfile
|
|
6
|
+
# More info at https://github.com/guard/guard#readme
|
|
7
|
+
|
|
8
|
+
# Uncomment and set this to only include directories you want to watch
|
|
9
|
+
def check_dir_existence(dir)
|
|
10
|
+
return dir if Dir.exist?(dir)
|
|
11
|
+
|
|
12
|
+
UI.warning("Directory #{dir} does not exist")
|
|
13
|
+
false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
directories(
|
|
17
|
+
%w[lib test].select do |dir|
|
|
18
|
+
check_dir_existence(dir)
|
|
19
|
+
end
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
## Note: if you are using the `directories` clause above and you are not
|
|
23
|
+
## watching the project directory ('.'), then you will want to move
|
|
24
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
|
25
|
+
#
|
|
26
|
+
# $ mkdir config
|
|
27
|
+
# $ mv Guardfile config/
|
|
28
|
+
# $ ln -s config/Guardfile .
|
|
29
|
+
#
|
|
30
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
|
31
|
+
|
|
32
|
+
guard :minitest, all_on_start: false do
|
|
33
|
+
# with Minitest::Unit
|
|
34
|
+
watch(%r{^test/(.*)/?test_(.*)\.rb$})
|
|
35
|
+
watch(%r{^test/(.*)/?(.*)_test\.rb$})
|
|
36
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
|
37
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
|
38
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
|
39
|
+
|
|
40
|
+
# Rails 4
|
|
41
|
+
watch(%r{^lib/(.+)\.rb$}) do |m|
|
|
42
|
+
"test/lib/#{m[1]}_test.rb"
|
|
43
|
+
end
|
|
44
|
+
watch(%r{^test/.+_test\.rb$})
|
|
45
|
+
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
|
46
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Cedric Degremont
|
|
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/Makefile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Assertable
|
|
2
|
+
|
|
3
|
+
Allows for assertions in your code.
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
class Bottle
|
|
7
|
+
include Assertable
|
|
8
|
+
|
|
9
|
+
def initialize(volume_in_ml:)
|
|
10
|
+
assert volumne_in_ml > 0
|
|
11
|
+
@volume_in_ml = volume_in_ml
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
Bottle.new volume_in_ml: 1500
|
|
15
|
+
=> #<Bottle:0x000056533e319100>
|
|
16
|
+
|
|
17
|
+
Bottle.new volume_in_ml: -100
|
|
18
|
+
=> raises Assertable::Assertion
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Add this line to your application's Gemfile:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
gem 'assertable'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
And then execute:
|
|
30
|
+
|
|
31
|
+
$ bundle install
|
|
32
|
+
|
|
33
|
+
Or install it yourself as:
|
|
34
|
+
|
|
35
|
+
$ gem install assertable
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
Including in your class:
|
|
40
|
+
```ruby
|
|
41
|
+
class Bottle
|
|
42
|
+
include Assertable
|
|
43
|
+
|
|
44
|
+
def initialize(volume_in_ml:)
|
|
45
|
+
assert volumne_in_ml > 0
|
|
46
|
+
@volume_in_ml = volume_in_ml
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
Bottle.new volume_in_ml: 1500
|
|
50
|
+
=> #<Bottle:0x000056533e319100>
|
|
51
|
+
|
|
52
|
+
Bottle.new volume_in_ml: -100
|
|
53
|
+
=> raises Assertable::Assertion
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
We try to follow MiniTest style of assertions. Current list:
|
|
57
|
+
- assert_send
|
|
58
|
+
- assert
|
|
59
|
+
- assert_equal
|
|
60
|
+
- assert_includes
|
|
61
|
+
- assert_kind_of
|
|
62
|
+
- assert_nil
|
|
63
|
+
- refute
|
|
64
|
+
- refute_equal
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
Run `bundle exec rake test` to run the tests.
|
|
69
|
+
|
|
70
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
71
|
+
|
|
72
|
+
## Contributing
|
|
73
|
+
|
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Facilecomm/assertable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/assertable/blob/master/CODE_OF_CONDUCT.md).
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
80
|
+
|
|
81
|
+
## Code of Conduct
|
|
82
|
+
|
|
83
|
+
Everyone interacting in the Assertable project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Facilecomm/assertable/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/assertable.gemspec
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/assertable/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'assertable'
|
|
7
|
+
spec.version = Assertable::VERSION
|
|
8
|
+
spec.authors = ['Shippingbo']
|
|
9
|
+
spec.email = ['tech@facilecomm.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'Assertions in code (MiniTest-like syntax)'
|
|
12
|
+
spec.description = 'Allows for compact checks (Python style)'
|
|
13
|
+
spec.homepage = 'https://github.com/Facilecomm/assertable'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
|
16
|
+
|
|
17
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
18
|
+
|
|
19
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
|
20
|
+
# spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
|
|
21
|
+
# spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
|
|
22
|
+
|
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
|
24
|
+
# The `git ls-files -z` loads the files
|
|
25
|
+
# in the RubyGem that have been added into git.
|
|
26
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
spec.bindir = 'exe'
|
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
33
|
+
spec.require_paths = ['lib']
|
|
34
|
+
|
|
35
|
+
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
|
|
36
|
+
spec.add_development_dependency 'byebug', '~> 11.1'
|
|
37
|
+
spec.add_development_dependency 'guard', '~> 2.16'
|
|
38
|
+
spec.add_development_dependency 'guard-minitest', '~> 2.4'
|
|
39
|
+
spec.add_development_dependency 'minitest', '~> 5.11'
|
|
40
|
+
spec.add_development_dependency 'minitest-reporters', '~> 1.4'
|
|
41
|
+
spec.add_development_dependency 'mocha', '~> 1.11'
|
|
42
|
+
spec.add_development_dependency 'pry', '~> 0.13'
|
|
43
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
44
|
+
spec.add_development_dependency 'rubocop', '~> 0.85'
|
|
45
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.5'
|
|
46
|
+
spec.add_development_dependency 'simplecov', '~> 0.18.5'
|
|
47
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'assertable'
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/assertable.rb
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'assertable/version'
|
|
4
|
+
|
|
5
|
+
module Assertable
|
|
6
|
+
class Assertion < RuntimeError; end
|
|
7
|
+
class BadAssertionChoice < RuntimeError; end
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def assert_send(method_name)
|
|
12
|
+
assert(
|
|
13
|
+
send(method_name),
|
|
14
|
+
"Expected :#{method_name} to not be falsy, but it was."
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def assert(value_to_check, message = nil)
|
|
19
|
+
return if value_to_check
|
|
20
|
+
|
|
21
|
+
message ||= "Expected #{value_to_check.inspect} to be truthy."
|
|
22
|
+
raise Assertion, message
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def assert_equal(expected_value, actual_value, message = nil)
|
|
26
|
+
if expected_value.nil?
|
|
27
|
+
raise BadAssertionChoice, 'Use assert_nil when expecting nil'
|
|
28
|
+
end
|
|
29
|
+
return if expected_value == actual_value
|
|
30
|
+
|
|
31
|
+
message ||= [
|
|
32
|
+
"Expected: #{expected_value.inspect}",
|
|
33
|
+
"Actual: #{actual_value.inspect}"
|
|
34
|
+
].join("\n")
|
|
35
|
+
raise Assertion, message
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def assert_includes(ok_values, value, message = nil)
|
|
39
|
+
unless ok_values.is_a? Array
|
|
40
|
+
raise BadAssertionChoice, 'Use assert_equal if checking equality'
|
|
41
|
+
end
|
|
42
|
+
return if ok_values.include? value
|
|
43
|
+
|
|
44
|
+
message ||= [
|
|
45
|
+
value,
|
|
46
|
+
'is not included in',
|
|
47
|
+
ok_values.map(&:to_s).join(',')
|
|
48
|
+
].join ' '
|
|
49
|
+
raise Assertion, message
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def assert_kind_of(klass, object, message = nil)
|
|
53
|
+
return if object.is_a?(klass)
|
|
54
|
+
|
|
55
|
+
message ||= "Expected #{object.inspect} to be a #{klass}. But it was not."
|
|
56
|
+
raise Assertion, message
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def assert_nil(value_to_check, message = nil)
|
|
60
|
+
return if value_to_check.nil?
|
|
61
|
+
|
|
62
|
+
message ||= "Expected #{value_to_check.inspect} to be nil."
|
|
63
|
+
raise Assertion, message
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def refute(value_to_check, message = nil)
|
|
67
|
+
return unless value_to_check
|
|
68
|
+
|
|
69
|
+
message ||= "Expected #{value_to_check.inspect} to be falsy."
|
|
70
|
+
raise Assertion, message
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def refute_equal(expected_value, actual_value, message = nil)
|
|
74
|
+
return unless expected_value == actual_value
|
|
75
|
+
|
|
76
|
+
message ||= [
|
|
77
|
+
"Expected #{actual_value.inspect} to not be equal to",
|
|
78
|
+
"#{expected_value.inspect}."
|
|
79
|
+
].join(' ')
|
|
80
|
+
raise Assertion, message
|
|
81
|
+
end
|
|
82
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: assertable
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Shippingbo
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-06-05 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: '2.1'
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 2.1.4
|
|
23
|
+
type: :development
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '2.1'
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 2.1.4
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: byebug
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '11.1'
|
|
40
|
+
type: :development
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '11.1'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: guard
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.16'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '2.16'
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: guard-minitest
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '2.4'
|
|
68
|
+
type: :development
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '2.4'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: minitest
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '5.11'
|
|
82
|
+
type: :development
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '5.11'
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
name: minitest-reporters
|
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '1.4'
|
|
96
|
+
type: :development
|
|
97
|
+
prerelease: false
|
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '1.4'
|
|
103
|
+
- !ruby/object:Gem::Dependency
|
|
104
|
+
name: mocha
|
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '1.11'
|
|
110
|
+
type: :development
|
|
111
|
+
prerelease: false
|
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '1.11'
|
|
117
|
+
- !ruby/object:Gem::Dependency
|
|
118
|
+
name: pry
|
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0.13'
|
|
124
|
+
type: :development
|
|
125
|
+
prerelease: false
|
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - "~>"
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '0.13'
|
|
131
|
+
- !ruby/object:Gem::Dependency
|
|
132
|
+
name: rake
|
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - "~>"
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '13.0'
|
|
138
|
+
type: :development
|
|
139
|
+
prerelease: false
|
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - "~>"
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '13.0'
|
|
145
|
+
- !ruby/object:Gem::Dependency
|
|
146
|
+
name: rubocop
|
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
|
148
|
+
requirements:
|
|
149
|
+
- - "~>"
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: '0.85'
|
|
152
|
+
type: :development
|
|
153
|
+
prerelease: false
|
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - "~>"
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: '0.85'
|
|
159
|
+
- !ruby/object:Gem::Dependency
|
|
160
|
+
name: rubocop-performance
|
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
|
162
|
+
requirements:
|
|
163
|
+
- - "~>"
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: '1.5'
|
|
166
|
+
type: :development
|
|
167
|
+
prerelease: false
|
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
169
|
+
requirements:
|
|
170
|
+
- - "~>"
|
|
171
|
+
- !ruby/object:Gem::Version
|
|
172
|
+
version: '1.5'
|
|
173
|
+
- !ruby/object:Gem::Dependency
|
|
174
|
+
name: simplecov
|
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
|
176
|
+
requirements:
|
|
177
|
+
- - "~>"
|
|
178
|
+
- !ruby/object:Gem::Version
|
|
179
|
+
version: 0.18.5
|
|
180
|
+
type: :development
|
|
181
|
+
prerelease: false
|
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
183
|
+
requirements:
|
|
184
|
+
- - "~>"
|
|
185
|
+
- !ruby/object:Gem::Version
|
|
186
|
+
version: 0.18.5
|
|
187
|
+
description: Allows for compact checks (Python style)
|
|
188
|
+
email:
|
|
189
|
+
- tech@facilecomm.com
|
|
190
|
+
executables: []
|
|
191
|
+
extensions: []
|
|
192
|
+
extra_rdoc_files: []
|
|
193
|
+
files:
|
|
194
|
+
- ".gitignore"
|
|
195
|
+
- ".rubocop.yml"
|
|
196
|
+
- ".ruby_version"
|
|
197
|
+
- ".travis.yml"
|
|
198
|
+
- CODE_OF_CONDUCT.md
|
|
199
|
+
- Gemfile
|
|
200
|
+
- Gemfile.lock
|
|
201
|
+
- Guardfile
|
|
202
|
+
- LICENSE.txt
|
|
203
|
+
- Makefile
|
|
204
|
+
- README.md
|
|
205
|
+
- Rakefile
|
|
206
|
+
- assertable.gemspec
|
|
207
|
+
- bin/console
|
|
208
|
+
- bin/setup
|
|
209
|
+
- lib/assertable.rb
|
|
210
|
+
- lib/assertable/version.rb
|
|
211
|
+
homepage: https://github.com/Facilecomm/assertable
|
|
212
|
+
licenses:
|
|
213
|
+
- MIT
|
|
214
|
+
metadata: {}
|
|
215
|
+
post_install_message:
|
|
216
|
+
rdoc_options: []
|
|
217
|
+
require_paths:
|
|
218
|
+
- lib
|
|
219
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
|
+
requirements:
|
|
221
|
+
- - ">="
|
|
222
|
+
- !ruby/object:Gem::Version
|
|
223
|
+
version: 2.6.0
|
|
224
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
|
+
requirements:
|
|
226
|
+
- - ">="
|
|
227
|
+
- !ruby/object:Gem::Version
|
|
228
|
+
version: '0'
|
|
229
|
+
requirements: []
|
|
230
|
+
rubygems_version: 3.0.1
|
|
231
|
+
signing_key:
|
|
232
|
+
specification_version: 4
|
|
233
|
+
summary: Assertions in code (MiniTest-like syntax)
|
|
234
|
+
test_files: []
|