June 27, 2013
Target your recruiting
If you find digging around in stuff like this fun, you might want to take a look at our job page: http://prezi.com/jobs/ :)
I have to wonder if they find anyone this way, but given how specific it is—it’s unlikely this message reaches anyone who wouldn’t be at least a little qualified—and how low the cost, it’s a pretty efficient recruiting message.
June 5, 2013
The application uses Rails 3.2 (actually 3.2.13 at the moment). I made a false start using the
jasmine-rails gem, but in the end I had two big problems with that: the
rake task which was supposed to run the tests couldn’t find the Jasmine library, and while Rails was able to mount the Jasmine engine, it wasn’t loading the scripts I intended to test.
I dumped that branch and went back to master and started over. Following the tip on the Jasmine page linked above, this time I tried using
jasmine-gem. (It was v1.3.0.) I installed it as directed on the gem’s README page, specifically by adding
gem 'jasmine' to the project’s
bundle install, and then
rails g jasmine:install and
rails g jasmine:examples.
(In the end I didn’t commit any of the code generated by the
jasmine:examples generator, but it was illuminating.)
The gem then suggests starting a server with
rake jasmine, and sure enough, that worked. It took a bit to get the server seeing the code to be tested, however. This involved tweaking the
src_dirvalue needed to be
public/assets. This Stack Overflow question pointed me in the right direction. I had to add a manifest file (i.e.
assets/application.js) to the
src_filesarray as well in order to include the script containing the code I wanted to test.
- I needed jQuery to be available to Jasmine.
jasmine-jqueryturned out to be the solution here, not because it itself is useful (although it is) but because it pointed out that I needed to add jQuery to my
src_filesfile. (It isn’t in my manifest because I’m loading it from a CDN.)
Now I had running Jasmine tests. (Once I wrote the tests, of course, within the
For this I wound up installing
guard-jasmine. (This was v1.16.0.) Once that was in my bundle (add to
bundle install, rinse, etc.) I ran
guard init jasmine and it added a block to my
Running this was a little trickier, however, because once again I needed to train it to find the code I wanted to test against. This required me to install
jasminerice (v0.0.10), even though I don’t need that gem’s primary function. Once I had that in my bundle and had created a
Now, about that test code: