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
b088c4c0
Unverified
Commit
b088c4c0
authored
Sep 11, 2016
by
Danielle Tomlinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Validator] Add specs for .swift-version
parent
f3c1318c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
17 deletions
+53
-17
validator.rb
lib/cocoapods/validator.rb
+13
-13
validator_spec.rb
spec/unit/validator_spec.rb
+40
-4
No files found.
lib/cocoapods/validator.rb
View file @
b088c4c0
...
@@ -237,6 +237,19 @@ module Pod
...
@@ -237,6 +237,19 @@ module Pod
Pathname
(
Dir
.
tmpdir
)
+
'CocoaPods/Lint'
Pathname
(
Dir
.
tmpdir
)
+
'CocoaPods/Lint'
end
end
# @return [String] the SWIFT_VERSION to use for validation.
#
def
swift_version
@swift_version
||=
dot_swift_version
||
'2.3'
end
# @return [String] the SWIFT_VERSION in the .swift-version file or nil.
#
def
dot_swift_version
swift_version_path
=
file
.
dirname
+
'.swift-version'
File
.
read
(
swift_version_path
)
if
File
.
exist?
(
swift_version_path
)
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
private
private
...
@@ -656,19 +669,6 @@ module Pod
...
@@ -656,19 +669,6 @@ module Pod
# !@group Helpers
# !@group Helpers
# @return [String] the SWIFT_VERSION to use for validation.
#
def
swift_version
dot_swift_version
||
'2.3'
end
# @return [String] the SWIFT_VERSION in the .swift-version file or nil.
#
def
dot_swift_version
swift_version_path
=
file
.
dirname
+
'.swift-version'
File
.
read
(
swift_version_path
)
if
File
.
exists?
(
swift_version_path
)
end
# @return [Array<String>] an array of source URLs used to create the
# @return [Array<String>] an array of source URLs used to create the
# {Podfile} used in the linting process
# {Podfile} used in the linting process
#
#
...
...
spec/unit/validator_spec.rb
View file @
b088c4c0
...
@@ -784,13 +784,12 @@ module Pod
...
@@ -784,13 +784,12 @@ module Pod
validator
=
Validator
.
new
(
file
,
config
.
sources_manager
.
master
.
map
(
&
:url
))
validator
=
Validator
.
new
(
file
,
config
.
sources_manager
.
master
.
map
(
&
:url
))
validator
.
stubs
(
:build_pod
)
validator
.
stubs
(
:build_pod
)
validator
.
stubs
(
:validate_url
)
validator
.
stubs
(
:validate_url
)
validator
.
stubs
(
:swift_version
).
returns
(
'2.3'
)
validator
.
validate
validator
validator
end
end
it
'fails on deployment target < iOS 8 for Swift Pods'
do
it
'fails on deployment target < iOS 8 for Swift Pods'
do
validator
=
test_swiftpod
validator
=
test_swiftpod
validator
.
validate
validator
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/dynamic frameworks.*iOS > 8/
validator
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/dynamic frameworks.*iOS > 8/
validator
.
result_type
.
should
==
:error
validator
.
result_type
.
should
==
:error
...
@@ -800,6 +799,7 @@ module Pod
...
@@ -800,6 +799,7 @@ module Pod
Specification
::
Consumer
.
any_instance
.
stubs
(
:frameworks
).
returns
(
%w(XCTest)
)
Specification
::
Consumer
.
any_instance
.
stubs
(
:frameworks
).
returns
(
%w(XCTest)
)
validator
=
test_swiftpod
validator
=
test_swiftpod
validator
.
validate
validator
.
results
.
count
.
should
==
0
validator
.
results
.
count
.
should
==
0
end
end
...
@@ -807,12 +807,48 @@ module Pod
...
@@ -807,12 +807,48 @@ module Pod
Specification
.
any_instance
.
stubs
(
:deployment_target
).
returns
(
'9.0'
)
Specification
.
any_instance
.
stubs
(
:deployment_target
).
returns
(
'9.0'
)
validator
=
test_swiftpod
validator
=
test_swiftpod
validator
.
validate
validator
.
results
.
count
.
should
==
0
validator
.
results
.
count
.
should
==
0
end
end
it
'defaults to Swift 2.3'
do
describe
'#swift_version'
do
validator
=
test_swiftpod
it
'defaults to Swift 2.3'
do
validator
=
test_swiftpod
validator
.
stubs
(
:dot_swift_version
).
returns
(
nil
)
validator
.
swift_version
.
should
==
'2.3'
end
it
'checks for dot_swift_version'
do
validator
=
test_swiftpod
validator
.
expects
(
:dot_swift_version
)
validator
.
swift_version
end
it
'uses the result of dot_swift_version if not nil'
do
validator
=
test_swiftpod
validator
.
stubs
(
:dot_swift_version
).
returns
(
'1.0'
)
validator
.
swift_version
.
should
==
'1.0'
end
end
describe
'#dot_swift_version'
do
it
'looks for a .swift-version file'
do
validator
=
test_swiftpod
File
.
expects
(
:exist?
).
with
do
|
arg
|
arg
.
basename
.
to_s
==
'.swift-version'
end
validator
.
dot_swift_version
end
it
'uses the .swift-version file if present'
do
validator
=
test_swiftpod
File
.
stubs
(
:exist?
).
returns
(
true
)
File
.
expects
(
:read
).
with
do
|
arg
|
arg
.
basename
.
to_s
==
'.swift-version'
end
.
returns
(
'1.0'
)
validator
.
dot_swift_version
.
should
==
'1.0'
end
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