Skip to content

Latest commit

 

History

History

__tests__

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Firebase SPM / firebase.json Ruby tests

Unit tests for CocoaPods/SPM Ruby helpers under packages/app/**/*.rb (primarily firebase_spm.rb, plus firebase_json.rb).

How to run (canonical)

From the repo root:

yarn ruby:install         # root Gemfile (or root `yarn` covers it via postinstallDev)
yarn tests:ios:ruby       # RuboCop (yarn lint:ruby) then SimpleCov suites

yarn lint:ruby is also available alone (same Gemfile / BUNDLE_FROZEN install). It is not part of root yarn lint — CI Lint has no Bundler step; Ruby lint runs with unit tests on tests_e2e_ios.yml.

Gems install under vendor/bundle via the committed root .bundle/config (BUNDLE_PATH); that directory is gitignored. Commit Gemfile.lock (including CHECKSUMS); CI installs with BUNDLE_FROZEN=true bundle install (Bundler 2.6 deprecates the --frozen CLI flag and would persist it into .bundle/config). Dependabot watches package-ecosystem: bundler at / (with cooldown) — do not put Bundler-native cooldown: in the Gemfile (needs Bundler 4.0.13+; host/CI stay on 2.6.x).

That discovers every packages/app/__tests__/*_test.rb (including suites added later), runs each suite in an isolated process (so mock-based unit tests and real cocoapods/xcodeproj shape checks never conflict), collects SimpleCov coverage (with peek-merge across production load resets), and writes:

Artifact Path
LCOV coverage/ios-ruby/lcov.info
HTML (optional local browse) coverage/ios-ruby/index.html

Coverage tracks production Ruby under packages/app/**/*.rb and excludes __tests__. Codecov flag: ios-ruby (coverage design).

Agents must use yarn tests:ios:ruby — not ad-hoc ruby packages/app/__tests__/…_test.rb (agent command policy).

Shape-check suite (firebase_spm_shape_test.rb)

A companion, opt-in Minitest suite — not a replacement for firebase_spm_test.rb. firebase_spm_test.rb mocks the Xcodeproj/CocoaPods classes firebase_spm.rb depends on (MockAggregateTarget, MockInstaller, MockRootObject, MockBuildConfig, MockTarget, MockUserProject, MockBuildType, etc.) so the helper's post-install logic can be unit-tested without those gems installed. A mock is only ever as accurate as the person who wrote it, and this exact PR shipped a bug of that class (MockAggregateTarget#build_as_static? modeled as a directly-settable flag, when the real Pod::Target#build_as_static? is unconditionally true — the actual per-install signal is target_definition.build_type.static?), which only surfaced via a real pod install.

firebase_spm_shape_test.rb asserts, against the real xcodeproj/cocoapods gems, that every mocked class/method in firebase_spm_test.rb still has the shape those mocks assume — so a future CocoaPods/Xcodeproj release that changes that shape fails in seconds instead of ~20 minutes into a real pod install in the E2E jobs.

It skips cleanly (no failure, no tests defined) when xcodeproj/cocoapods aren't installed, so local runs without those gems still exit 0 via yarn tests:ios:ruby:

  • CI home is tests_e2e_ios.yml (iOS job, debug matrix cell): after BUNDLE_FROZEN=true bundle install on the root Gemfile (pinned cocoapods/xcodeproj + SimpleCov), runs yarn tests:ios:ruby so unit + shape + embed execute with the real toolchain, then uploads Codecov flag ios-ruby.
  • Jest (tests_jest.yml) and macOS/other (tests_e2e_other.yml) do not run Ruby helpers — use yarn tests:ios:ruby locally / as the OKF gate.

Embed-script suite (firebase_spm_embed_script_test.rb)

Exercises the bash body of rnfirebase_spm_embed_script (embed_frameworks_from) against real Mach-O frameworks built with clang/ar. This is what catches Archive-embed regressions like #9154 (static CocoaPods frameworks incorrectly copied into the app bundle). No cocoapods/xcodeproj gems needed.

Skips cleanly off macOS or when clang/ar/file are missing. Discovered and run by yarn tests:ios:ruby with the other *_test.rb suites (same tests_e2e_ios.yml debug cell — no separate raw ruby …_test.rb CI step).

What is Pod::Specification and why is it mocked?

Pod::Specification is the core CocoaPods class — it's the s object used inside every .podspec file to declare things like s.dependency, s.name, s.version, etc. We mock it with a simple class that records dependency calls, so we can run the tests without installing CocoaPods.

Test flow

  1. A mock Pod::Specification captures dependency calls.
  2. firebase_dependency() is called with known inputs (version, SPM products; legacy CocoaPods pod names are ignored / fail-loud).
  3. Assertions verify which path executed and with what arguments.

Tests

Representative rows for the Firebase resolution / DisableSPM fail-loud surface (the suite has many more embed/hook/probe tests — see firebase_spm_test.rb):

Test What it verifies Path Flow
test_missing_spm_single_product_fails_loud Without spm_dependency, a single Firebase product fails loud (no CocoaPods Firebase fallback). Fail-loud spm_dependency undefined → raises; spec.dependency never called
test_missing_spm_multiple_products_fails_loud Without spm_dependency, multi-product modules also fail loud (legacy CocoaPods pod lists are not declared). Fail-loud spm_dependency undefined → raises; no spec.dependency calls
test_spm_single_product When SPM is available, the Firebase dependency is declared via Swift Package Manager, using the correct URL, version, and product name. SPM spm_dependency defined → called with ['FirebaseAuth'], spec.dependency not called
test_spm_multiple_products_ignores_cocoapods_extras When SPM is available, only the SPM product names are used. Extra legacy CocoaPods-only names (like FirebaseCoreExtension) are ignored because SPM resolves them as transitive dependencies. SPM spm_dependency defined → called with ['FirebaseCrashlytics'] only
test_disable_spm_true_fails_loud_without_cocoapods_pods $RNFirebaseDisableSPM = true fails loud — CocoaPods Firebase is removed. Fail-loud $RNFirebaseDisableSPM = true → raises; no pods declared; active flag stays falsy
test_disabled_spm_fails_loud_even_if_spm_dependency_defined DisableSPM fails even when spm_dependency exists (must not silently take an SPM or CocoaPods path). Fail-loud $RNFirebaseDisableSPM = true + spm_dependency defined → raises; flag stays falsy
test_disable_spm_false_still_uses_spm Explicit $RNFirebaseDisableSPM = false (config generators / Expo templates) must still use SPM. SPM $RNFirebaseDisableSPM = false → SPM path
test_reads_spm_url_from_package_json The Firebase SPM repository URL is read from package.json instead of being hardcoded, ensuring a single source of truth for the SDK location. Config $firebase_spm_url reads from package.json → https://github.com/firebase/firebase-ios-sdk.git
test_spm_path_sets_active_flag Taking the SPM path in firebase_dependency sets $rnfirebase_spm_active, which rnfirebase_add_spm_embed_phase uses to decide whether to run — no reflection into RN-internal state. Embed flag SPM path taken → $rnfirebase_spm_active becomes truthy
test_missing_spm_dependency_fails_loud_without_cocoapods_pods Missing spm_dependency fails loud and must not set the SPM-active flag. Fail-loud spm_dependency undefined → raises; flag stays falsy
test_embed_phase_noop_when_spm_not_active rnfirebase_add_spm_embed_phase returns immediately (never touches installer) when Firebase isn't using SPM — safe to always call from a Podfile. Embed phase $rnfirebase_spm_active falsy → no-op, installer never walked
test_embed_phase_noop_without_cp_embed_pods_frameworks_phase No RNFB phase is added to a target that has no [CP] Embed Pods Frameworks phase, and the project is not saved. Embed phase No matching CocoaPods phase → no changes, no save
test_embed_phase_adds_phase_when_active_and_cp_phase_present The [RNFB] Embed Firebase SPM Frameworks phase is added with the correct script/paths, and the project is saved exactly once. Embed phase Matching CocoaPods phase found → RNFB phase added + project saved
test_embed_phase_is_idempotent_across_repeated_pod_installs Running the embed-phase logic twice (i.e. two pod installs) reuses the existing phase instead of duplicating it. Embed phase Phase added once and updated in place on subsequent runs
test_hook_wraps_original_method_and_calls_embed_phase rnfirebase_hook_cocoapods_post_install! wraps CocoaPods' own run_podfile_post_install_hooks, still runs the original behavior, and calls rnfirebase_add_spm_embed_phase with the installer afterward — no RN-internal hook involved. CocoaPods hook Fake Pod::Installer-shaped class → original called once, embed phase called once with the instance
test_hook_preserves_original_method_privacy The patched method stays private if it was private beforehand (matches real Pod::Installer#run_podfile_post_install_hooks), keeping the patch's footprint minimal. CocoaPods hook Original private → patched version still private
test_hook_is_idempotent_across_repeated_podspec_requires Multiple RNFB podspecs requiring firebase_spm.rb in the same pod install process must not double-wrap the method. CocoaPods hook Hook installed twice → original/embed phase still each called exactly once
test_hook_swallows_embed_phase_errors_without_breaking_original_hook A bug in our own embed-phase logic must not break CocoaPods' own post-install behavior or its return value. CocoaPods hook rnfirebase_add_spm_embed_phase raises → original hook still completes and its result is still returned
test_hook_noop_when_hook_method_does_not_exist Guards against a future CocoaPods release renaming/removing run_podfile_post_install_hooks — must not raise. CocoaPods hook Target method missing → no-op, no alias created
test_hook_noop_when_installer_class_is_nil Mirrors production when Pod::Installer isn't defined (e.g. outside a real CocoaPods environment) — must not raise. CocoaPods hook installer_class is nil → no-op