rspec-uuid 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4e842761ec28b372bbb63629058b3a67c0cdb822af9b809388be813b5671f6c6
4
+ data.tar.gz: 68ce117e6e041a56184781a548bef376185dfad070bf4dd32492643872d550a8
5
+ SHA512:
6
+ metadata.gz: 869b71a5eddce1e8a6789ba1850e77cb8fdba899919615f041527839af2c98f9bb69cd94aa0488c15fca6e975b08d4f144d08e2f06b57b9391c73a16360d98de
7
+ data.tar.gz: 9ab3472cccbec91a3925fd59265e39fff337fc528bca36d58b2bc1e600c0b4a072fd0d0e0f1db3e898d3ac0afeec9656bec12e456a4d5c9ae5e9658853b1a495
@@ -0,0 +1,28 @@
1
+ module RSpecUUID
2
+ module Matchers
3
+ class UUIDMatcher
4
+ def matches?(obj)
5
+ return false unless obj.is_a?(String)
6
+
7
+ # https://www.uuidtools.com/what-is-uuid
8
+ obj.match? /^\h{8}-\h{4}-\h{4}-\h{4}-\h{12}$/
9
+ end
10
+
11
+ def description
12
+ "be a UUID"
13
+ end
14
+
15
+ def failure_message
16
+ "expected a UUID"
17
+ end
18
+
19
+ def failure_message_when_negated
20
+ "did not expect a UUID"
21
+ end
22
+ end
23
+
24
+ def be_a_uuid
25
+ UUIDMatcher.new
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module RSpecUUID
2
+ VERSION = "0.1.0"
3
+ end
data/lib/rspec-uuid.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "rspec/core"
2
+ require "rspec/expectations"
3
+ require "rspec-uuid/matchers"
4
+ require "rspec-uuid/version"
5
+
6
+ RSpec.configure do |config|
7
+ config.include(RSpecUUID::Matchers)
8
+ end
@@ -0,0 +1,32 @@
1
+ describe RSpecUUID::Matchers do
2
+ context "with a valid UUID" do
3
+ let(:uuid) { "992c94bd-5870-4e02-ad2d-a9435f7fffe6" }
4
+
5
+ specify { expect(uuid).to be_a_uuid }
6
+ end
7
+
8
+ context "with Faker UUIDs" do
9
+ specify do
10
+ 100.times { expect(Faker::Internet.uuid).to be_a_uuid }
11
+ end
12
+ end
13
+
14
+ context "with invalid UUIDs" do
15
+ specify { expect("abc").not_to be_a_uuid }
16
+ specify { expect(:xyz).not_to be_a_uuid }
17
+ specify { expect(123).not_to be_a_uuid }
18
+ specify { expect(nil).not_to be_a_uuid }
19
+ end
20
+
21
+ it "fails with a useful message" do
22
+ expect {
23
+ expect(nil).to be_a_uuid
24
+ }.to fail_including("expected a UUID")
25
+ end
26
+
27
+ it "fails with a useful negation message" do
28
+ expect {
29
+ expect(Faker::Internet.uuid).not_to be_a_uuid
30
+ }.to fail_including("did not expect a UUID")
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-uuid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Pepper
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: codecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: faker
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '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: '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: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: RSpec UUID matcher
84
+ email:
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - lib/rspec-uuid.rb
90
+ - lib/rspec-uuid/matchers.rb
91
+ - lib/rspec-uuid/version.rb
92
+ - spec/matchers_spec.rb
93
+ homepage: https://github.com/dpep/rspec-uuid
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubygems_version: 3.1.6
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: RSpecUUID
116
+ test_files:
117
+ - spec/matchers_spec.rb