{"action":"opened","issue":{"url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/154","repository_url":"https://api.github.com/repos/jasmine/jasmine-ajax","labels_url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/154/labels{/name}","comments_url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/154/comments","events_url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/154/events","html_url":"https://github.com/jasmine/jasmine-ajax/issues/154","id":148013823,"number":154,"title":"stubRequest does not seem to play nicely with Rails remote (jquery-ujs)","user":{"login":"vaharoni","id":483279,"avatar_url":"https://avatars.githubusercontent.com/u/483279?v=3","gravatar_id":"","url":"https://api.github.com/users/vaharoni","html_url":"https://github.com/vaharoni","followers_url":"https://api.github.com/users/vaharoni/followers","following_url":"https://api.github.com/users/vaharoni/following{/other_user}","gists_url":"https://api.github.com/users/vaharoni/gists{/gist_id}","starred_url":"https://api.github.com/users/vaharoni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vaharoni/subscriptions","organizations_url":"https://api.github.com/users/vaharoni/orgs","repos_url":"https://api.github.com/users/vaharoni/repos","events_url":"https://api.github.com/users/vaharoni/events{/privacy}","received_events_url":"https://api.github.com/users/vaharoni/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-13T10:16:43Z","updated_at":"2016-04-13T10:16:43Z","closed_at":null,"body":"I have a link in Rails:\r\n```ruby\r\n<%= link_to 'click here', '/some_path', class: 'special-link', remote: true %>\r\n```\r\n\r\nand some JS code intended to have an effect on the DOM:\r\n```coffeescript\r\n$(document).on 'ajax:success', '.special-link', (e, data, status, xhr) ->\r\n  # Code that has some effect on the DOM as a function of the server response\r\n```\r\n\r\nWhen I try to test the library in Jasmine by calling `$('.special-link').click()`, the AJAX request occurs but the desirable effect on the DOM cannot be observed. The issue, it seems, is that the `ajax:success` event does not get triggered:\r\n\r\n```coffeescript\r\ndescribe 'my library', ->\r\n  beforeEach ->\r\n    MagicLamp.load('fixture') # Fixture library that injects the link above to the DOM\r\n    jasmine.Ajax.install()\r\n    jasmine.Ajax.stubRequest('/some_path').andReturn({\r\n      responseText: 'response that is supposed to trigger some effect on the DOM'})\r\n\r\n  afterEach ->\r\n    jasmine.Ajax.uninstall()\r\n\r\n  # Works. The fixtures are loading properly\r\n  it '[sanity] loads fixtures correctly', ->\r\n    expect($('.special-link').length).toEqual(1)\r\n\r\n  # Works. The jquery-ujs correctly triggers an ajax request on click\r\n  it '[sanity] triggers the ajax call', ->\r\n    $('.special-link').click() \r\n    expect(jasmine.Ajax.requests.mostRecent().url).toContain('/some_path')\r\n\r\n  # Does not work. \r\n  it 'knows how to handle ajax:success events', ->\r\n    spy = jasmine.createSpy('my spy')\r\n    $('.special-link').on 'ajax:success', spy\r\n    $('.special-link').click()\r\n    expect(spy).toHaveBeenCalled()\r\n```\r\n\r\nAm I missing something? What's the recommended way to black-box test effects on DOM of jquery-ujs events?\r\n\r\nThanks.\r\nAmit"}}