Add Partial XMLHttpResponse 2 Support #60
Conversation
This is backwards incompatible with being able to do |
I took a stab at adding to this PR. My goal was to make it so The additional commit can be found here: tdg5@a93edf5 Seems like phantomjs tests are still struggling in Travis. |
… with the builtin method
Conflicts: spec/javascripts/mock-ajax-toplevel-spec.js
@tdg5 I rebased your commit onto my pull request. I've totally forgotten the code I wrote a month ago though. I've also given you write privilege to my fork if you wish to develop on there. |
Is there an official opinion of how this might be handled? What I've added feels half baked, but I haven't come up with a better solution. |
We'd really like to get XHR2 support in, but we've been trying to figure out if there is a way to do that without changing the interface for jasmine ajax. @jboyens and I have discussed this off-and-on in person, trying to figure out if there is a way to do something like this without changing the interface for jasmine ajax. One thought was to have XHR2 support be an option you'd turn on, and only at that point would the Another option might be to have Neither of these really seems awesome, but the other options effectively mean we have to break the interface again after we just released a 2.0. In addition, there's been some more refactoring of the code, and all of the individual pieces are now pulled out into their own files for easier testing, and then combined later, so this PR will need to be rebased before we can accept it. |
I would be happy to refactor and clean up the code in this pull request but it would be nice to have a high level decision about how to proceed. I agree with your options and I personally think the second option sounds better because turning on or off XHR2 support is not something you can do in a browser anyways. The second option can also be made safer by checking for tell-tale XHR2 calls, such as setting |
The problem with changing the behaviour of response is that in XHR2 it's a property not a method. So when code under test uses response it's always :
and never
Which sadly makes the trick of looking at the number of arguments a non-starter :-( Whilst the mode switch might be annoying it looks to be the only solution right now without breaking API compatibility. |
@awk agreed that's a problem. I come from a python background so in python I would be using the |
Sounds like we're just going to need to make an interface change. I think I'd prefer something like |
I'd prefer respondWith too - it's more in keeping with the language of Jasmine I think. |
I took a crack at rebasing this pull request and fixing conflicts but I'm honestly a little lost. It seems there's been a refactor that I've missed. For example, why are there duplicate |
|
shouldn't mock-ajax.js not be tracked in git then? |
|
Thanks for the release, @slackersoft ! |
I added in the
response
property that was introduced in XMLHttpResponse2. This should help to address #49.I'm not sure how to run tests though, other than waiting for Travis.