- loading...
RSpec snippets/templates for RadRails
Using RadRails? Using RSpec? Missing some snippet/template love?
70 RSpec Textmate snippets have been ported for your rspec-ing pleasure by Kosmas Schütz.
Using RadRails? Using RSpec? Missing some snippet/template love?
70 RSpec Textmate snippets have been ported for your rspec-ing pleasure by Kosmas Schütz.
Now that RadRails is blessed with 100s of templates/snippets the challenge is now knowing what is available. Several people have had a crack at this: XSL conversions of the template XML into HTML, and Ruby scripts to convert the XML into text.
The nicest, most completest solution (that is, it is awesome and yet I didn’t have to do anything) is by Aran Donohue.
Aran now wields a rake field to update these two wiki sites whenever the templates/snippets change. Sweet cheating goodness.
Cop a glimpse at Aran’s cheating via Subversion:
http://arandonohue.com/svn/projects/EclipseCheatSheetMaker/
Amen.
I have started to cleanup the Ruby and RHTML templates previously released. They are now stored on SVN so you can get latest versions. They now have a ticketing system for improvements. They now have a Wiki for everyone to help everyone.
RadRails Templates now has a home: http://radrailstemplates.com/
Kyle from the RadRails is busy making improvements to template support for the next release, and has promised that the new and improved templates will also be included in it. Bonza.
You can get the latest edge releases of the templates via Subversion: http://radrailstemplates.com/svn/templates/trunk/
I’ve cleaned up a bunch of the original templates, and started to add new ones that seem generally relevant to everyone: see the CHANGELOG.txt
Currently the templates come in two big XML files: one for Ruby editor, and one for the RHTML editor. On the plus side, this makes importing new templates easy: you delete all the old templates and them import the new file, and go for a coffee.
On the negative side, this infers all new templates need to go into the same file and thus are imposed upon everyone. Instead there might be templates associated with rails plugins, that aren’t generic.
I don’t have a good plan for what to do about this yet. In the short term, submit any patches or new template files to trac and we’ll figure it all out in due course.
If you want to create patches of your own templates see below.
Similarly, if you add new templates locally and don’t want to share but don’t want to lose them each time you upgrade, my initial suggestion is to do the following:
svn co http://radrailstemplates.com/svn/templates/trunk/ radrailstemplatessvn update on the template files and your templates should be kept for you (unless you get nasty conflicts)FIXED You can happily ignore this section, or read Ry’s comment for solution.
My skills with apache are apparently lacking. Why does the raw port number keep appearing in the url?
Its hosted on TextDrive, and the .htaccess file in my /web/public folder is:
RewriteEngine On RewriteRule ^trac_common/(.*) http://radrailstemplates.com:8669/trac_common/$1 [P] RewriteRule ^trac/?(.*) http://radrailstemplates.com:8669/$1 [P] RewriteRule ^radrailstemplates(.*) http://radrailstemplates.com:8669/radrailstemplates$1 [P]
How do I fix this?
One my very early posts (3 months ago) might be useful to RadRailers if you haven’t already seen it: how to make RadRails text editors look like TextMate.
Its full of updates, comments and demos.

I tease myself with things I can’t have – like watching TextMate demo videos. One wonderful video shows a test-driven design demonstration by James Edward Gray II where he used Textmate snippets to generate the various assert statements. For example:
ase => assert_equal(expected, actual) asn => assert_nil(instance) asm => assert_match(/expected_pattern/, actual_string)
I’d been using Corban Brook’s templates but they didn’t include any assert or migration templates. And I wanted them without having to spend $3049 on TextMate [1]
Solution 1: Learn Emacs. Setting up Emacs with all the modules you’ll need is a non-trival exercise. That is, put aside a day or so and don’t expect to be finished when time runs out. Plus, a version of GNU Emacs for Windows hasn’t been released since 2005. Not a lot of OSS love there.
Solution 2: Offer to build Textmate for Windows. I’m sure I read once that the Textmate author was open to porting of Textmate to Windows. That must be the past, because their website claims very strongly that there will never be a port:
countless requests for both a Windows and Linux port, but TextMate remains exclusive for the Mac, and that is how we like it!
That’s just lazy if you ask me.
Solution 3: Port Textmate’s snippet libraries (bundles) over to RadRails. Textmate has a more powerful syntax for its snippets than RadRails has for its templates (a limitation inherited from Eclipse), but SUCCESS! On the 31st of October – the day when Textmate was lauded around the blogosphere for its Halloween theme, I ported all their snippets into RadRails. OoooOOOOHHH spooooky.
You can now access the latest and greatest in templates/snippets for Radrails, for Ruby/Rails and RHTML (or click on the yellow boxes at the top).
Too difficult? The next release of RadRails will include these new templates.
You can peruse a textmate-snippets-cheat-sheet, but really, spend 20 minutes looking through the template lists in RadRails. The name of the template is the text you type into the editor to activate the template.
So, the name of assert_equals is ase. So, type ase and press CTRL-SPACE, and a list of options pops up. Press return on the selected option.
Want to see all available assert_* templates? Type as and CTRL-SPACE and there they are. Nifty.
The RadRails guys are going to host these templates to allow anonymous access to make submitting patches relatively easy (if you know how to wield SVN). In future perhaps there will be a nice website for collaboratively sharing and downloading updates to templates.
I’ve put in a request for adding template support for JS and CSS as I have ported the JavaScript+CSS bundles as well. We just need a UI to import them into RadRails.
[1] TextMate is 39 euros = $49 at the moment. Plus $3000 for a new Mac.