Thursday, April 16, 2009

Ruby Concordion on Rails - Getting Started

UPDATE: The Ruby Concordion Project is pretty much inactive. This blog post is here for my own ego.


There aren't many tutorials out there about Ruby's version of Concordion so I figured that I would help you get started. In this post, I will give you some guidance on how to get started working with Rails 2.0+. The artifacts that concordion requires are:
  1. Directories for your specifications
  2. Directories for your instrumentation code, a.k.a. fixtures
  3. Directories to output your test results
  4. An easy way to include concordion functionality into your test suite
  5. Provide Rake tasks to run with your build


Create a directory to store your specifications:
$APP_ROOT/test/specs

Create a directory to store your instrumentation code:
$APP_ROOT/test/fixtures

Add a $APP_ROOT/test/fixtures/concordion_test_helper.rb that will make it easy to use Concordion:
==============================================================

#I guess you don't really need this line
ENV["RAILS_ENV"] = "test"

#This adds your specification directory to the Ruby load path
$:.unshift File.join(File.dirname(__FILE__),'..','specs')

#Lazily assign the output directory that concordion will write to
ENV['RCOR_OUTPUT_DIR'] ||= File.join(File.expand_path(File.dirname( __FILE__)),'..','spec-output')

#Load the existing Rails test helper
require File.join(File.dirname(__FILE__),"..","..","test_helper")

#The Concordion main module
require 'concordion/test_methods'

#Decorates all classes that inherit from TestCase class with concordion functionality
class Test::Unit::TestCase

def self.inherited(child)
child.send(:include, Concordion::TestMethods)
end
end

===============================================================
Create a Rake task to run your fixtures as part of your application code:
$APP_ROOT/lib/tasks/concordion.rake
===============================================================
require 'rake/clean'

#Set the directory where all of the test results will go
ENV['RCOR_OUTPUT_DIR'] ||= File.join 'test','concordion','spec-output'

#Task will create the output directory on demand
directory ENV['RCOR_OUTPUT_DIR']

#Add the output directory to the clean task
CLEAN.include ENV['RCOR_OUTPUT_DIR']

namespace :test do
namespace :concordion do
desc "Prepares the environment for running tests"
task :prepare => ['clean','db:test:prepare', ENV['RCOR_OUTPUT_DIR']]
end
end

Rake::TestTask.new('test:concordion' => 'test:concordion:prepare') do |t|
t.libs << "test"
t.libs << Dir[File.join('test','concordion','specs'),File.join('test','concordion','specs','**','*')].select{|item| File.directory?(item)}
t.test_files = FileList[File.join('test','concordion','fixtures','**','*.rb')]
t.verbose = true
end
============================================================================ Now you can create your specification here: $APP_ROOT/test/concordion/spec/order_state_rules.html Then the instrumentation: $APP_ROOT/test/concordion/fixtures/order_state_rules_test.rb ============================================================================
require File.join(File.dirname(__FILE__),"concordion_test_helper")

class OrderStateRulesTest < Test::Unit::TestCase; end


That's pretty much it. In future posts I will go over how to write your first set of examples and some of the mistakes spec authors make while working with Concordion.

Wednesday, April 15, 2009

Ruby Concordion 0.9.9.9

For those of you who have run who are getting cryptic errors while working with Concordion and Rails I have good news for you. Some of the bugs are fixed in version 0.9.9.9 out on RubyForge! As far as I know everything is working on with Ruby 1.8.6 and Rails 2.1 on both RHEL 4 x84_64 and Mac OS X i386.
If you have any trouble using this release feel free to post on our mailing list ruby-concordion@googlegroups.com and we will help you.
Happy Testing!

Thursday, April 9, 2009

Rails vrs Ruby Error Messages

Just discovered the following:
irb>nil.foo
NoMethodError: undefined method `foo' for nil:NilClass
from (irb):1

script/console>nil.foo
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.foo
from (irb):2

Wednesday, April 8, 2009

Holy Week Services Montclair, NJ

Saint Peter Claver Church ¨ 56 Elmwood Ave., Montclair, NJ 07042 ¨ 973-783-4852

HOLY THURSDAY
April 9th
7:00 PM – Solemn Mass of the Lord's Supper, Operation Rice Bowl Collection, followed by Adoration of the Holy Eucharist

GOOD FRIDAY
April 10th
Solemn Liturgy of the Passion and Death of Jesus
6:30 PM – Stations of the Cross begins in church w/ neighborhood procession followed by the Solemn Liturgy of the Lord's Passion.

HOLY SATURDAY EASTER VIGIL
April 11th
Blessing of Fire, Easter Candle & Water
7:30 PM – Solemn Easter Vigil Celebration

EASTER SUNDAY
April 12th
The Ressurection of the Lord Jesus
9:00 AM – English Eucharist
11:00 AM – English Eucharist
12:45 PM – Creole Eucharist
6:00 PM – Spanish Eucharist

DIVINE MERCY SUNDAY
April 19th
5:45 PM [Sat.] – English Eucharist
9:00 AM – English Eucharist
11:00 AM – English Eucharist
12:45 PM – Creole Eucharist
6:00 PM – Spanish Eucharist

SPIRIT OF EASTER MASS
Tuesday, April 21st 7PM