shoulda-matchers-uuid 0.1.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +140 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +75 -0
- data/CHANGELOG.md +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +99 -0
- data/LICENSE.txt +13 -0
- data/README.md +44 -0
- data/Rakefile +9 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/shoulda/matchers/uuid.rb +46 -0
- data/lib/shoulda/matchers/uuid/version.rb +9 -0
- data/shoulda-matchers-uuid.gemspec +44 -0
- metadata +260 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35ce969e8021c6c4211733e9c06db6a6e3cef4b5cc46f165116fd4fcda4114b1
|
4
|
+
data.tar.gz: d03adac5b7bb0527d0904e812aef23872892d0c4f6e8b5fd1b71712ab319f8af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50586b433c71e9a613964476850dfafeba41a8355d1cc4799c6c976995388feb31ced51b9ecadaf192b91aab321a246e7352b2238db3b8dad26f82e4f653ef5e
|
7
|
+
data.tar.gz: 408f646ca37ef221a03e0c6edd53bd6d29bbc593f3bd316df35e14321030eb4e6c4984310ca52cfa6d542cc8e836dc67b23e71cb71b3bd2bc6052201d7a9f442
|
@@ -0,0 +1,140 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
orbs:
|
4
|
+
gem: doximity/gem-publisher@0
|
5
|
+
|
6
|
+
executors:
|
7
|
+
ruby-latest:
|
8
|
+
resource_class: small
|
9
|
+
docker:
|
10
|
+
- image: circleci/ruby:2.6
|
11
|
+
environment:
|
12
|
+
BUNDLE_VERSION: "~> 1.17"
|
13
|
+
- image: circleci/mysql:5.6
|
14
|
+
|
15
|
+
# yaml anchor filters
|
16
|
+
master_only: &master_only
|
17
|
+
filters:
|
18
|
+
branches:
|
19
|
+
only: master
|
20
|
+
tags:
|
21
|
+
ignore: /.*/
|
22
|
+
pr_only: &pr_only
|
23
|
+
filters:
|
24
|
+
branches:
|
25
|
+
ignore: master
|
26
|
+
tags:
|
27
|
+
ignore: /.*/
|
28
|
+
version_tags_only: &version_tags_only
|
29
|
+
filters:
|
30
|
+
branches:
|
31
|
+
ignore: /.*/
|
32
|
+
tags:
|
33
|
+
only: /^v.*/
|
34
|
+
|
35
|
+
jobs:
|
36
|
+
build:
|
37
|
+
executor: ruby-latest
|
38
|
+
steps:
|
39
|
+
- checkout
|
40
|
+
- run:
|
41
|
+
name: Install Bundler specific version
|
42
|
+
command: |
|
43
|
+
gem install bundler --version "${BUNDLE_VERSION}" --force
|
44
|
+
- restore_cache:
|
45
|
+
keys:
|
46
|
+
- v1-bundle-{{ checksum "Gemfile.lock" }}-
|
47
|
+
- run:
|
48
|
+
name: Install Ruby Dependencies
|
49
|
+
command: bundle check --path=vendor/bundle || bundle install --local --frozen --path=vendor/bundle --jobs=4 --retry=3
|
50
|
+
- save_cache:
|
51
|
+
key: v1-bundle-{{ checksum "Gemfile.lock" }}-
|
52
|
+
paths:
|
53
|
+
- vendor/bundle
|
54
|
+
- run:
|
55
|
+
name: Load mysql database from workspace
|
56
|
+
command: |
|
57
|
+
apt-get update -qq && apt-get install -y --no-install-recommends mysql-client
|
58
|
+
until `nc -z 127.0.0.1 3306`; do
|
59
|
+
echo 'Waiting for MySQL container...'
|
60
|
+
sleep 1
|
61
|
+
done
|
62
|
+
echo 'MySQL container is up'
|
63
|
+
- run:
|
64
|
+
name: Run Tests
|
65
|
+
command: bundle exec rake ci:specs
|
66
|
+
environment:
|
67
|
+
DATABASE_URL: mysql2://127.0.0.1:3306
|
68
|
+
- store_test_results:
|
69
|
+
name: Store test results
|
70
|
+
path: tmp/test-results
|
71
|
+
- run:
|
72
|
+
name: Run Rubocop
|
73
|
+
command: bundle exec rake ci:rubocop
|
74
|
+
- run:
|
75
|
+
name: Build documentation
|
76
|
+
command: bundle exec rake ci:doc
|
77
|
+
- store_artifacts:
|
78
|
+
name: Saves documentation
|
79
|
+
path: doc
|
80
|
+
- persist_to_workspace:
|
81
|
+
root: .
|
82
|
+
paths:
|
83
|
+
- vendor/bundle
|
84
|
+
|
85
|
+
workflows:
|
86
|
+
version: 2
|
87
|
+
|
88
|
+
trunk:
|
89
|
+
jobs:
|
90
|
+
- build:
|
91
|
+
<<: *master_only
|
92
|
+
- gem/build:
|
93
|
+
<<: *master_only
|
94
|
+
executor: ruby-latest
|
95
|
+
name: gem-build
|
96
|
+
requires:
|
97
|
+
- build
|
98
|
+
|
99
|
+
pull-requests:
|
100
|
+
jobs:
|
101
|
+
- build:
|
102
|
+
<<: *pr_only
|
103
|
+
- gem/build:
|
104
|
+
<<: *pr_only
|
105
|
+
executor: ruby-latest
|
106
|
+
name: gem-build
|
107
|
+
requires:
|
108
|
+
- build
|
109
|
+
- pre-release-approval:
|
110
|
+
<<: *pr_only
|
111
|
+
type: approval
|
112
|
+
requires:
|
113
|
+
- gem-build
|
114
|
+
- gem/publish:
|
115
|
+
<<: *pr_only
|
116
|
+
name: gem-publish
|
117
|
+
to_rubygems: true
|
118
|
+
pre_release: true
|
119
|
+
requires:
|
120
|
+
- pre-release-approval
|
121
|
+
context: artifact_publishing
|
122
|
+
|
123
|
+
final-release:
|
124
|
+
jobs:
|
125
|
+
- build:
|
126
|
+
<<: *version_tags_only
|
127
|
+
- gem/build:
|
128
|
+
<<: *version_tags_only
|
129
|
+
executor: ruby-latest
|
130
|
+
name: gem-build
|
131
|
+
requires:
|
132
|
+
- build
|
133
|
+
- gem/publish:
|
134
|
+
<<: *version_tags_only
|
135
|
+
name: gem-publish
|
136
|
+
to_rubygems: true
|
137
|
+
pre_release: false
|
138
|
+
requires:
|
139
|
+
- gem-build
|
140
|
+
context: artifact_publishing
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rails
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
Exclude:
|
7
|
+
- "./vendor/**/*"
|
8
|
+
TargetRubyVersion: 2.6
|
9
|
+
|
10
|
+
Layout/DotPosition:
|
11
|
+
EnforcedStyle: trailing
|
12
|
+
Enabled: true
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
Lint/AmbiguousBlockAssociation:
|
17
|
+
Exclude:
|
18
|
+
- ./**/*_spec.rb
|
19
|
+
Lint/UselessAccessModifier:
|
20
|
+
ContextCreatingMethods:
|
21
|
+
- concerning
|
22
|
+
|
23
|
+
Metrics/AbcSize:
|
24
|
+
Max: 20
|
25
|
+
Metrics/BlockLength:
|
26
|
+
Exclude:
|
27
|
+
- "./**/*_spec*.rb"
|
28
|
+
- "./*.gemspec"
|
29
|
+
- "./spec/*_helper*.rb"
|
30
|
+
- "./tasks/ci.rake"
|
31
|
+
- "./lib/tasks/**/*.rake"
|
32
|
+
- "Gemfile"
|
33
|
+
Metrics/CyclomaticComplexity:
|
34
|
+
Max: 7
|
35
|
+
Metrics/ModuleLength:
|
36
|
+
Exclude:
|
37
|
+
- "./**/*_spec*.rb"
|
38
|
+
Metrics/MethodLength:
|
39
|
+
Max: 20
|
40
|
+
Exclude:
|
41
|
+
- "./**/*_spec*.rb"
|
42
|
+
Metrics/PerceivedComplexity:
|
43
|
+
Max: 8
|
44
|
+
|
45
|
+
RSpec/BeforeAfterAll:
|
46
|
+
Enabled: false
|
47
|
+
RSpec/ExampleLength:
|
48
|
+
Enabled: false
|
49
|
+
RSpec/IteratedExpectation:
|
50
|
+
Enabled: false
|
51
|
+
RSpec/FilePath:
|
52
|
+
Enabled: false
|
53
|
+
RSpec/MultipleExpectations:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Rails/ApplicationRecord:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
Security/YAMLLoad:
|
60
|
+
AutoCorrect: false
|
61
|
+
|
62
|
+
Style/Documentation:
|
63
|
+
Enabled: false
|
64
|
+
Style/FormatStringToken:
|
65
|
+
EnforcedStyle: template
|
66
|
+
Style/LambdaCall:
|
67
|
+
Enabled: false
|
68
|
+
Style/NumericLiterals:
|
69
|
+
Enabled: false
|
70
|
+
Style/StringLiterals:
|
71
|
+
EnforcedStyle: double_quotes
|
72
|
+
ConsistentQuotesInMultiline: true
|
73
|
+
Enabled: true
|
74
|
+
Style/StringLiteralsInInterpolation:
|
75
|
+
EnforcedStyle: double_quotes
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Changelog
|
2
|
+
=========
|
3
|
+
|
4
|
+
## 0.1.2.pre 02/25/2020
|
5
|
+
* Updates CircleCi config to release to Rubygems
|
6
|
+
* Cleans gemspec/readme to be open-source compatable
|
7
|
+
* Updates .rubocop.yml to work for everyone
|
8
|
+
|
9
|
+
## 0.1.1 02/06/2020
|
10
|
+
* Adds CircleCi config
|
11
|
+
* Release on Nexus using gem-publisher CircleCI Orb
|
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 vstoll@doximity.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,99 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shoulda-matchers-uuid (0.1.2.pre)
|
5
|
+
shoulda-matchers
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (6.0.2.1)
|
11
|
+
activesupport (= 6.0.2.1)
|
12
|
+
activerecord (6.0.2.1)
|
13
|
+
activemodel (= 6.0.2.1)
|
14
|
+
activesupport (= 6.0.2.1)
|
15
|
+
activesupport (6.0.2.1)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 0.7, < 2)
|
18
|
+
minitest (~> 5.1)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
zeitwerk (~> 2.2)
|
21
|
+
ast (2.4.0)
|
22
|
+
byebug (11.1.1)
|
23
|
+
concurrent-ruby (1.1.6)
|
24
|
+
diff-lcs (1.3)
|
25
|
+
i18n (1.8.2)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
jaro_winkler (1.5.4)
|
28
|
+
minitest (5.14.0)
|
29
|
+
mysql-binuuid-rails (1.2.1)
|
30
|
+
activerecord (>= 5)
|
31
|
+
mysql2 (0.5.3)
|
32
|
+
parallel (1.19.1)
|
33
|
+
parser (2.7.0.2)
|
34
|
+
ast (~> 2.4.0)
|
35
|
+
rack (2.2.2)
|
36
|
+
rainbow (3.0.0)
|
37
|
+
rake (13.0.1)
|
38
|
+
rdoc (6.2.1)
|
39
|
+
rexml (3.2.4)
|
40
|
+
rspec (3.9.0)
|
41
|
+
rspec-core (~> 3.9.0)
|
42
|
+
rspec-expectations (~> 3.9.0)
|
43
|
+
rspec-mocks (~> 3.9.0)
|
44
|
+
rspec-core (3.9.1)
|
45
|
+
rspec-support (~> 3.9.1)
|
46
|
+
rspec-expectations (3.9.0)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.9.0)
|
49
|
+
rspec-mocks (3.9.1)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.9.0)
|
52
|
+
rspec-support (3.9.2)
|
53
|
+
rspec_junit_formatter (0.4.1)
|
54
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
55
|
+
rubocop (0.80.0)
|
56
|
+
jaro_winkler (~> 1.5.1)
|
57
|
+
parallel (~> 1.10)
|
58
|
+
parser (>= 2.7.0.1)
|
59
|
+
rainbow (>= 2.2.2, < 4.0)
|
60
|
+
rexml
|
61
|
+
ruby-progressbar (~> 1.7)
|
62
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
63
|
+
rubocop-rails (2.2.1)
|
64
|
+
rack (>= 1.1)
|
65
|
+
rubocop (>= 0.72.0)
|
66
|
+
rubocop-rspec (1.37.1)
|
67
|
+
rubocop (>= 0.68.1)
|
68
|
+
ruby-progressbar (1.10.1)
|
69
|
+
sdoc (1.0.0)
|
70
|
+
rdoc (>= 5.0)
|
71
|
+
shoulda-matchers (4.3.0)
|
72
|
+
activesupport (>= 4.2.0)
|
73
|
+
thread_safe (0.3.6)
|
74
|
+
tzinfo (1.2.6)
|
75
|
+
thread_safe (~> 0.1)
|
76
|
+
unicode-display_width (1.6.1)
|
77
|
+
zeitwerk (2.2.2)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
activemodel (> 5.0)
|
84
|
+
activerecord (> 4)
|
85
|
+
bundler
|
86
|
+
byebug
|
87
|
+
mysql-binuuid-rails
|
88
|
+
mysql2
|
89
|
+
rake
|
90
|
+
rspec
|
91
|
+
rspec_junit_formatter
|
92
|
+
rubocop
|
93
|
+
rubocop-rails
|
94
|
+
rubocop-rspec
|
95
|
+
sdoc
|
96
|
+
shoulda-matchers-uuid!
|
97
|
+
|
98
|
+
BUNDLED WITH
|
99
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2016 Doximity, Inc.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# shoulda-matchers-uuid
|
2
|
+
|
3
|
+
This is a patch to shoulda-matchers that allows the uniqueness validation matchers to work with MySQL UUIDs. The current shoulda-matchers gem incorrectly increments UUID values when they are set as `binary` types (when using the [mysql-binuuid-rails gem](https://github.com/nedap/mysql-binuuid-rails)).
|
4
|
+
|
5
|
+
See [the original shoulda-matchers PR](https://github.com/thoughtbot/shoulda-matchers/pull/1159) that is likely not going to make it through.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'shoulda-matchers-uuid'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install shoulda-matchers-uuid
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
That's it! Use shoulda-matchers as usual to validate uniqueness of UUIDs.
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
Pre-requisite: `brew install mysql`, or whatever version of MySQL you prefer. We use this in our tests to verify that the full integration works as expected.
|
30
|
+
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/doximity/shoulda-matchers-uuid. 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/doximity/shoulda-matchers-uuid/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## Code of Conduct
|
39
|
+
|
40
|
+
Everyone interacting in the Shoulda::Matchers::Uuid project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/doximity/shoulda-matchers-uuid/blob/master/CODE_OF_CONDUCT.md).
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
The gem is available as open source under the terms of the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).
|
data/Rakefile
ADDED
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 "shoulda/matchers/uuid"
|
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
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
require "shoulda/matchers"
|
5
|
+
|
6
|
+
module ShouldaMatchersMysqlUuidFix
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
# rubocop:disable Metrics/BlockLength
|
10
|
+
included do
|
11
|
+
def next_scalar_value_for(scope, previous_value)
|
12
|
+
if uuid?(scope)
|
13
|
+
SecureRandom.uuid
|
14
|
+
elsif defined_as_enum?(scope)
|
15
|
+
available_values = available_enum_values_for(scope, previous_value)
|
16
|
+
available_values.keys.last
|
17
|
+
elsif polymorphic_type_attribute?(scope, previous_value)
|
18
|
+
Uniqueness::TestModels.create(previous_value).to_s
|
19
|
+
elsif previous_value.respond_to?(:next)
|
20
|
+
previous_value.next
|
21
|
+
elsif previous_value.respond_to?(:to_datetime)
|
22
|
+
previous_value.to_datetime.next
|
23
|
+
elsif boolean_value?(previous_value)
|
24
|
+
!previous_value
|
25
|
+
else
|
26
|
+
previous_value.to_s.next
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def uuid?(scope)
|
31
|
+
[
|
32
|
+
column_for(scope),
|
33
|
+
attribute_type_for(scope)
|
34
|
+
].compact.map(&:type).include? :uuid
|
35
|
+
end
|
36
|
+
|
37
|
+
def attribute_type_for(scope)
|
38
|
+
return unless model.respond_to?(:attribute_types)
|
39
|
+
|
40
|
+
model.attribute_types[scope.to_s]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
# rubocop:enable Metrics/BlockLength
|
44
|
+
end
|
45
|
+
|
46
|
+
Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher.include ShouldaMatchersMysqlUuidFix
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/shoulda/matchers/uuid/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "shoulda-matchers-uuid"
|
7
|
+
spec.version = Shoulda::Matchers::Uuid::VERSION
|
8
|
+
spec.authors = ["Valentino Stoll", "Ben Simpson"]
|
9
|
+
spec.email = ["vstoll@doximity.com", "bsimpson@doximity.com"]
|
10
|
+
|
11
|
+
spec.summary = "Adds support for MYSQL uuids in shoulda-matchers context"
|
12
|
+
spec.description = "This extends shoulda-matchers to allow validating binary uuids in models."
|
13
|
+
spec.homepage = "https://github.com/doximity/shoulda-matchers-uuid"
|
14
|
+
spec.license = "Apache-2.0"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/doximity/shoulda-matchers-uuid"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/doximity/shoulda-matchers-uuid/blob/master/CHANGELOG.md"
|
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(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|vendor|tasks|tmp)/}) }
|
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 "shoulda-matchers"
|
30
|
+
|
31
|
+
spec.add_development_dependency "activemodel", "> 5.0"
|
32
|
+
spec.add_development_dependency "activerecord", "> 4"
|
33
|
+
spec.add_development_dependency "bundler"
|
34
|
+
spec.add_development_dependency "byebug"
|
35
|
+
spec.add_development_dependency "mysql-binuuid-rails"
|
36
|
+
spec.add_development_dependency "mysql2"
|
37
|
+
spec.add_development_dependency "rake"
|
38
|
+
spec.add_development_dependency "rspec"
|
39
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
40
|
+
spec.add_development_dependency "rubocop"
|
41
|
+
spec.add_development_dependency "rubocop-rails"
|
42
|
+
spec.add_development_dependency "rubocop-rspec"
|
43
|
+
spec.add_development_dependency "sdoc"
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shoulda-matchers-uuid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Valentino Stoll
|
8
|
+
- Ben Simpson
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: shoulda-matchers
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activemodel
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '5.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '5.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: activerecord
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '4'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '4'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: bundler
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: byebug
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: mysql-binuuid-rails
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: mysql2
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rake
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rspec
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rspec_junit_formatter
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: rubocop
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: rubocop-rails
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: rubocop-rspec
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
- !ruby/object:Gem::Dependency
|
197
|
+
name: sdoc
|
198
|
+
requirement: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
type: :development
|
204
|
+
prerelease: false
|
205
|
+
version_requirements: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
description: This extends shoulda-matchers to allow validating binary uuids in models.
|
211
|
+
email:
|
212
|
+
- vstoll@doximity.com
|
213
|
+
- bsimpson@doximity.com
|
214
|
+
executables: []
|
215
|
+
extensions: []
|
216
|
+
extra_rdoc_files: []
|
217
|
+
files:
|
218
|
+
- ".circleci/config.yml"
|
219
|
+
- ".gitignore"
|
220
|
+
- ".rspec"
|
221
|
+
- ".rubocop.yml"
|
222
|
+
- CHANGELOG.md
|
223
|
+
- CODE_OF_CONDUCT.md
|
224
|
+
- Gemfile
|
225
|
+
- Gemfile.lock
|
226
|
+
- LICENSE.txt
|
227
|
+
- README.md
|
228
|
+
- Rakefile
|
229
|
+
- bin/console
|
230
|
+
- bin/setup
|
231
|
+
- lib/shoulda/matchers/uuid.rb
|
232
|
+
- lib/shoulda/matchers/uuid/version.rb
|
233
|
+
- shoulda-matchers-uuid.gemspec
|
234
|
+
homepage: https://github.com/doximity/shoulda-matchers-uuid
|
235
|
+
licenses:
|
236
|
+
- Apache-2.0
|
237
|
+
metadata:
|
238
|
+
homepage_uri: https://github.com/doximity/shoulda-matchers-uuid
|
239
|
+
source_code_uri: https://github.com/doximity/shoulda-matchers-uuid
|
240
|
+
changelog_uri: https://github.com/doximity/shoulda-matchers-uuid/blob/master/CHANGELOG.md
|
241
|
+
post_install_message:
|
242
|
+
rdoc_options: []
|
243
|
+
require_paths:
|
244
|
+
- lib
|
245
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - ">="
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: '0'
|
250
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
251
|
+
requirements:
|
252
|
+
- - ">"
|
253
|
+
- !ruby/object:Gem::Version
|
254
|
+
version: 1.3.1
|
255
|
+
requirements: []
|
256
|
+
rubygems_version: 3.0.3
|
257
|
+
signing_key:
|
258
|
+
specification_version: 4
|
259
|
+
summary: Adds support for MYSQL uuids in shoulda-matchers context
|
260
|
+
test_files: []
|