For the first time in quite a while, I’ve been able to spend time working on a brand-new Rails application that’s actually a business thing and not a side project. It’s small. Okay, it’s really small. But at least for the moment it’s mine, mine, mine. (What was that about collective code ownership? I can’t hear you…) This seemed like a good time to reflect on the various Object-Oriented Rails discussions, including Avdi’s book, DCI in Rails, fast Rails tests, Objectify, DHH’s skepticism about the whole enterprise, and even my little contribution to the debate.
The key to fast tests is simple: don’t do slow things. Warning: this post is a kind of long examination of a problem, namely, how to integrate fast non-Rails tests and slow Rails tests in the same test suite. This may be a problem nobody is having. But having seen a sample of how this might work, I was compelled to try and make it work in my toy app. You’ve been warned, hope you like it.
Consider this part of an occasional series where I attempt to revisit tools discussed in Rails Test Prescriptions that have undergone some revision. (NOTE: Most of this was written before the DHH Twitter-storm about testing this week. For the purposes of this post, I’m choosing to pretend the whole thing didn’t happen.) The cucumber-rails gem released version 0.4 last week, which had some significant changes, and intensified what we might call the opinionated nature of Cucumber over what a Cucumber scenario should look like.
Here’s something I haven’t done in a while – a genuine code blog entry. I needed to add a simple CSV file output, here’s how I did it, tests and all. I used two gems, FasterCSV, which I assume that most of you are familiar with, and Comma, which is a nice little DSL for specifying CSV formats. (Thanks again to Jason Pearl for reminding me what the gem was called…).
Book Status Beta 5 should be out early this week, featuring a mostly new chapter on testing legacy projects, and also updating the code setup and the initial walkthrough chapters to Rails 3. Over the next couple betas any remaining Rails 3 incompatibilities will also be fixed. Book Reviews Something new for you on a Monday, a couple of novels that I liked in the last couple of weeks. Kraken, by China Mieville.
Status Not much to tell, really. Spent some time getting RVM set up, since I think I’ll need it to manage simultaneously building the Rails 2 and Rails 3. Now I have a working version of the startup appendix that uses Rails 3 and Devise. I can’t speak to using Devise in practice yet, but the immediate goal of making the setup less complicated was definitely accomplished. The big question now is how much to support Rails 2 in the walk-through chapters.
The title, by the way, is from a favorite scene in a favorite movie. Status Now definitely working on the “dealing with legacy code” chapter, which I am hoping will be substantially more useful than the Lulu version, in that it will cover a few more techniques. I should know later today what the timeline is for beta 4. Links Let’s see what we’ve got today. Nick Quaranto over at Thoughtbot wants you to stop leaving time bombs in your tests.
Link post today. Turns out I built up more links than I thought. Book Status Somehow I wound up writing and editing the Rcov chapter, which, among other things, is the first time I’ve had to wrestle with RSpec 2 vs. RSpec 1 behavior, when writing about how RSpec and Rcov get along. Now I need to figure out how to write about that more coherently. Actually, I need to decide if I’m going to acknowledge RSpec 1 at all.
Okay, There’s a New iPhone Don’t really have a whole lot to say beyond what’s already been said. It looks very slick, and if anybody can actually pull off getting people to use video chat, it’s Apple. The form factor of video chat from a phone seems at first glance to be significantly better than from either a laptop or the iPad, in that it seems easier to hold the phone in a position to get a good angle.
Routes Geoffrey Grossenbach at Peepcode posted a typically beautiful post/rant about Rails routing. DHH responded in the comments of the article on YCombinator. Grossenbach argues that Routes are unnecessary configuration and offers a couple of options for moving the routing into the controllers, as Sinatra does. DHH responds that GG’s schemes would be challenging for large projects, and that the seven default action names are an important constraint. Everybody’s making good points here, so lets have the debate.
Short today, but preparing some longer, more rant-y bits for the future… Book status Not much forward motion for the next few days, as I have a lot of other stuff to do, including preparing for Chicago Ruby on June 1 and doing a bit of touch-up on Obtiva’s 4-Day Ruby on Rails/TDD boot camp. All fun, but time consuming. Some Links A quick tutorial by Peter Cooper on setting up JQuery in Rails 3.
Top Story Got interviewed yesterday by Miles Forrest and Curtis McHale of the coderpath podcast. Presumably it’ll be out and public in the next couple of weeks. You’ll be the first person I tell. Couple things It’s been a while since I did anything like this, and I always forget how much it’s a genuine skill to be able to give a clear answer without doing a lot of ums and ahs.
Top Story Beta 3 should be out today. The main change in this Beta is the inclusion of the Cucumber chapter, which has been updated both in terms of new tech, and also in terms of conclusions about how to use Cucumber. And In Rails news… When last we met, Rails 2.3.6 had just been released. Well, in the intervening 24 hours, we’ve bumped all the way to 2.3.8, with two bug fix releases, explained by Jeremy Kemper here and here.
Top Story Rails 2.3.6 released, with more changes than I expected, taking it just a little bit beyond a bug-fix release. Follow the link for the full release notes. Things that caught my eye: Looks like they made an official plugin to give Rails 2.3.6 the default HTML safe behavior of Rails 3. Although the note is vague and I could be misunderstanding. Alert and notice are now separate methods rather than just being keys on the flash.
Book Status Starting to sound repetitive. Still working on the Cuke chapter, this time focusing on cleaning up the parts where I recommend ways to use Cucumber. Still hoping for a beta early next week. Other things This week in Yehuda, there’s a very long article about text encodings and what problems they have, and in particular how Ruby’s implementation is shaped by the complicated relationship between Unicode and Japanese.
Top Story MacRuby 0.6 is out. Big new features include a debugger, a new interface to Cocoa’s Grand Central Dispatch, and a rewrite of the internals of basic Ruby classes. In a related story, the early text of Matt Aimonetti’s MacRuby book from O’Reilly is available for free online. Nice job all around. I’m not sure if I’ve mentioned it here, but I use MacRuby and its ability to manipulate AppleScriptable programs to power my crazy-obsessive iTunes random playlist generator, so speed improvements are hoped for.
Top Story/Book Status This is the week – Rails Test Prescriptions should go on beta sale on Wednesday. In a related story, railsrx.com now points to here, railsprescriptions.com also will shortly. I’ll be adding some basic about information and static pages here. At some point, I’ll probably bring over any blog content from the previous site that still seems relevant. I’m not sure if the original free version of Rails Test prescriptions will still be available (it’s becoming out of date, and there will be free samples available at Pragmatic), but I will make it available if anybody is still interested.
Top Story and Book Update I have sample cover designs. I don’t think I can show them yet, but I’ve got ‘em, I like them, and hopefully we’ll have picked one to show shortly. Tab dump Not a whole lot today: Here’s a look at the current status of using a non-blocking MySQL driver with Rails. The promise here is for significantly faster database access. Two stories that are related to projects that I worked on back in my EdTech days:
Just a quick mention that part 1 of my article series on using Rails to write iPhone apps is online at IBM Developerworks. Parts 2 and 3 will be published sometime in the rather near future. In other notes, Pathfinder has updated the company blog URL to http://www.pathf.com/blogs. Individual authors now have unique pages, I’m http://www.pathf.com/blogs/noel rappin. Recent pieces there include a quick welcome to RailsConf, and a two-part article on HTML and code markup in Rails, available here and here.
A couple of updates on book and article news… It looks like the screencast/video thing is going to happen, thanks to Jim Minatel. The main constraint is that they’d like the videos to be about five minutes long. I think the first one will be setting up a Rails project in Subversion (chapter 2 of the book, essentially), and I’d do a remix of that chapter using Git if there’s interest.
Two articles on the Pathfinder blog on adding show and hide toggles to a Rails application: http://blogs.pathf.com/agileajax/2008/04/hide-and-go-see.html http://blogs.pathf.com/agileajax/2008/04/hide-seek-and-s.html
Annnddd… This, of course, is what I get for posting anything about Wiley late at night without checking. Jim Minatel from Wiley added the following comment: Noel: I’m interested in getting Wrox authors to to videos related to their books…. I can tell you what’s involved and see what we can do. So, contacting in progress. Further bulletins as events warrant. Or as events don’t warrant, I think further bulletins are inevitable.
New post on the pathfinder blog: Using ActiveRecord to Migrate Legacy Data Enjoy!
![223888 cover_df.pdf (3 pages).jpg](http://blogs.pathf.com/agileajax//223888 cover_df.pdf (3 pages).jpg)This week, my book Professional Ruby on Rails will be officially released. You can see sample chapters here, and you can buy the book at Amazon (affiliate link). This book is designed to meet the needs of an intermediate to advanced Ruby on Rails user. The first wave of Rails books could not assume that the user had any pre-existing knowledge of Rails. As a result, they spent a lot of time covering the basics.
As I’ve mentioned here a few times, I have a book coming out, “Professional Ruby on Rails”, available later this month. If you’d like a sneak peek, Wrox has put some samples online as PDF files. You can also just buy the book. Chapter 1 – This sets up the sample project used in the book, and talks about the new REST features in Rails. Table of Contents – Take a look at this to see if your favorite topic is covered.
First off, several pathfinder blog posts to catch up on… A two part series on a quick little testing tool that I wrote called testbed. Part 1. Part2. Predictions for 2008 How to test custom form builders in RSpec. I wrote this in the hope that somebody else won’t have to spend two hours Googling this. Coming soon, “Why I stopped using RSpec…” My contribution to a discussion on duck typing, Save the Duck!
Somebody anonymous asks: As most of the currently available books cover Rails 1.2, are you providing the code in the books also as Rails 1.2? The sample example in the book is Rails 2.0, which was Edge Rails when I started, and I just validated all the tests against 2.0.2 last week when I turned in the finished code samples. Where there’s a significant change between 1.2 and 2.
In response to the commenter who asked if there was going to be a beta book. UPDATE: Clearly I should ask about these things before I post. Jim Minatel from Wrox added the following in comments: There will be a PDF about six weeks after the print book, meaning end of March or thereabouts. There will also be an Amazon Kindle version, eventually. Also after 6 weeks, the book will be available via Wrox’s online subscription service: http://wrox.
Just got the next version of the book chapters for my examination. I’m not 100% sure exactly where these fit in the process. It looks like they’ve had a good look-see from a copyeditor, largely for style, clarity, and consistency. (Any lingering “we” sentences seem to have been pruned, for example). They produced a book-specific style guide, which is a listing of canonical forms for things like plugin names, capitalization of commands or tools and the like.
Some things I learned about Rails and writing while working on this book: The great benefit of working on a project like this book is that it enabled me to compress about two years worth of research into Ruby and Rails tools into six months. In my case, this was a great opportunity to really dig into some tools to find that I’ve only been using a fraction of their power and also really get a sense of how elegant and flexible the tools are.
I turned in the last chapter of Author Review on Monday, and Professional Ruby On Rails is now in production. Target release date is still mid-February, final page count will be in the range of 450. I was able to keep the test-first nature of the code going through nearly all of it, which I’m really happy with. The table of contents looks something like this (in theory, still subject to change…)
Wow, I haven’t been here for a while. Sorry about that. Here’s the deal… The Rails book initial draft went in about a week ago, more or less on time. (Well, on time for a slightly revised schedule). My understanding of the current schedule is that the author review phase will continue through November. After that, it goes to production, where I get another crack at revising thing that have changed.
Couple quick things while I have a minute… Just turned in Chapter 10 (of 16) of the Rails book. Still mostly on schedule for a turn in on October 26, not quite sure what that implies for a print date As I write this, the wxPython book is at 11 thousand and change on Amazon, the highest I’ve seen in months, which is probably a fluke. Weirdly Amazon says it’s the #15 book on “Website Architecture & Usability”, which would be great if it was, you know, actually about website architecture usability…
A few things I forgot to put in the last book update: The Amazon listing has the book at 600 pages. That’s almost certainly optimistic. The contract calls for 400-500. As far as the schedule goes, I’m currently hoping to turn the complete draft in on October 26th, which is about ten days after the original date. The publisher says that pushes publication out to April, six to eight weeks after the original date.
I was fortunate enough to attend Pragmatic’s Rails Edge mini-conference here in Chicago last week. I have two blog posts up on this at Pathfinder, the first is made up of quotes from my notebook, and the second is some general thoughts. Enjoy.
Here’s a couple notes on the current status of the Rails book and life in general. The Rails book is presently just about 30% done – first payment triggered (yay!). I’m reasonably happy about it so far, though definitely too close to it at the moment to have a clear sense of its quality. I do like the way the test integration is working out – it seems to help my descriptions of functionality to have the tests there.
In the interests of being able to push out quick updates on the book’s progress, I’ve created a Twitter account for the book. You can follow that account on the sidebar of this here blog, or at http://twitter.com/noelrappinbook – there’s also an RSS feed. Please remember that any and all information about the book is subject to change at whim. Enjoy.
It’s been about a week or so of continued radio silence, so I thought I’d pop in with an update. I’m in the middle of chapter three of the Rails book. I think it’s going well, but nobody other then me has read the chapters yet, so that’s easy to say. My first milestone date is the end of the month, and four chapters done – that’s about one-quarter of the entire book.
I’m pleased to be able to say that I’ve contracted for a new book, Professional Ruby on Rails, scheduled to be available in “early 2008”, hopefully February or March. The publisher is Wiley, through the Wrox imprint – the ones with the red covers and the author’s picture on them. Wiley wanted me to be sure and mention that the ISBN number is 9780470223888, so you’ll be ready to pre-order it the second that becomes possible.
I wasn’t planning on posting about either web apps or linking to Joel Spolsky again, but this language wars post is just too interesting to pass up. Besides, a jillion people have already commented on this, so what’s a jillion and one? Spolsky is riffing on what language or platform you should use for an enterprise web project. He makes a few points (note, I’m paraphrasing him here – these are his points, not mine):