Files
react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb
T
Riccardo CipolleschiandFacebook GitHub Bot d96806bbc6 Move Flipper to dedicated flipper.rb
Summary:
This Diff moves all the Flipper.rb related setup in the cocoapods scripts to a dedicated script.

It also removes the not needed dummy files and add tests for flipper.

## Changelog

[iOS][Internal] - Extract Flipper setup in a separate file and add tests

Reviewed By: cortinico

Differential Revision: D36129808

fbshipit-source-id: 5446203a69b527146c893aa9611e98688e20b778
2022-05-09 02:55:30 -07:00

80 lines
1.9 KiB
Ruby
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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.
# This file replicate the structure of the Installer used Cocoapods in the post_install step.
#
# To use it, add `require_relative path/to/InstallerMock.rb` into your test file
#
# ## Initialization
# You can create a new mock with the `InstallerMock.new` statement. In this case, you will
# create an empty mock.
#
# It's possible to create complex with the initializer. To create an Installer with a pod, for example, we can
# use the following code:
#
# ```ruby
# installer = Installer.new(
# PodsProjectMock.new([
# TargetMock.new(
# "MyPod",
# [
# BuildConfigurationMock.new("Debug"),
# ]
# )
# )
# )
# ```
#
# ## Assert
# All the properties of these objects are accessible in read mode.
# To access the target's list, for example, you can use the following line:
#
# ```ruby
# targets = installer.pods_project.targets
# ```
class InstallerMock
attr_reader :pods_project
def initialize(pods_project = PodsProjectMock.new)
@pods_project = pods_project
end
def target_with_name(name)
return @pods_project.targets
.select { |target| target.name == name }
.first
end
end
class PodsProjectMock
attr_reader :targets
def initialize(targets = [])
@targets = targets
end
end
class TargetMock
attr_reader :name
attr_reader :build_configurations
def initialize(name, build_configurations = [])
@name = name
@build_configurations = build_configurations
end
end
class BuildConfigurationMock
attr_reader :name
attr_reader :build_settings
def initialize(name, build_settings = {})
@name = name
@build_settings = build_settings
end
end