{"record":{"id":"d2650394c30d95ee","repo":"thoughtbot/shoulda-matchers","slug":"delegation-needs-a-target-use-the-to-method-to-d","errorCode":null,"errorMessage":"Delegation needs a target. Use the #to method to define one, e.g. `post_office.should delegate(:deliver_mail).to(:mailman)`","messagePattern":"Delegation needs a target\\. Use the #to method to define one, e\\.g\\. `post_office\\.should delegate\\(:deliver_mail\\)\\.to\\(:mailman\\)`","errorType":"exception","errorClass":"DelegateObjectNotSpecified","httpStatus":null,"severity":"error","filePath":"lib/shoulda/matchers/independent/delegate_method_matcher.rb","lineNumber":422,"sourceCode":"            call.args == delegated_arguments\n          end\n        end\n\n        def subject_has_delegating_method?\n          if expects_private_delegation?\n            !subject.respond_to?(delegating_method) && subject.respond_to?(delegating_method, true)\n          else\n            subject.respond_to?(delegating_method)\n          end\n        end\n\n        def subject_has_delegate_object_reader_method?\n          subject.respond_to?(delegate_object_reader_method, true)\n        end\n\n        def ensure_delegate_object_has_been_specified!\n          if delegate_object_reader_method.to_s.empty?\n            raise DelegateObjectNotSpecified\n          end\n        end\n\n        def subject_delegates_to_delegate_object_correctly?\n          if expects_private_delegation?\n            privately_call_delegating_method_with_delegate_method_returning(delegate_object)\n          else\n            call_delegating_method_with_delegate_method_returning(delegate_object)\n          end\n\n          if delegated_arguments.any?\n            delegate_object_received_call_with_delegated_arguments?\n          else\n            delegate_object_received_call?\n          end\n        end\n\n        def subject_handles_nil_delegate_object?","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/thoughtbot/shoulda-matchers/blob/79cdfbc326e97c9b43991b644434ca53c1f62c4c/lib/shoulda/matchers/independent/delegate_method_matcher.rb#L404-L440","documentation":"Error \"Delegation needs a target. Use the #to method to define one, e.g. `post_office.should delegate(:deliver_mail).to(:mailman)`\" thrown in thoughtbot/shoulda-matchers.","triggerScenarios":"Thrown at lib/shoulda/matchers/independent/delegate_method_matcher.rb:422 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79cdfbc326e97c9b43991b644434ca53c1f62c4c","analyzedAt":"2026-08-23T09:43:24.200Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}