Always use strict test doubles (instance_double, class_double) instead of basic doubles or OpenStruct in tests. Strict doubles provide compile-time checks that prevent tests from passing when the mocked interface changes, improving test maintainability and catching integration issues early.
Always use strict test doubles (instance_double, class_double) instead of basic doubles or OpenStruct in tests. Strict doubles provide compile-time checks that prevent tests from passing when the mocked interface changes, improving test maintainability and catching integration issues early.
Example - Instead of:
auth_stub = double("vault auth", aws_iam: nil)
dummy = OpenStruct.new(stdout: output, exitstatus: 0)
Use:
auth_stub = instance_double("VaultAuth", aws_iam: nil)
shell_out = instance_double(Mixlib::ShellOut,
stdout: output,
exitstatus: 0,
error?: false
)
This approach:
Enter the URL of a public GitHub repository