Skip to content

Commit

Permalink
Ensure test_type value is converted to a symbol from consumers of J…
Browse files Browse the repository at this point in the history
…SON podspecs.
  • Loading branch information
dnkoutso committed Jan 9, 2019
1 parent 0fc80df commit a2f58b0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

##### Bug Fixes

* Ensure `test_type` value is converted to a symbol from consumers of JSON podspecs.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#504](https://github.com/CocoaPods/Core/pull/504)

* Fix several array sorting inconsistencies when generating a Lockfile.
When a Lockfile is being written to disk, `YAMLHelper` sorts arrays by `&:downcase`.
When a new Lockfile is generated, the sort order is plain lexicographical.
Expand Down
13 changes: 13 additions & 0 deletions lib/cocoapods-core/specification/consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,19 @@ def _prepare_prefix_header_contents(value)
end
end

# Converts the test type value from a string to a symbol.
#
# @param [String, Symbol] value.
# The value of the test type attributed as specified by the user.
#
# @return [Symbol] the test type as a symbol.
#
def _prepare_test_type(value)
if value
value.to_sym
end
end

# Converts the array of hashes (script phases) where keys are strings into symbols.
#
# @param [Array<Hash{String=>String}>] value.
Expand Down
9 changes: 9 additions & 0 deletions spec/specification/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ module Pod
test_consumer.test_type.should.be == :unit
end

it 'returns the test type as a symbol when consuming JSON specs' do
@spec.test_spec {}
test_spec = @spec.test_specs.first
test_spec.test_type = :unit
json_spec = @spec.to_json
test_consumer = Specification::Consumer.new(Specification.from_json(json_spec).test_specs.first, :ios)
test_consumer.test_type.should.be == :unit
end

it 'allows to specify whether the specification requires an app host' do
@spec.test_spec {}
test_spec = @spec.test_specs.first
Expand Down

0 comments on commit a2f58b0

Please sign in to comment.