Posts Tagged ‘RSpec’

The RSpec Book is in beta!

Thursday, January 29th, 2009

A whole lot of Ruby developers are waiting for this book. It’s finally in Beta state, which means you can buy the PDF version and download new versions as the book is being written. For only US$ 24 it’s a bargain!

Title: The RSpec Book: Behaviour Driven Development with RSpec, Cucumber and Friends

350 pages, Apr 2009

Authors: by David Chelimsky, Dave Astels, Zach Dennis, Aslak Hellesoy, Bryan Helmkamp, Dan North.

ISBN: 9781934356371

Is your team trying to do TDD and failing? Are you finding your test suites bloated and difficult to read, understand, or maintain? Business applications today are plagued with features that are never used, highly coupled code that is hard to change, and expensive test suites that aren’t run any more because they are brittle and unreadable.

RSpec, Ruby’s leading Behaviour Driven Development tool, helps you do TDD right by embracing the design and documentation aspects of TDD. It encourages readable, maintainable suites of code examples that not only test your code, they document it as well. The RSpec Book will teach you how to use RSpec, Cucumber, and other Ruby tools to develop truly agile software that gets you to market quickly and maintains its value as evolving market trends drive new requirements.

Automatic file type detection for Rspec and Rails in Textmate

Saturday, November 29th, 2008

If your TextMate is:

  • using the Ruby Bundle for files that are Ruby on Rails;
  • using the Ruby on Rails Bundle for files that are Rspec;
  • any other wrong association.

There are some ways to fix. I followed these steps to fix it:

1. Remove the manual associations. When you use the popup bar at the status bar, in Textmate, you may not know but you are associating files to Bundles, manually, which is bad. To fix it, let’s first read what’s already in there. Run this command in the Terminal:


defaults read com.macromates.textmate OakLanguageFileBindings

Check the manual associations you’ve made so far. And remove them all with:


defaults delete com.macromates.textmate OakLanguageFileBindings

2. Specify inside a Bundle, which files it should be used for. Open Bundles → Bundle Editor → Edit Languages… and locate the Ruby Grammar. Inside this text area, locate a line that looks like this:


fileTypes = ( 'rb', 'rbx', 'rjs', 'Rakefile', 'rake',
  'cgi', 'fcgi', 'gemspec', 'irbrc', 'capfile' );

Remove the rb extension. And add it to the Ruby on Rails grammar instead. At the end my lines became like this:


# my Ruby Language grammar
fileTypes = ( 'rbx', 'rjs', 'Rakefile', 'rake', 
  'cgi', 'fcgi', 'gemspec', 'irbrc', 'capfile' );

# my Ruby on Rails Language grammar
fileTypes = ( 'rb', 'rxml', 'builder' );

As you see, the rb extension now belongs to the Rails Language Grammar.

Now whenever I open a *.rb file, the Bundle is Ruby on Rails. Whenever I open a *_spec.rb file, the Bundle is RSpec. You can always improve on that idea, and do what you think it’s best for you. For example, you can edit Ruby on Rails grammar for .erb files, .rjs, and the like.

Further information in the TextMate Blog’s post File Type Detection (RSpec & Rails).