Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Saturday, November 5, 2011

Using GitHub to get better at Ruby

Aside from being a great site to host open source software, GitHub is a great place to review other people's code. By following all the repositories you're interested in, you get to see all their latest updates on your dashboard when you log in. I've found it useful for writing better specs/scenarios - when I get writer's block, I go look at some of the bigger Ruby-based projects on Github for ideas.

Another cool thing to do is search repos for specific gems/libraries that you are interested in using, or trying to get your head around. When you search GitHub, you can do a search with very specific parameters.

For example: Search "Code" with language "Ruby" and term "require savon" to see other projects using the Savon gem - because consuming SOAP services in Ruby are so much fun! I mean, it's almost as good as getting teeth pulled... (Savon makes it bearable)

Wednesday, November 2, 2011

Bundle Install gives Gem::Exception: Cannot load gem at

While trying to install someone else's Rails 3.0.x app on my dev server, the 'bundle install' command kept failing, with an error about the cache location for gems.
$ bundle install

Fetching source index for http://rubygems.org/


Gem::Exception: Cannot load gem at [/usr/lib/ruby/gems/1.9.1/cache/rake-0.8.7.gem] in /home/rowan/newprj
An error occured while installing rake (0.8.7), and Bundler cannot continue.
Make sure that `gem install rake -v '0.8.7'` succeeds before bundling.

After reading a StackOverflow post on a similar error message I found that the way around it is to do a bundle install as root:
$ sudo bundle install

This isn't the right way to do it normally, and I don't recommend it, but it does seem to be necessary at the moment because Ubuntu (11.x) has Ruby 1.9.2 packaged under the 1.9.1 label/location.

Tuesday, November 1, 2011

We don't need no stinkin' web steps!

I spent my first attempts back in BDD-land wondering why all the examples I was reading kept referring to Capybara's web_steps.rb file, and why I didn't have it. It all made sense when I finally found this article by Aslak.

The file web_steps.rb was originally in Webrat (which is what I used last time I was doing Rails apps in Rails 2.3). It contained a bunch of pre-defined, regex-dependent steps which could be incorporated in to your scenarios for quick development of - but ultimately limiting - your scenarios.

Read the article for the full reasons behind it. It seems a bit of an inconvenience for someone starting out, but seeing as Aslak created Cucumber, I'm not going to argue with him about the finer points of BDD.

The Capybara API is what you should be using instead to replace web_steps.rb functionality in the future.