Files
react-native/scripts/cocoapods/__tests__/test_utils/PodMock.rb
T
Riccardo Cipolleschi 7a2704455f Move cocoapods utilities to utils.rb - Part 1 (#33978)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33978

This Diff moves part of the utilities from the `react_native_pods` file to a specific `utils.rb` file.

It adds tests for these utils and improve our test mocks.

The goal is to simplify the `react_native_pods.rb` so it's easier to work with it.

I decided to split this diff in 2 because it was becoming quite big.

## Changelog

[iOS][Changed] - Refactoring part of the react_native_pods.rb script

Reviewed By: cortinico

Differential Revision: D37004347

fbshipit-source-id: a5156f7c199d082d5d895a58af80948556c51c2a
2022-06-10 07:25:52 -07:00

87 lines
1.9 KiB
Ruby

# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
module Pod
class Config
@@instance = Config.new()
attr_reader :installation_root
def initialize()
@installation_root = InstallationRootMock.new()
end
def self.instance()
return @@instance
end
def self.reset()
@@instance = Config.new()
end
end
class InstallationRootMock
attr_accessor :relative_path_from
attr_reader :relative_path_from_invocation_count
def initialize()
@relative_path_from = ""
@relative_path_from_invocation_count = 0
end
def relative_path_from(path)
@relative_path_from_invocation_count += 1
return @relative_path_from
end
end
class UI
@@collected_messages = []
@@collected_warns = []
def self.puts(message)
@@collected_messages.push(message)
end
def self.warn(warn)
@@collected_warns.push(warn)
end
def self.collected_messages()
return @@collected_messages
end
def self.collected_warns()
return @@collected_warns
end
def self.reset()
@@collected_messages = []
@@collected_warns = []
end
end
class Executable
@@executed_commands = []
def self.execute_command(command, arguments)
@@executed_commands.push({
"command" => command,
"arguments" => arguments
})
end
def self.executed_commands
return @@executed_commands
end
def self.reset()
@@executed_commands = []
end
end
end