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
f25f715f
Commit
f25f715f
authored
Oct 18, 2015
by
Tim Bodeit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ProjectSpec] Add tests for #group_for_path_in_group
parent
7777824e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
project_spec.rb
spec/unit/project_spec.rb
+82
-0
No files found.
spec/unit/project_spec.rb
View file @
f25f715f
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
module
Pod
# Expose to unit test file
class
Project
public
:group_for_path_in_group
end
describe
Project
do
before
do
@project
=
Project
.
new
(
config
.
sandbox
.
project_path
)
...
...
@@ -216,6 +221,83 @@ module Pod
#----------------------------------------#
describe
'#group_for_path_in_group'
do
before
do
@project
.
add_pod_group
(
'BananaLib'
,
config
.
sandbox
.
pod_dir
(
'BananaLib'
),
false
)
@file
=
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
'file.m'
subdir
=
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
'Dir/SubDir/'
@nested_file
=
subdir
+
'nested_file.h'
@nested_file2
=
subdir
+
'nested_file.m'
@localized_base_foo
=
subdir
+
'Base.lproj/Foo.storyboard'
@localized_de_foo
=
subdir
+
'de.lproj/Foo.strings'
@localized_de_bar
=
subdir
+
'de.lproj/Bar.strings'
@group
=
@project
.
group_for_spec
(
'BananaLib'
)
end
it
'returns parent group when file is in main group directory'
do
group
=
@project
.
group_for_path_in_group
(
@file
,
@group
,
true
)
group
.
uuid
.
should
==
@group
.
uuid
end
it
'returns parent group when not localized or reflecting structure'
do
group
=
@project
.
group_for_path_in_group
(
@nested_file
,
@group
,
false
)
group
.
uuid
.
should
==
@group
.
uuid
end
it
'adds subgroups if reflecting file system structure'
do
group
=
@project
.
group_for_path_in_group
(
@nested_file
,
@group
,
true
)
group
.
hierarchy_path
.
should
==
'/Pods/BananaLib/Dir/SubDir'
end
it
"doesn't duplicate groups for a single directory path"
do
group_1
=
@project
.
group_for_path_in_group
(
@nested_file
,
@group
,
true
)
group_2
=
@project
.
group_for_path_in_group
(
@nested_file2
,
@group
,
true
)
group_1
.
uuid
.
should
==
group_2
.
uuid
end
it
'creates variant group for localized file'
do
group
=
@project
.
group_for_path_in_group
(
@localized_base_foo
,
@group
,
false
)
group
.
hierarchy_path
.
should
==
'/Pods/BananaLib/Foo'
group
.
class
.
should
==
Xcodeproj
::
Project
::
Object
::
PBXVariantGroup
end
it
'creates variant group for localized file when adding subgroups'
do
group
=
@project
.
group_for_path_in_group
(
@localized_base_foo
,
@group
,
true
)
group
.
hierarchy_path
.
should
==
'/Pods/BananaLib/Dir/SubDir/Foo'
group
.
class
.
should
==
Xcodeproj
::
Project
::
Object
::
PBXVariantGroup
end
it
'sets variant group path to the folder that contains .lproj bundles'
do
group
=
@project
.
group_for_path_in_group
(
@localized_base_foo
,
@group
,
false
)
group
.
real_path
.
should
==
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
'Dir/SubDir'
end
it
"doesn't duplicate variant groups for same name"
do
group_1
=
@project
.
group_for_path_in_group
(
@localized_base_foo
,
@group
,
false
)
group_2
=
@project
.
group_for_path_in_group
(
@localized_de_foo
,
@group
,
false
)
group_1
.
uuid
.
should
==
group_2
.
uuid
@group
.
children
.
count
.
should
==
1
end
it
'makes separate variant groups for different names'
do
group_1
=
@project
.
group_for_path_in_group
(
@localized_base_foo
,
@group
,
false
)
group_2
=
@project
.
group_for_path_in_group
(
@localized_de_bar
,
@group
,
false
)
group_1
.
uuid
.
should
!=
group_2
.
uuid
@group
.
children
.
count
.
should
==
2
end
it
'raises if the given path is not absolute'
do
should
.
raise
ArgumentError
do
@project
.
add_file_reference
(
'relative/path/to/file.m'
,
@group
,
true
)
end
.
message
.
should
.
match
/Paths must be absolute/
should
.
raise
ArgumentError
do
@project
.
add_file_reference
(
'relative/path/to/file.m'
,
@group
,
false
)
end
.
message
.
should
.
match
/Paths must be absolute/
end
end
#----------------------------------------#
describe
'#reference_for_path'
do
before
do
@project
.
add_pod_group
(
'BananaLib'
,
config
.
sandbox
.
pod_dir
(
'BananaLib'
),
false
)
...
...
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