{"action":"created","issue":{"url":"https://api.github.com/repos/opal/opal-rspec/issues/17","labels_url":"https://api.github.com/repos/opal/opal-rspec/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/opal/opal-rspec/issues/17/comments","events_url":"https://api.github.com/repos/opal/opal-rspec/issues/17/events","html_url":"https://github.com/opal/opal-rspec/issues/17","id":65547410,"number":17,"title":"Investigate using Promises for async specs","user":{"login":"adambeynon","id":68938,"avatar_url":"https://avatars.githubusercontent.com/u/68938?v=3","gravatar_id":"","url":"https://api.github.com/users/adambeynon","html_url":"https://github.com/adambeynon","followers_url":"https://api.github.com/users/adambeynon/followers","following_url":"https://api.github.com/users/adambeynon/following{/other_user}","gists_url":"https://api.github.com/users/adambeynon/gists{/gist_id}","starred_url":"https://api.github.com/users/adambeynon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adambeynon/subscriptions","organizations_url":"https://api.github.com/users/adambeynon/orgs","repos_url":"https://api.github.com/users/adambeynon/repos","events_url":"https://api.github.com/users/adambeynon/events{/privacy}","received_events_url":"https://api.github.com/users/adambeynon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-31T21:09:32Z","updated_at":"2015-06-01T00:18:14Z","closed_at":null,"body":"Instead of:\r\n\r\n```ruby\r\nasync 'HTTP requests should work' do\r\n  HTTP.get('/users/1.json') do |res|\r\n    run_async {\r\n      expect(res).to be_ok\r\n    }\r\n  end\r\nend\r\n```\r\n\r\nWe could use:\r\n\r\n```ruby\r\nasync 'HTTP requests should work' do\r\n  HTTP.get('/users/1.json').then do |res|\r\n      expect(res).to be_ok\r\n  end\r\nend\r\n```\r\n\r\nBasically, if the example block returns a Promise, then instead of the inner `run_async` block, the spec runner can just wait on the Promise to resolve or reject, and then handle it accordingly."},"comment":{"url":"https://api.github.com/repos/opal/opal-rspec/issues/comments/107261992","html_url":"https://github.com/opal/opal-rspec/issues/17#issuecomment-107261992","issue_url":"https://api.github.com/repos/opal/opal-rspec/issues/17","id":107261992,"user":{"login":"wied03","id":297123,"avatar_url":"https://avatars.githubusercontent.com/u/297123?v=3","gravatar_id":"","url":"https://api.github.com/users/wied03","html_url":"https://github.com/wied03","followers_url":"https://api.github.com/users/wied03/followers","following_url":"https://api.github.com/users/wied03/following{/other_user}","gists_url":"https://api.github.com/users/wied03/gists{/gist_id}","starred_url":"https://api.github.com/users/wied03/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wied03/subscriptions","organizations_url":"https://api.github.com/users/wied03/orgs","repos_url":"https://api.github.com/users/wied03/repos","events_url":"https://api.github.com/users/wied03/events{/privacy}","received_events_url":"https://api.github.com/users/wied03/received_events","type":"User","site_admin":false},"created_at":"2015-06-01T00:18:14Z","updated_at":"2015-06-01T00:18:14Z","body":"I'm not sure it's the best approach, but I'm working on a branch I could turn into a PR here: https://github.com/wied03/opal-rspec/tree/opal-0.8-other/rspec31_async_fix\r\n\r\nwhat works:\r\n* Basic runner that uses promises along with example_group monkey patches and and a new AsyncExample class\r\n* Test failures show up properly in results instead of uncaught exceptions (kind of a hack, but already had to do this with RSpec 3.1/lack of diff support for fail_with anyways)\r\n\r\nI still need to get:\r\n* example hierarchy working properly\r\n* pending/skipped within the example working\r\n* Support an async subject and/or example return value as you mention above so that the 'done' stuff is not necessary\r\n* Ensure other specs besides async_spec.rb work (and all of the other async specs I'm toggling on and off right now as I test)\r\n* See if there is a better way to test my work via CI besides manual inspection (test the test framework)"}}