Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
35735620
Commit
35735620
authored
Oct 04, 2019
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create allow_next_instance_of spec helper
parent
c0133a59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
doc/development/gotchas.md
doc/development/gotchas.md
+1
-1
spec/spec_helper.rb
spec/spec_helper.rb
+1
-0
spec/support/helpers/allow_next_instance_of.rb
spec/support/helpers/allow_next_instance_of.rb
+15
-0
No files found.
doc/development/gotchas.md
View file @
35735620
...
...
@@ -106,7 +106,7 @@ end
Using `any_instance` to stub a method (elasticsearch_indexing) that has been defined on a prepended module (EE::ApplicationSetting) is not supported.
```
### Alternative: `expect_next_instance_of`
### Alternative: `expect_next_instance_of`
or `allow_next_instance_of`
Instead of writing:
...
...
spec/spec_helper.rb
View file @
35735620
...
...
@@ -90,6 +90,7 @@ RSpec.configure do |config|
config
.
include
StubFeatureFlags
config
.
include
StubGitlabCalls
config
.
include
StubGitlabData
config
.
include
AllowNextInstanceOf
config
.
include
ExpectNextInstanceOf
config
.
include
TestEnv
config
.
include
Devise
::
Test
::
ControllerHelpers
,
type: :controller
...
...
spec/support/helpers/allow_next_instance_of.rb
0 → 100644
View file @
35735620
# frozen_string_literal: true
module
AllowNextInstanceOf
def
allow_next_instance_of
(
klass
,
*
new_args
)
receive_new
=
receive
(
:new
)
receive_new
.
with
(
*
new_args
)
if
new_args
.
any?
allow
(
klass
).
to
receive_new
.
and_wrap_original
do
|
method
,
*
original_args
|
method
.
call
(
*
original_args
).
tap
do
|
instance
|
yield
(
instance
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment