{"action":"opened","issue":{"url":"https://api.github.com/repos/rspec/rspec-mocks/issues/904","labels_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/904/labels{/name}","comments_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/904/comments","events_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/904/events","html_url":"https://github.com/rspec/rspec-mocks/issues/904","id":59791614,"number":904,"title":"Verify that an object received a message chain?","user":{"login":"mathie","id":438,"avatar_url":"https://avatars.githubusercontent.com/u/438?v=3","gravatar_id":"","url":"https://api.github.com/users/mathie","html_url":"https://github.com/mathie","followers_url":"https://api.github.com/users/mathie/followers","following_url":"https://api.github.com/users/mathie/following{/other_user}","gists_url":"https://api.github.com/users/mathie/gists{/gist_id}","starred_url":"https://api.github.com/users/mathie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathie/subscriptions","organizations_url":"https://api.github.com/users/mathie/orgs","repos_url":"https://api.github.com/users/mathie/repos","events_url":"https://api.github.com/users/mathie/events{/privacy}","received_events_url":"https://api.github.com/users/mathie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-04T12:32:12Z","updated_at":"2015-03-04T12:32:12Z","closed_at":null,"body":"Leaving aside the tasteless violations of poor Demeter, this morning I wound up writing the following code:\r\n\r\n```ruby\r\nbefore(:each) do\r\n  allow(user).to receive_message_chain(:receipts, :build)\r\nend\r\n\r\nit 'builds a new receipt' do\r\n  get :new\r\n  expect(user).to have_received_message_chain(:receipts, :build)\r\nend\r\n```\r\n\r\nI expected that since `have_received` exists for verifying stubbed methods are called, then there would be the corresponding method for verifying stubbed message chains.\r\n\r\nOf course the workaround is just to set up the expectation before the method call:\r\n\r\n```ruby\r\nbefore(:each) do\r\n  allow(user).to receive_message_chain(:receipts, :build)\r\nend\r\n\r\nit 'builds a new receipt' do\r\n  expect(user).to receive_message_chain(:receipts, :build)\r\n  get :new\r\nend\r\n```\r\n\r\nbut I've fallen in love with spies, and having a consistent given/when/then pattern for all my specs. Would it be possible to implement `have_received_message_chain`?"}}