Monday, December 31, 2012

Rake tasks cheatsheet

It's frustrating that typing:
     rake -T
gives you some but not all of the tasks that are available. If you are only a part-time user of Rails, it's easy to forget the precise syntax for those undocumented commands.

That's why I really liked the TutorialsPoint page which lists many more of the built-in rake -T commands. Very helpful.

Now, if folks would just fully document their rake tasks, we could see everything right where we need it without resorting to an external site.

Sunday, November 18, 2012

ERROR: Gem bundler is not installed, run `gem install bundler` first... FIXED

Have you ever had the problem when using RVM that bundler is listed as an installed gem, yet trying to run bundler gives you an error? This is obviously a regularly recurring problem as there are many posts about this issue... and most of them don't work.

jseidel@EDP15:~/Dev/WebForms$ gem list

 *** LOCAL GEMS ***

bundler (1.1.5)
json (1.7.5)
rake (
ruby-ole (
rubygems-bundler (1.0.6)
rvm (
spreadsheet (0.7.3)
jseidel@EDP15:~/Dev/WebForms$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.
jseidel@EDP15:~/Dev/WebForms$ whence bundle
bundle is /home/jseidel/.rvm/bin/bundle
My .bashrc script has the proper RVM incantations at the end of the file, and I've got a gemset defined... everything looks perfect, except that it doesn't work.  I've gotten bitten by this more than once, so at least with this post I won't have to go searching all over the place again to find the solution.

If you tried everything else and it still doesn't fix the problem, run the command:
rvm reload
and you should be good to go. Hopefully this'll help someone avoid the fruitless searches I went through. It would be nice if there was some kind of helpful message from RVM or somewhere a clear explanation of why this happens occasionally for no apparent reason.

Monday, January 23, 2012

Cucumber, Capybara, and Webkit testing for Ajaxified actions

I recently upgraded my testing stack and now use Capybara and Webkit with Cucumber (and RSpec, too). I ran into a number of problems and found this post by Mathew O'Riordan incredibly helpful. He tracks the history of his research and testing through a github project and at various points on the blog entry shows the commit for the changes he just discussed: kudos on that approach!

A couple of gotchas that I ran into along the way:

First, you may need to add the following line to your features/support/env.rb file:
require 'capybara-webkit'
O'Riordan doesn't do this in his project, but I got an error:
"no driver called :webkit was found, available drivers: :rack_test, :selenium (Capybara::DriverNotFoundError)"
and found this discussion which gave me the solution.

Second, although it may be obvious, I missed the fact that you MUST put
before each scenario that requires in-browser javascript. I had thought this was just a way of grouping scenarios together, but it actually triggers the use of the webkit driver to run the step.