Implement custom Rspec matcher for ROP main classes
MR: Implement custom rop rspec matcher (!153367 - merged)
Description
The following discussion from !147718 (merged) should be addressed:
-
@pslaughter started a discussion: (+2 comments) I'm assuming this pipeline is covered by an integration test, and we already have
Resultunit tested, and these individual functions are unit tested. As far ascreator_speccoverage goes, from a unit test perspective, I think we're mostly concerned about:To assert that the Railway was created and executed as expected, it'd be nice to have helpers like:
expect_railway_to_have_been_called( PersonalAccessTokenCreator.method(:create), WorkspaceCreator.method(:create), WorkspaceVariablesCreator.method(:create) ).with(init_value).and_return(Result.ok(updated_value))Then we can greatly reduce the amount of test code here and in other places. WDYT? I think simplifying the testability is one of the best wins we get with ROP.
See entire thread for a more detailed discussion.
See https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/remote_development/README.md#railway-oriented-programming-and-the-result-class for more context on ROP.
Acceptance Criteria
-
Define expect_railway_to_have_been_calledor similarly named helper in existing ROP helpers inee/spec/support/helpers/remote_development/railway_oriented_programming_helpers.rb. -
Update all existing ROP unit tests to use the helper where possible
Technical Requirements
- Define the helper as described, in existing ROP helpers in
ee/spec/support/helpers/remote_development/railway_oriented_programming_helpers.rb.
Impact Assessment
Improves developer productivity and happiness by making ROP tests easier to write, understand, and maintain.