0

I have some working opal code running inside of a sample rails app, and I am trying to write some rspec tests around it.

Everything is setup and I can do some basic stuff, but in my code I use templates, and I can't seem to get the load paths set up to find/compile the templates.

So I have for example

mylibs ->
  some_lib ->
    some_lib.js.rb
    some_libs_template.opalerb

inside of some_lib.js.rb I have

require 'template'
#...
#...
  puts "Template.paths: #{Template.paths}"

which prints "Template.paths: "

i.e. no templates.

Same code works fine when called from within the rails app, so I assume I need to do something, for the template compiler to work in the test environment?

Note I have set the load paths up using Opal.append_path and it seems to be working as I can in fact require the .js.rb files, just not the templates which are in the same directory.

Mitch VanDuyn
  • 2,838
  • 1
  • 22
  • 29

1 Answers1

1

The answer is, that inside of the rails app the templates are getting compiled because they are in the require tree.

In the test I just needed to explicitly require each of the templates.

Mitch VanDuyn
  • 2,838
  • 1
  • 22
  • 29