testdouble / jasmine-rails

A Jasmine runner for rails projects that's got you covered in both the terminal and the browser
http://rubygems.org/gems/jasmine-rails
MIT License
378 stars 154 forks source link

Variables in erb files #186

Closed asenamdsol closed 8 years ago

asenamdsol commented 8 years ago

Hello,

I am attempting to test functions in the app/assets/javascripts/application.js.erb file. The spec runs fine, and the function I am attempting to test is found. The problem is, because it is an erb file, there are variables being used that are not rendered. I had assumed that because the applications.js.erb file is in the asset pipeline and the server is running that any variables used would be rendered. Is it even possible to do what I am attempting?

Thanks

searls commented 8 years ago

Yeah, this isn't possible or feasible. Jasmine is designed for unit testing, and your erb processing will happen outside the context of your traditional application server (e.g. Ivars set in your controllers won't be set). This isn't supported

On Feb 19, 2016, at 5:15 PM, Anthony Sena notifications@github.com wrote:

Hello,

I am attempting to test functions in the app/assets/javascripts/application.js.erb file. The spec runs fine, and the function I am attempting to test is found. The problem is, because it is an erb file, there are variables being used that are not rendered. I had assumed that because the applications.js.erb file is in the asset pipeline and the server is running that any variables used would be rendered. Is it even possible to do what I am attempting?

Thanks

— Reply to this email directly or view it on GitHub.

asenamdsol commented 8 years ago

Thanks for the reply. Looked all day for a solution. Tired of banging my head against the wall.