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
df80738e
Commit
df80738e
authored
Apr 09, 2021
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include context in spec time tracking
parent
73f2e6fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
6 deletions
+50
-6
spec/knapsack_env.rb
spec/knapsack_env.rb
+46
-0
spec/spec_helper.rb
spec/spec_helper.rb
+4
-6
No files found.
spec/knapsack_env.rb
0 → 100644
View file @
df80738e
# frozen_string_literal: true
require
'knapsack'
module
KnapsackEnv
class
RSpecContextAdapter
<
Knapsack
::
Adapters
::
RSpecAdapter
def
bind_time_tracker
::
RSpec
.
configure
do
|
config
|
# Original version starts timer in `config.prepend_before(:each) do`
# https://github.com/KnapsackPro/knapsack/blob/v1.17.0/lib/knapsack/adapters/rspec_adapter.rb#L9
config
.
prepend_before
(
:context
)
do
Knapsack
.
tracker
.
start_timer
end
# Original version is `config.prepend_before(:each) do`
# https://github.com/KnapsackPro/knapsack/blob/v1.17.0/lib/knapsack/adapters/rspec_adapter.rb#L9
config
.
prepend_before
(
:each
)
do
# rubocop:disable RSpec/HookArgument
current_example_group
=
if
::
RSpec
.
respond_to?
(
:current_example
)
::
RSpec
.
current_example
.
metadata
[
:example_group
]
else
example
.
metadata
end
Knapsack
.
tracker
.
test_path
=
Knapsack
::
Adapters
::
RSpecAdapter
.
test_path
(
current_example_group
)
end
# Original version stops timer in `config.append_after(:each) do`
# https://github.com/KnapsackPro/knapsack/blob/v1.17.0/lib/knapsack/adapters/rspec_adapter.rb#L20
config
.
append_after
(
:context
)
do
Knapsack
.
tracker
.
stop_timer
end
config
.
after
(
:suite
)
do
Knapsack
.
logger
.
info
(
Knapsack
::
Presenter
.
global_time
)
end
end
end
end
def
self
.
configure!
return
unless
ENV
[
'CI'
]
&&
ENV
[
'KNAPSACK_GENERATE_REPORT'
]
&&
!
ENV
[
'NO_KNAPSACK'
]
RSpecContextAdapter
.
bind
end
end
spec/spec_helper.rb
View file @
df80738e
...
...
@@ -15,6 +15,9 @@ Warning[:deprecated] = true unless ENV.key?('SILENCE_DEPRECATIONS')
require
'./spec/deprecation_toolkit_env'
DeprecationToolkitEnv
.
configure!
require
'./spec/knapsack_env'
KnapsackEnv
.
configure!
require
'./spec/simplecov_env'
SimpleCovEnv
.
start!
...
...
@@ -47,11 +50,6 @@ if rspec_profiling_is_configured && (!ENV.key?('CI') || branch_can_be_profiled)
require
'rspec_profiling/rspec'
end
if
ENV
[
'CI'
]
&&
ENV
[
'KNAPSACK_GENERATE_REPORT'
]
&&
!
ENV
[
'NO_KNAPSACK'
]
require
'knapsack'
Knapsack
::
Adapters
::
RSpecAdapter
.
bind
end
# require rainbow gem String monkeypatch, so we can test SystemChecks
require
'rainbow/ext/string'
Rainbow
.
enabled
=
false
...
...
@@ -81,7 +79,7 @@ RSpec.configure do |config|
config
.
run_all_when_everything_filtered
=
true
config
.
use_transactional_fixtures
=
true
config
.
use_instantiated_fixtures
=
false
config
.
use_instantiated_fixtures
=
false
config
.
fixture_path
=
Rails
.
root
config
.
verbose_retry
=
true
...
...
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