Issue with Jasmine Ruby gem and requiring custom jasmine_config.rb in Rails

56 views
Skip to first unread message

Grant Hutchins

unread,
Mar 3, 2011, 5:58:59 PM3/3/11
to jasmi...@googlegroups.com

Hi guys,


First off, I noticed that at https://github.com/pivotal/jasmine-gem it says "Please file issues here at Github" at the bottom of the README, but that the project doesn't have an Issues section. Oops!


Also, we ran into an issue with the rake tasks supplied by the jasmine gem. I noticed the lines that load a custom jasmine_config.rb file if present:


    jasmine_config_overrides = 'spec/javascripts/support/jasmine_config.rb'


    require jasmine_config_overrides if File.exist?(jasmine_config_overrides)

https://github.com/pivotal/jasmine-gem/blob/master/lib/jasmine/tasks/jasmine.rake#L33-34


The problem we're running into is when the file exists at "spec/javascripts/support/jasmine_config.rb" relative to the current directory, but the current directory is not in the load path. (such as while in the root of a Rails project)


So File.exist? for the relative path returns true, but the require fails.


It seems that we could just change it to

    jasmine_config_overrides = File.join(Dir.pwd, 'spec/javascripts/support/jasmine_config.rb')

    require jasmine_config_overrides if File.exist?(jasmine_config_overrides)


and it would work.


Am I on the right track, or is there something I'm not understanding?


Thanks!

Davis Frank

unread,
Mar 4, 2011, 12:19:36 AM3/4/11
to jasmi...@googlegroups.com, Grant Hutchins
Grant-

Thanks for the catch. Not sure where the Issues link went. I've re-enabled it. 

As for the require, it sounds like you're on the right track. Have you had Rajan take a look?


--dwf

--
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.

Grant Hutchins

unread,
Mar 4, 2011, 8:29:22 AM3/4/11
to Davis Frank, jasmi...@googlegroups.com, Grant Hutchins
Rajan and I talked about it right before the NYC open house party last night. It turns out that Ruby 1.9.2 no longer adds the current directory to the load path by default. So Rajan was going to look into it further and figure the best fix (probably the Dir.pwd thing).

Thanks!

Grant

Rajan Agaskar

unread,
Mar 4, 2011, 9:18:13 AM3/4/11
to jasmi...@googlegroups.com, Grant Hutchins, Davis Frank, Grant Hutchins
Yep -- Grant and I talked about it last night, and essentially 1.9.2 doesn't support relative paths (without a .). Dir.pwd is a safer choice anyways, so I'll roll it into the other fixes. 

Davis Frank

unread,
Mar 4, 2011, 10:17:05 AM3/4/11
to Rajan Agaskar, jasmi...@googlegroups.com, Grant Hutchins, Grant Hutchins
Wow. Great to know for a couple of other gems I'm working on.

Thanks for that find, too.

--dwf
Reply all
Reply to author
Forward
0 new messages