mongoid7-rspec-callbacks 1.0.0.pre.816289031
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +674 -0
- data/Gemfile +6 -0
- data/LICENSE +14 -0
- data/README.md +65 -0
- data/Rakefile +8 -0
- data/lib/matchers/association_callbacks.rb +86 -0
- data/lib/matchers/callbacks.rb +157 -0
- data/lib/matchers/set_callbacks.rb +78 -0
- data/lib/mongoid-rspec-callbacks/info.rb +35 -0
- data/lib/mongoid_rspec_callbacks.rb +6 -0
- data/spec/band_spec.rb +8 -0
- data/spec/profile_spec.rb +10 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/studio_spec.rb +8 -0
- data/spec/support/models/band.rb +18 -0
- data/spec/support/models/profile.rb +33 -0
- data/spec/support/models/studio.rb +20 -0
- data/spec/support/models/user.rb +29 -0
- data/spec/user_spec.rb +26 -0
- metadata +251 -0
data/spec/band_spec.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Band do
|
6
|
+
it { is_expected.to association_callback(:has_many, :add, :after, :send_email_to_subscribers) }
|
7
|
+
it { is_expected.to association_callback(:has_many, :add, :before, :send_email_to_unsubscribers) }
|
8
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Profile do
|
6
|
+
it { is_expected.to callback(:callback_before_save).before(:save) }
|
7
|
+
it { is_expected.to callback(:callback_after_save).after(:save) }
|
8
|
+
it { is_expected.to callback(:callback_before_validation, :callback_before_validation_x).before(:validation) }
|
9
|
+
it { is_expected.to callback(:callback_after_validation).after(:validation).on(:create) }
|
10
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mongoid_rspec_callbacks'
|
4
|
+
require 'simplecov'
|
5
|
+
require 'simplecov_json_formatter'
|
6
|
+
|
7
|
+
SimpleCov.start
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
11
|
+
|
12
|
+
Dir['spec/support/**/*.rb'].each do |f|
|
13
|
+
require File.expand_path(f)
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# Stop when rspec fail
|
18
|
+
config.fail_fast = false
|
19
|
+
|
20
|
+
# Exclude spec broken
|
21
|
+
config.filter_run_excluding broken: true
|
22
|
+
|
23
|
+
config.include Mongoid::Matchers
|
24
|
+
end
|
data/spec/studio_spec.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Studio do
|
6
|
+
it { is_expected.to association_callback(:has_many, :remove, :after, :send_notification_subscribers) }
|
7
|
+
it { is_expected.to association_callback(:has_many, :remove, :before, :send_notification_unsubscribers) }
|
8
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Band
|
4
|
+
include Mongoid::Document
|
5
|
+
|
6
|
+
has_many :studio, {
|
7
|
+
before_add: :send_notification_subscribers,
|
8
|
+
after_add: :send_email_to_subscribers
|
9
|
+
}
|
10
|
+
|
11
|
+
def send_email_to_subscribers
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def send_email_to_unsubscribers
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Profile
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps::Short
|
6
|
+
include Mongoid::Attributes::Dynamic
|
7
|
+
|
8
|
+
before_save :callback_before_save
|
9
|
+
after_save :callback_after_save
|
10
|
+
|
11
|
+
before_validation :callback_before_validation, :callback_before_validation_x
|
12
|
+
after_validation :callback_after_validation, on: :create
|
13
|
+
|
14
|
+
def callback_before_save
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def callback_after_save
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def callback_before_validation
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def callback_before_validation_x
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def callback_after_validation
|
31
|
+
true
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Studio
|
4
|
+
include Mongoid::Document
|
5
|
+
|
6
|
+
belongs_to :band
|
7
|
+
|
8
|
+
has_many :user, {
|
9
|
+
before_remove: :send_notification_unsubscribers,
|
10
|
+
after_remove: :send_email_to_unsubscribers
|
11
|
+
}
|
12
|
+
|
13
|
+
def send_notification_subscribers
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def send_notification_unsubscribers
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class User
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
set_callback(:initialize, :after)
|
8
|
+
set_callback(:build, :after)
|
9
|
+
set_callback(:validation, :before)
|
10
|
+
set_callback(:validation, :after)
|
11
|
+
set_callback(:create, :before)
|
12
|
+
set_callback(:create, :arround)
|
13
|
+
set_callback(:create, :after)
|
14
|
+
set_callback(:find, :after)
|
15
|
+
set_callback(:update, :before)
|
16
|
+
set_callback(:update, :arround)
|
17
|
+
set_callback(:update, :after)
|
18
|
+
set_callback(:upsert, :before)
|
19
|
+
set_callback(:upsert, :arround)
|
20
|
+
set_callback(:upsert, :after)
|
21
|
+
set_callback(:save, :before)
|
22
|
+
set_callback(:save, :arround)
|
23
|
+
set_callback(:save, :after)
|
24
|
+
set_callback(:destroy, :before)
|
25
|
+
set_callback(:destroy, :arround)
|
26
|
+
set_callback(:destroy, :after)
|
27
|
+
|
28
|
+
belongs_to :studio
|
29
|
+
end
|
data/spec/user_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe User do
|
6
|
+
it { is_expected.to set_callback(:initialize, :after) }
|
7
|
+
it { is_expected.to set_callback(:build, :after) }
|
8
|
+
it { is_expected.to set_callback(:validation, :before) }
|
9
|
+
it { is_expected.to set_callback(:validation, :after) }
|
10
|
+
it { is_expected.to set_callback(:create, :before) }
|
11
|
+
it { is_expected.to set_callback(:create, :arround) }
|
12
|
+
it { is_expected.to set_callback(:create, :after) }
|
13
|
+
it { is_expected.to set_callback(:find, :after) }
|
14
|
+
it { is_expected.to set_callback(:update, :before) }
|
15
|
+
it { is_expected.to set_callback(:update, :arround) }
|
16
|
+
it { is_expected.to set_callback(:update, :after) }
|
17
|
+
it { is_expected.to set_callback(:upsert, :before) }
|
18
|
+
it { is_expected.to set_callback(:upsert, :arround) }
|
19
|
+
it { is_expected.to set_callback(:upsert, :after) }
|
20
|
+
it { is_expected.to set_callback(:save, :before) }
|
21
|
+
it { is_expected.to set_callback(:save, :arround) }
|
22
|
+
it { is_expected.to set_callback(:save, :after) }
|
23
|
+
it { is_expected.to set_callback(:destroy, :before) }
|
24
|
+
it { is_expected.to set_callback(:destroy, :arround) }
|
25
|
+
it { is_expected.to set_callback(:destroy, :after) }
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,251 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongoid7-rspec-callbacks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre.816289031
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- VAILLANT Jeremy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry-byebug
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 13.0.3
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '13.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 13.0.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: reek
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 6.0.4
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 6.0.4
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.10'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.10'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.13.0
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.13.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rubocop-performance
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.11'
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.11.1
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.11'
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 1.11.1
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: rubocop-rspec
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '2.3'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '2.3'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: simplecov
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 0.21.2
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 0.21.2
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: simplecov_json_formatter
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 0.1.3
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 0.1.3
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: activesupport
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 6.1.3.1
|
158
|
+
type: :runtime
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - "~>"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: 6.1.3.1
|
165
|
+
- !ruby/object:Gem::Dependency
|
166
|
+
name: mongoid
|
167
|
+
requirement: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - "~>"
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '7.2'
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: 7.2.2
|
175
|
+
type: :runtime
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '7.2'
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: 7.2.2
|
185
|
+
- !ruby/object:Gem::Dependency
|
186
|
+
name: mongoid-rspec
|
187
|
+
requirement: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - "~>"
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '4.1'
|
192
|
+
type: :runtime
|
193
|
+
prerelease: false
|
194
|
+
version_requirements: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - "~>"
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '4.1'
|
199
|
+
description: |2
|
200
|
+
This gem is meant to be use with mongoid-rpsec,
|
201
|
+
altought it works by itself. Syntax is the same
|
202
|
+
as shoulda-callback-matchers.
|
203
|
+
email:
|
204
|
+
- jeremy@dazzl.tv
|
205
|
+
executables: []
|
206
|
+
extensions: []
|
207
|
+
extra_rdoc_files: []
|
208
|
+
files:
|
209
|
+
- COPYING
|
210
|
+
- Gemfile
|
211
|
+
- LICENSE
|
212
|
+
- README.md
|
213
|
+
- Rakefile
|
214
|
+
- lib/matchers/association_callbacks.rb
|
215
|
+
- lib/matchers/callbacks.rb
|
216
|
+
- lib/matchers/set_callbacks.rb
|
217
|
+
- lib/mongoid-rspec-callbacks/info.rb
|
218
|
+
- lib/mongoid_rspec_callbacks.rb
|
219
|
+
- spec/band_spec.rb
|
220
|
+
- spec/profile_spec.rb
|
221
|
+
- spec/spec_helper.rb
|
222
|
+
- spec/studio_spec.rb
|
223
|
+
- spec/support/models/band.rb
|
224
|
+
- spec/support/models/profile.rb
|
225
|
+
- spec/support/models/studio.rb
|
226
|
+
- spec/support/models/user.rb
|
227
|
+
- spec/user_spec.rb
|
228
|
+
homepage: http://github.com/dazzl-tv/mongoid-rspec-callbacks
|
229
|
+
licenses:
|
230
|
+
- GPL-3.0
|
231
|
+
metadata: {}
|
232
|
+
post_install_message:
|
233
|
+
rdoc_options: []
|
234
|
+
require_paths:
|
235
|
+
- lib
|
236
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
237
|
+
requirements:
|
238
|
+
- - ">="
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: 2.6.0
|
241
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
242
|
+
requirements:
|
243
|
+
- - ">"
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: 1.3.1
|
246
|
+
requirements: []
|
247
|
+
rubygems_version: 3.0.3.1
|
248
|
+
signing_key:
|
249
|
+
specification_version: 4
|
250
|
+
summary: RSpec Callbacks matchers for Mongoid
|
251
|
+
test_files: []
|