Monday, October 25, 2010

Rails 3 + Cucumber

Cucumber is a great gem to describe features.

To setup with Rails 3, we will need to use the README documentation on Github.

1) Include the necessary gems
2) $ bundle install
3) $ rails g cucumber:install --rspec --capybara

Generate a Feature
4) rails g cucumber:feature post title:string description:text published:boolean
5) rails g scaffold post title:string description:text published:boolean
6) rake db:migrate
7) Comment out the line require 'cucumber/rails/capybara_javascript_emulation' in /features/support/env.rb
8) rake cucumber

Sunday, October 17, 2010

Creating a Gem with Bundler

Bundler is really cool in that it helps manage gem dependencies and its a default in Rails 3.


Using those information, i am going to run through steps to start making a gem.

Step 1
$ bundle gem awesome-stuff

Step 2
Make some changes to .gemspec

Step 3
Put the logic in /lib/awesome-stuff

Step 4
require the rb files in /lib/awesome-stuff.rb

Step 5
$ git add .
$ git commit -m "My first gem commit"

Step 6
$ gem build awesome-stuff.gemspec
$ gem install awesome-stuff-0.0.1.gem

Now fire up Interactive Ruby (irb)
> require 'rubygems'
> require 'awesome-stuff'
> Awesome::Pop.makeSomeNoise
> Hello Gem!
> => nil

It works!

The github documentation has some information on using Rspec and Gem Dependencies stuff that you might be interested.
And share the gem with the rest of the world.