Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/ReactiveX/RxSwift", from: "6.5.0"),
.package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", from: "2.2.2"), // for testTarget only
Copy link
Contributor

@rbrovko rbrovko Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need add CwlPreconditionTesting to RIBs.podspec too.

  s.test_spec 'Tests' do |test_spec|
    test_spec.source_files = 'RIBsTests/**/*.swift'
    test_spec.dependency 'CwlPreconditionTesting'
  end

],
targets: [
.target(
Expand All @@ -20,7 +21,7 @@ let package = Package(
),
.testTarget(
name: "RIBsTests",
dependencies: ["RIBs"],
dependencies: ["RIBs", "CwlPreconditionTesting"],
path: "RIBsTests"
),
]
Expand Down
11 changes: 9 additions & 2 deletions RIBsTests/ComponentizedBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@testable import RIBs
import XCTest
import CwlPreconditionTesting

class ComponentizedBuilderTests: XCTestCase {

Expand All @@ -29,10 +30,16 @@ class ComponentizedBuilderTests: XCTestCase {
}

let _: MockSimpleRouter = sameInstanceBuilder.build(withDynamicBuildDependency: (), dynamicComponentDependency: ())

expectAssertionFailure {

let options = XCTExpectedFailure.Options()
options.issueMatcher = { issue in
issue.type == .assertionFailure
}

let assertionFailureException = catchBadInstruction {
let _: MockSimpleRouter = sameInstanceBuilder.build(withDynamicBuildDependency: (), dynamicComponentDependency: ())
}
XCTAssertNotNil(assertionFailureException, "Builder should not return the same instance for the same component. Assertion failure is triggered.")
}

func test_componentForCurrentPass_builderReturnsNewInstance_verifyNoAssertion() {
Expand Down
7 changes: 5 additions & 2 deletions RIBsTests/MultiStageComponentizedBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@testable import RIBs
import XCTest
import CwlPreconditionTesting

class MultiStageComponentizedBuilderTests: XCTestCase {

Expand Down Expand Up @@ -64,13 +65,15 @@ class MultiStageComponentizedBuilderTests: XCTestCase {

_ = sameInstanceBuilder.finalStageBuild(withDynamicDependency: 92393)

expectAssertionFailure {
let finalStageBuildFatalErrorException = catchBadInstruction {
_ = sameInstanceBuilder.finalStageBuild(withDynamicDependency: 92393)
}
XCTAssertNotNil(finalStageBuildFatalErrorException, "fatalError expected")

expectAssertionFailure {
let componentForCurrentBuildPassAssertionFailureException = catchBadInstruction {
_ = sameInstanceBuilder.componentForCurrentBuildPass
}
XCTAssertNotNil(componentForCurrentBuildPassAssertionFailureException, "Assertion failure expected")
}
}

Expand Down
Loading