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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
bc6d131b
Commit
bc6d131b
authored
Feb 13, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for SystemCheck and custom matcher
parent
a4460f42
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
0 deletions
+65
-0
lib/system_check.rb
lib/system_check.rb
+7
-0
spec/lib/system_check_spec.rb
spec/lib/system_check_spec.rb
+39
-0
spec/support/matchers/execute_check.rb
spec/support/matchers/execute_check.rb
+19
-0
No files found.
lib/system_check.rb
View file @
bc6d131b
...
...
@@ -15,9 +15,16 @@ module SystemCheck
raise
ArgumentError
,
'Invalid executor'
end
prepare
(
component
,
checks
,
executor_klass
).
execute
end
def
self
.
prepare
(
component
,
checks
=
[],
executor_klass
=
SimpleExecutor
)
executor
=
executor_klass
.
new
(
component
)
checks
.
each
do
|
check
|
executor
<<
check
end
executor
end
private_class_method
:prepare
end
spec/lib/system_check_spec.rb
0 → 100644
View file @
bc6d131b
require
'spec_helper'
describe
SystemCheck
,
lib:
true
do
subject
{
SystemCheck
}
describe
'.run'
do
it
'requires custom executor to be a BasicExecutor'
do
expect
{
subject
.
run
(
'Component'
,
[],
SystemCheck
::
SimpleExecutor
)
}.
not_to
raise_error
end
context
'custom matcher'
do
class
SimpleCheck
<
SystemCheck
::
BaseCheck
def
check?
true
end
end
class
OtherCheck
<
SystemCheck
::
BaseCheck
def
check?
false
end
end
subject
{
SystemCheck
}
it
'detects execution of SimpleCheck'
do
is_expected
.
to
execute_check
(
SimpleCheck
)
SystemCheck
.
run
(
'Test'
,
[
SimpleCheck
])
end
it
'detects exclusion of OtherCheck in execution'
do
is_expected
.
not_to
execute_check
(
OtherCheck
)
SystemCheck
.
run
(
'Test'
,
[
SimpleCheck
])
end
end
end
end
spec/support/matchers/execute_check.rb
0 → 100644
View file @
bc6d131b
RSpec
::
Matchers
.
define
:execute_check
do
|
expected
|
match
do
|
actual
|
expect
(
actual
).
to
eq
(
SystemCheck
)
expect
(
actual
).
to
receive
(
:run
)
do
|*
args
|
expect
(
args
[
1
]).
to
include
(
expected
)
end
end
match_when_negated
do
|
actual
|
expect
(
actual
).
to
eq
(
SystemCheck
)
expect
(
actual
).
to
receive
(
:run
)
do
|*
args
|
expect
(
args
[
1
]).
not_to
include
(
expected
)
end
end
failure_message
do
|
actual
|
return
'This matcher must be used with SystemCheck'
unless
actual
==
SystemCheck
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