{"action":"created","issue":{"url":"https://api.github.com/repos/rspec/rspec-expectations/issues/830","labels_url":"https://api.github.com/repos/rspec/rspec-expectations/issues/830/labels{/name}","comments_url":"https://api.github.com/repos/rspec/rspec-expectations/issues/830/comments","events_url":"https://api.github.com/repos/rspec/rspec-expectations/issues/830/events","html_url":"https://github.com/rspec/rspec-expectations/issues/830","id":97962088,"number":830,"title":"Aggregating expects that require a block?","user":{"login":"DMA57361","id":1375133,"avatar_url":"https://avatars.githubusercontent.com/u/1375133?v=3","gravatar_id":"","url":"https://api.github.com/users/DMA57361","html_url":"https://github.com/DMA57361","followers_url":"https://api.github.com/users/DMA57361/followers","following_url":"https://api.github.com/users/DMA57361/following{/other_user}","gists_url":"https://api.github.com/users/DMA57361/gists{/gist_id}","starred_url":"https://api.github.com/users/DMA57361/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DMA57361/subscriptions","organizations_url":"https://api.github.com/users/DMA57361/orgs","repos_url":"https://api.github.com/users/DMA57361/repos","events_url":"https://api.github.com/users/DMA57361/events{/privacy}","received_events_url":"https://api.github.com/users/DMA57361/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-29T15:26:35Z","updated_at":"2015-07-29T16:29:37Z","closed_at":null,"body":"Have today noticed that RSpec 3.3 is out and that it includes a new aggregate_failures feature, which looks just like what I need to speed up a chronically slow test we have in one of our apps.\r\n\r\nUnfortunately, on inspection, this test has plenty of the following within each of it's many many context's (the subject is a lambda that's running a processor of some kind):\r\n```\r\nit{ is_expected.not_to raise_error }\r\nit{ is_expected.to change{ ReceivedMail.count }.by(+1) }\r\nit{ is_expected.to change{ Ticket.count       }.by(+1) }\r\n# and so on\r\n```\r\nI can't see a way that I can use these checks (presumably in the `expect{ processor.run }.to ...` form) in a manner that runs the block once and aggregates all the failures using the new feature, is this possible in some way?\r\n\r\n---\r\n\r\nAlternatively, I could manually store all the count values before, run the processor, then manually compare the results afterwards. This doesn't feel like a nice solution, but is probably what I'll be doing if the answer to the above it \"no\".\r\n\r\nAlso, I've also discovered I can do this:\r\n```\r\nis_expected\r\n  .to  change{ ReceivedMail.count }.by(+1)\r\n  .and change{ Ticket.count       }.by(+1)\r\n  # and so on\r\n```\r\nwhich technically works, but produces failure messages that are a bit opaque:\r\n```\r\n     Failure/Error: .to  change{ ReceivedMail.count }.by(+1)\r\n       expected result to have changed by 1, but was changed by 0 and expected result to have changed by 1, but was changed by 0 and expected result to have changed by 1, but was changed by 0\r\n```"},"comment":{"url":"https://api.github.com/repos/rspec/rspec-expectations/issues/comments/126008288","html_url":"https://github.com/rspec/rspec-expectations/issues/830#issuecomment-126008288","issue_url":"https://api.github.com/repos/rspec/rspec-expectations/issues/830","id":126008288,"user":{"login":"myronmarston","id":49391,"avatar_url":"https://avatars.githubusercontent.com/u/49391?v=3","gravatar_id":"","url":"https://api.github.com/users/myronmarston","html_url":"https://github.com/myronmarston","followers_url":"https://api.github.com/users/myronmarston/followers","following_url":"https://api.github.com/users/myronmarston/following{/other_user}","gists_url":"https://api.github.com/users/myronmarston/gists{/gist_id}","starred_url":"https://api.github.com/users/myronmarston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myronmarston/subscriptions","organizations_url":"https://api.github.com/users/myronmarston/orgs","repos_url":"https://api.github.com/users/myronmarston/repos","events_url":"https://api.github.com/users/myronmarston/events{/privacy}","received_events_url":"https://api.github.com/users/myronmarston/received_events","type":"User","site_admin":false},"created_at":"2015-07-29T16:29:37Z","updated_at":"2015-07-29T16:29:37Z","body":"Doing compound expectations with `and` should give you better failure messages in the future when we implement #747.  If you want to submit a PR for that that'd be great :).\r\n\r\nOtherwise, another solution is to nest them:\r\n\r\n``` ruby\r\nexpect {\r\n  expect {\r\n    do_it\r\n  }.to change { ReceivedMail.count }.by(+1)\r\n}.to change { Ticket.count }.by(+1)\r\n```\r\n\r\nI haven't tried that with the new `aggregate_failures but I think that should work."}}