How do I load remote javascript when running Jasmine?

341 views
Skip to first unread message

Dan Steinicke

unread,
Dec 23, 2010, 12:32:50 PM12/23/10
to Jasmine
I'm trying to start using Jasmine-gem on a small existing Rails
project that uses the Google maps API. Normally the app loads the
Google maps JS API in the layouts/application.html.erb but this
doesn't seem to happen when I run rake jasmine (Firebug reports an
error google object not defined).

Is there a standard way to deal with this? Looking through the docs I
only see ways to load local javascript files, not remote ones.

I am using the following versions:

OS X 10.5.8
rails 2.3.8
ruby 1.8.7
jasmine 1.0.1.1

Thanks in advance for any advice folks can offer.

Corey Haines

unread,
Dec 23, 2010, 1:38:56 PM12/23/10
to jasmi...@googlegroups.com
Hi, Dan,

I would highly recommend wrapping your interactions with the google
maps API and test against that wrapper, rather than against the real
API. This will keep you isolated from their library, ensuring control
over your own code changes.

Basically, just write small routines that are related to your domain
that then call the google maps API from that. If you want to test the
wrapper, you can pass a spy in and verify that the appropriate calls
were made.

-Corey

> --
> You received this message because you are subscribed to the Google Groups "Jasmine" group.
> To post to this group, send email to jasmi...@googlegroups.com.
> To unsubscribe from this group, send email to jasmine-js+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jasmine-js?hl=en.
>
>

--
http://www.coreyhaines.com
The Internet's Premiere source of information about Corey Haines

Dan Steinicke

unread,
Dec 23, 2010, 3:25:04 PM12/23/10
to jasmi...@googlegroups.com
Thanks, that makes sense.  I wasn't thinking things through, just reacting to the error.  Thanks for putting me back on track.

Dan
Reply all
Reply to author
Forward
0 new messages