Jasmine Rails, src_files not being loaded from subdirectory

Viewed 153

Gemfile:

source 'https://rubygems.org'

ruby '2.6.6'
gem 'rails', '5.0.2'

gem "pry"

gem 'aasm'

gem 'figaro', '~> 1.0.0'
gem 'sucker_punch' , "~> 1.0"

gem 'stripe'
gem 'square.rb'
gem 'gon'
gem 'twilio-ruby'
gem 'nokogiri'

gem 'lograge' 

gem 'sass-rails'
# # Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
# gem 'coffee-rails', '~> 4.0.0' # doesn't work with rails 5
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

gem 'platform-api' 

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

group: development do
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

gem 'pg', '~> 0.18'

group :production do
  gem 'rails_12factor', '0.0.2'
  gem 'newrelic_rpm'
  gem 'puma' 
  gem 'rack-timeout'
end

group :test do
    gem 'rspec-rails', '~> 3.5'
    gem 'factory_girl_rails'
    gem 'selenium-webdriver'
    gem 'capybara'
    gem 'faker' 
    gem 'launchy', '~> 2.4.2' 
    gem 'database_cleaner'
    gem 'jasmine', "2.6" 
    gem 'jasmine-jquery-rails'
end

This is how my JS folder is organized

> assets/javascripts
  > 0_global
    > utility.js
    > ...
  > 2_place_order
    > cart.js
    > item.js
    > ...
  > 0_global.js
  > 2_place_order.js

Where the top-level .js files in the assets/javascripts folder require the corresponding directory. I.e.,

0_global.js

    //= require_directory ./0_global

2_place_order.js

    //= require_directory ./2_place_order

I'm having trouble getting this set up to work with my jasmine. So in jasmine.yml, I required the top-level js file, figuring that since that file already requires the directory, it should load, but it does not. I.e., the below doesn't work:

src_files:
  - assets/0_global.js
  - assets/2_place_order.js

Is there a different way to get this to work? I have also tried:

src_files:
  - assets/0_global/*.js
  - assets/2_place_order/*.js

To require the directory from the set up jasmine.yml but this didn't work either. Would like to try to not have to enumerate every js file in the subdirectories.

Thanks!

1 Answers

I don't know anything about jasmine, but looking at the homepage it seems that the jasmine.yml would expect strings to be quoted:

# minimalist jasmine.yml configuration when leveraging asset pipeline
spec_files:
   - "**/*[Ss]pec.{js,coffee}"
Related