Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
7ef32e9e
Commit
7ef32e9e
authored
Dec 06, 2014
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2845 from CocoaPods/issue/2845
[Unit Tests] Add specs for `Pod::UI`
parents
8bd9839a
4dd7b38b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
8 deletions
+82
-8
user_interface.rb
lib/cocoapods/user_interface.rb
+4
-8
user_interface_spec.rb
spec/unit/user_interface_spec.rb
+78
-0
No files found.
lib/cocoapods/user_interface.rb
View file @
7ef32e9e
...
@@ -193,20 +193,16 @@ module Pod
...
@@ -193,20 +193,16 @@ module Pod
#
#
def
labeled
(
label
,
value
,
justification
=
12
)
def
labeled
(
label
,
value
,
justification
=
12
)
if
value
if
value
title
=
"-
#{
label
}
:"
.
ljust
(
justification
)
title
=
"-
#{
label
}
:"
output
=
begin
if
value
.
is_a?
(
Array
)
if
value
.
is_a?
(
Array
)
lines
=
[
wrap_string
(
title
,
self
.
indentation_level
)]
lines
=
[
wrap_string
(
title
,
self
.
indentation_level
)]
value
.
each
do
|
v
|
value
.
each
do
|
v
|
lines
<<
wrap_string
(
"-
#{
v
}
"
,
self
.
indentation_level
+
2
)
lines
<<
wrap_string
(
"-
#{
v
}
"
,
self
.
indentation_level
+
2
)
end
end
lines
.
join
(
"
\n
"
)
puts
lines
.
join
(
"
\n
"
)
else
else
wrap_string
(
title
+
"
#{
value
}
"
,
self
.
indentation_level
)
puts
wrap_string
(
title
.
ljust
(
justification
)
+
"
#{
value
}
"
,
self
.
indentation_level
)
end
+
"
\n
"
end
end
puts
output
output
end
end
end
end
...
@@ -291,7 +287,7 @@ module Pod
...
@@ -291,7 +287,7 @@ module Pod
#
#
def
wrap_string
(
string
,
indent
=
0
)
def
wrap_string
(
string
,
indent
=
0
)
if
disable_wrap
if
disable_wrap
string
(
' '
*
indent
)
+
string
else
else
first_space
=
' '
*
indent
first_space
=
' '
*
indent
indented
=
CLAide
::
Command
::
Banner
::
TextWrapper
.
wrap_with_indent
(
string
,
indent
,
9999
)
indented
=
CLAide
::
Command
::
Banner
::
TextWrapper
.
wrap_with_indent
(
string
,
indent
,
9999
)
...
...
spec/unit/user_interface_spec.rb
0 → 100644
View file @
7ef32e9e
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
module
Pod
describe
UI
do
describe
'#section'
do
# TODO
end
describe
'#titled_section'
do
# TODO
end
describe
'#title'
do
# TODO
end
describe
'#message'
do
# TODO
end
describe
'#info'
do
# TODO
end
describe
'#notice'
do
# TODO
end
describe
'#labeled'
do
it
'prints nothing if value is nil'
do
UI
.
labeled
(
'label'
,
nil
)
UI
.
output
.
should
==
''
end
it
'prints label and value on one line if value is not an array'
do
UI
.
labeled
(
'label'
,
'value'
,
12
)
UI
.
output
.
should
==
"- label: value
\n
"
end
it
'justifies the label'
do
UI
.
labeled
(
'label'
,
'value'
,
30
)
UI
.
output
.
should
==
"- label:
#{
' '
*
22
}
value
\n
"
# 22 = 30 - ('- label:'.length)
end
it
'justifies the label with default justification'
do
UI
.
labeled
(
'label'
,
'value'
)
# defaults to 12
UI
.
output
.
should
==
"- label: value
\n
"
end
it
'uses the indentation level'
do
UI
.
indentation_level
=
10
UI
.
labeled
(
'label'
,
'value'
)
# defaults to 12
UI
.
output
.
should
==
"
#{
' '
*
10
}
- label: value
\n
"
end
it
'prints array values on separate lines, no indentation level'
do
UI
.
labeled
(
'label'
,
%w(value1)
,
12
)
UI
.
output
.
should
==
"- label:
\n
- value1
\n
"
end
it
'prints array values (1) on separate lines with indentation level'
do
UI
.
indentation_level
=
10
UI
.
labeled
(
'label'
,
%w(value1)
,
12
)
UI
.
output
.
should
==
"
#{
' '
*
10
}
- label:
\n
#{
' '
*
12
}
- value1
\n
"
end
it
'prints array values (3) on separate lines with indentation level'
do
UI
.
indentation_level
=
10
values
=
%w(value1 value2 value3)
UI
.
labeled
(
'label'
,
values
,
12
)
UI
.
output
.
should
==
"
#{
' '
*
10
}
- label:
\n
"
+
values
.
map
{
|
v
|
"
#{
' '
*
12
}
-
#{
v
}
\n
"
}.
join
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