The right way to require jasmine-jquery

144 views
Skip to first unread message

stanislaw

unread,
Nov 13, 2011, 3:40:10 PM11/13/11
to Evergreen
Hi, Jonas!

How should I require jasmine-jquery(https://github.com/velesin/jasmine-
jquery) into evergreen's spec/javascripts/spec_helper.js. Moving
jasmine-jquery-1.x.x.js into app/assets seems to be untidy.

Jasmine, if used as is, has its runner - all files from spec/
javascripts/helpers are required automatically and jasmine-jquery js
file basically goes there.

Here: http://groups.google.com/group/ruby-evergreen/browse_thread/thread/95964d4324b10d62
- you say that "there is no good way of requiring files from spec/
folder..."

What is evergreen way?

Thanks!

Magnus Bergmark

unread,
Feb 1, 2012, 5:55:24 AM2/1/12
to ruby-ev...@googlegroups.com
The following worked for me in Rails 3.2 using the asset pipeline.

In your config/evergreen.rb, add your spec directory to the asset path:

Evergreen.application.config.assets.paths.tap do |paths|
  paths << Evergreen.application.root.join('spec', 'javascripts')
end

Then, in your spec_helper.coffee:

# Spec libs
require '/assets/support/lib/jasmine-jquery-1.2.0.js'
require '/assets/support/lib/mock-ajax.js'

Hope it helps

Vaughan

unread,
Mar 4, 2012, 10:22:19 PM3/4/12
to ruby-ev...@googlegroups.com
I could not get this to work in Rails 3.1.3.

Evergreen.application.config.assets.paths is not getting updated.

Is your suggestion specific to Rails 3.2?

Magnus Bergmark

unread,
Mar 5, 2012, 3:57:02 AM3/5/12
to ruby-ev...@googlegroups.com
On Mon, Mar 5, 2012 at 4:22 AM, Vaughan <vrou...@gmail.com> wrote:
I could not get this to work in Rails 3.1.3.

Evergreen.application.config.assets.paths is not getting updated.

Is your suggestion specific to Rails 3.2?


Actually not, we eventually abandoned that way of doing it. Turns out evergreen.rb is evaluated every time a spec is run.

Here's what we ended up doing.

config/environments/test.rb and config/environments/development.rb:



config.assets.paths << Rails.root.join('spec', 'javascripts').to_s


config/evergreen.rb:
Evergreen.configure do |config|
  if ENV['guard'].present?
    require 'capybara-webkit'
    config.driver = :webkit
  end
end

In case anyone wonders, ENV['GUARD'] is set from our Guardfile. It's not out-of-the-box.

We need to add the asset path to the development environment as well since Evergreen runs on that environment (which caused us some trouble we needed to work around).

Magnus
Reply all
Reply to author
Forward
0 new messages