[rspec-users] what would be the best way to stub out an XHR request's response?

Adam Sroka adam.sroka at gmail.com
Wed Sep 26 18:34:05 UTC 2012


On Wed, Sep 26, 2012 at 11:26 AM, Patrick J. Collins
<patrick at collinatorstudios.com> wrote:
>> I would just wrap the method that makes the ajax call and spec it from
>> Jasmine. Then you can just stub the wrapper to return the data you
>> want and expect the right thing to happen in the callback method (or
>> however the data gets stored/displayed.)
>
> Sorry, I am not sure if I am understanding you correctly...  Are you
> saying, in the test environment, load jasmine via <script> tags, and use
> it to stub out the method that call that does the ajax call?
>

That could work. What I would actually do is call jamine-node from a
rake task, because I'm hoping I don't really need the full stack to
spec this behavior. Using rspec to test that a callback happens in a
page sounds like it would be slower than I'd like.


More information about the rspec-users mailing list