-
Hi, I am trying to include the compiled assets in my test environment (rspec inside a Ruby on Rails project).
Is there a way or a better way to achive this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
You can try include the relevant helpers in your class. Shakapacker relies on some Rails helpers so you would need them also. Something like:
You can see how we do something similar (though with extend as we want the module methods to be class rather than instance methods) in one of the specs https://github.com/shakacode/shakapacker/blob/main/spec/shakapacker/helper_spec.rb |
Beta Was this translation helpful? Give feedback.
-
I have found the path of the compiled assets, but in my tests running the JS with MiniRacer, I am getting the following error:
I don't know if it's an error of MiniRacer or I have to include something more to be able to use the bundle.
Are there any examples of how to use a webpack bundle in rspec tests? |
Beta Was this translation helpful? Give feedback.
You can try include the relevant helpers in your class. Shakapacker relies on some Rails helpers so you would need them also. Something like:
You can see how we do something similar (though with extend as we want the module methods to be class rather than instance methods) in one of the specs https://github.com/shakacode/shakapacker/blob/main/spec/shakapacker/helper_spec.rb