Explicit requires

16 views
Skip to first unread message

Marcus Ahnve

unread,
Nov 8, 2010, 9:41:03 AM11/8/10
to ruby-ev...@googlegroups.com
Hi,

I am trying to migrate a suite of tests from jstestdriver to Evergreen.
Initially trying with one test and running vanilla Jasmine everything
works fine.

When switching to Evergreen however, I cannot get the tests to work
unless I explicitly require dependencies in every Javascript file. So
first I have to require the file under test in the test. In that file
then, I have to require jQuery and everything else it depends on.

Is this expected behavior or am I doing something wrong? I have tried
to change 'public_dir' setting, but with no change.

Cheers /Marcus

--
Marcus Ahnve
http://marcus.ahnve.net
phone: +46 8 56 22 33 94
twitter: mahnve

Jonas Nicklas

unread,
Nov 8, 2010, 4:51:55 PM11/8/10
to ruby-ev...@googlegroups.com
I'd put whatever dependencies are shared in the spec_helper, Evergreen
will automatically load a file called spec_helper.js or
spec_helper.coffee in your spec_dir (which is spec/javascripts by
default). I haven't really felt a performance hit from requiring
everything in the spec helper, so I've been doing that for now, seems
like the easiest solution.

/Jonas

Marcus Ahnve

unread,
Nov 9, 2010, 3:06:04 AM11/9/10
to ruby-ev...@googlegroups.com
I must be missing something really obvious.

When I run my examples, the first error I get is that '$' is not
defined, so I obviously need to require jQuery. Trying different
permutations of
require('public/javascripts/jquery-1.4.2.min.js'); in spec_helper.js
with relative paths etcetera produces no different result.

/Marcus

On Mon, Nov 8, 2010 at 22:51, Jonas Nicklas <jonas....@gmail.com> wrote:
> I'd put whatever dependencies are shared in the spec_helper, Evergreen
> will automatically load a file called spec_helper.js or
> spec_helper.coffee in your spec_dir (which is spec/javascripts by
> default). I haven't really felt a performance hit from requiring
> everything in the spec helper, so I've been doing that for now, seems
> like the easiest solution
>

Jonas Nicklas

unread,
Nov 9, 2010, 3:17:28 AM11/9/10
to ruby-ev...@googlegroups.com
Ahh, you want those to be absolute paths. E.g:

require('/javascripts/jquery-1.4.2.min.js');

/Jonas

Marcus Ahnve

unread,
Nov 9, 2010, 4:01:34 AM11/9/10
to ruby-ev...@googlegroups.com
Absolute paths starting from the 'public' directory I take it?

/Marcus

Marcus Ahnve

unread,
Nov 9, 2010, 4:47:31 AM11/9/10
to ruby-ev...@googlegroups.com
Worked it out now, thanks. /Marcus
Reply all
Reply to author
Forward
0 new messages