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
Boxiang Sun
gitlab-ce
Commits
04108611
Commit
04108611
authored
Aug 25, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for attributable aspect of ci config entry
parent
4509594e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
lib/gitlab/ci/config/entry/attributable.rb
lib/gitlab/ci/config/entry/attributable.rb
+3
-1
spec/lib/gitlab/ci/config/entry/attributable_spec.rb
spec/lib/gitlab/ci/config/entry/attributable_spec.rb
+22
-5
No files found.
lib/gitlab/ci/config/entry/attributable.rb
View file @
04108611
...
...
@@ -8,7 +8,9 @@ module Gitlab
class_methods
do
def
attributes
(
*
attributes
)
attributes
.
flatten
.
each
do
|
attribute
|
raise
ArgumentError
if
method_defined?
(
attribute
)
if
method_defined?
(
attribute
)
raise
ArgumentError
,
'Method already defined!'
end
define_method
(
attribute
)
do
return
unless
config
.
is_a?
(
Hash
)
...
...
spec/lib/gitlab/ci/config/entry/attributable_spec.rb
View file @
04108611
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Attributable
do
let
(
:node
)
{
Class
.
new
}
let
(
:node
)
do
Class
.
new
do
include
Gitlab
::
Ci
::
Config
::
Entry
::
Attributable
end
end
let
(
:instance
)
{
node
.
new
}
before
do
node
.
include
(
described_class
)
node
.
class_eval
do
attributes
:name
,
:test
end
end
context
'config is a hash'
do
context
'
when
config is a hash'
do
before
do
allow
(
instance
)
.
to
receive
(
:config
)
...
...
@@ -29,7 +32,7 @@ describe Gitlab::Ci::Config::Entry::Attributable do
end
end
context
'config is not a hash'
do
context
'
when
config is not a hash'
do
before
do
allow
(
instance
)
.
to
receive
(
:config
)
...
...
@@ -40,4 +43,18 @@ describe Gitlab::Ci::Config::Entry::Attributable do
expect
(
instance
.
test
).
to
be_nil
end
end
context
'when method is already defined in a superclass'
do
it
'raises an error'
do
expectation
=
expect
do
Class
.
new
(
String
)
do
include
Gitlab
::
Ci
::
Config
::
Entry
::
Attributable
attributes
:length
end
end
expectation
.
to
raise_error
(
ArgumentError
,
'Method already defined!'
)
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