Geoffrey on February 24, 2008 at 12:35 am
I am a big RSpec fan. But occasionally, I work on projects that use test/spec. When I want output the spec documentation with RSpec, I just use rake spec:doc. With test/spec, I couldn’t find such a thing. So I made one and stuck it in lib/tasks/test_spec.rake
Rake::TestTask.new(:specdox) do |t|
t.options = '--runner=specdox'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
Rake::Task[:specdox].comment = "Generate specdox."
Now I can use rake specdox to see all the wonderful spec documentation!
Filed under: RSpec, Testing, test/spec, documentation
Geoffrey on February 11, 2008 at 11:08 am
I have been given the opportunity to join a GREAT group of guys. Starting today, I will be working full-time with Relevance. So if you are looking for software development, I know a good group of developers who can build exactly what you need.
Filed under: Uncategorized
Geoffrey on February 5, 2008 at 8:37 pm
I presented on RSpec 1.1 tonight at the Dallas.rb. I don’t claim to be an expert, I just love my specs (and now stories).
Feel free to take a look at the slides.
Filed under: RSpec, Ruby, Dallas, Testing
Geoffrey on January 12, 2008 at 10:58 am
Last night I recieved my very own copy of “Nobody Knows Shoes” by why the lucky stiff. Shoes, in case you are wondering, is a small framework for writing GUI applications that can run on multiple OS’s (Windows, Mac, Linux). “Nobody Knows Shoes” is the API documentation for the framework presented in the form of… well… comic book/ short stories/ examples… and that doesn’t even do it justice. I played around with Shoes and decided to get the book to see what it was all about. It is well worth the cost (less than $15, including shipping), if not for the pure entertainment value. It is also a good reference, as well.
If you haven’t experienced why or any of his code, you should definitely take a look. You will be entertained and enlightened.
Filed under: Ruby, Shoes
Geoffrey on January 10, 2008 at 9:54 am
So I came across Dan Manges Fixture Factory as a way to relieve myself of the pain of fixtures for testing. I don’t mind fixtures that much, but when I have to start setting up so many different combinations, it gets a little challenging. In reading through the comments I found that Scott Taylor had implemented it as a plugin. Now I get all that goodness for my specs.
The other day I wanted to play with some things using script/console, but was feeling too lazy to set up all of the data I was going to need to do what I wanted. Sure enough after looking at the documentation for fixture_replacement, I can use it there too:
% script/console
>> include FixtureReplacement
>> cause = create_cause
>> user = create_user
>> cause.users << user
It is really useful for easily setting up your test data in the spec (or test) that you are writing. Instead of having to go off to the fixture files and add new fixtures (and try to remember to set up all of the dependent fixtures that are needed), you can use new_xxx or create_xxx to get an object to test in a valid state with all its dependent data.
Take a look at the FixtureReplacement plugin now.
Filed under: Rails, RSpec, Ruby, Testing
Geoffrey on December 17, 2007 at 11:33 am
I recently upgraded StagingTracks.com to use Rails 2.0. I was excited about so many of the newest features that it seemed the logical thing to do. I even decided to upgrade RSpec in the process so I would be able to play with some of the new features there too.
Unfortunately, despite extensive local spec’ing, when I deployed the app to Dreamhost, things did not go as planned. I was using piston to manage my Rails in the app and all of my plugins, so I didn’t need to worry about which gems were installed on the server. What I found was that when users tried to submit new information using the forms on the site, nothing would happen. Let me correct that: It would look like something happened, but no data was submitted.
So what was the problem?
I first started by watching the production.log to see if the data was even getting submitted. As expected, nothing was coming through. I then used the Tamper Data plugin for Firefox to see if I if the data was getting out of the browser. It was, but something interesting appeared. I saw a 301 Redirect when the page was submitted. Odd. Especially since the application wasn’t seeing the data and there were no redirects in the production.log.
So I started looking in the http access.log to see why the data wasn’t coming through to the app. What I saw was surprising:
- - [16/Dec/2007:19:24:30 -0800] "POST /shops HTTP/1.1" 301 591 "http://www.stagingtracks.com/shops/new" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
- - [16/Dec/2007:19:24:30 -0800] "GET /shops/ HTTP/1.1" 200 319 "http://www.stagingtracks.com/shops/new" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
It looked like the POST (which goes to the ‘create’ method using Rails RESTful approach) was being redirected to ‘/shops/’. The browser would then call ‘/shops/ ‘ with a GET (which is the ‘index’ action). And the form submission never got through. Now I was perplexed. Why would the web server being sending the 301 Redirect?
It became a little clearer when I saw this in the logs as well:
- - [16/Dec/2007:19:15:11 -0800] "GET /shops HTTP/1.1" 301 591 "http://www.stagingtracks.com/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
- - [16/Dec/2007:19:15:11 -0800] "GET /shops/ HTTP/1.1" 200 89174 "http://www.stagingtracks.com/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
For some reason, the web server was causing 301 Redirects when the trailing slash was missing! Now I had heard of the trailing slash problem, but couldn’t find a suitable solution that would be easy to implement.
So How Do You Fix It?
I am so glad I am surrounded by lots of smart people. A quick conversation with my friend Rob Sanheim turned up the solution.
I added the following to my .htaccess file:
DirectorySlash Off
I added it after the Options +FollowSymLinks +ExecCGI and before the RewriteEngine On
Now things are back to normal again. I am now able to get back to connecting model railroaders.
Filed under: Rails, RSpec, Web Applications, Web Development, Dreamhost
Geoffrey on December 1, 2007 at 10:44 pm
My friend, Chris Gay, is a finalist in the Amazon Web Services Startup Challenge with his company, MileMeter. I love the concept of only paying for the auto insurance I am going to use. Both my wife and I work out of the home and therefore our cars sit in the garage alot. But I still have to pay the same rates as my neighbors who drive to downtown Dallas everyday. For both cars!
So now I urge you to go and vote for Chris and MileMeter.
Filed under: Rails, Ruby, Web Applications, Entrepreneurial, Dallas, North Texas
Geoffrey on November 9, 2007 at 12:25 pm
I got a Dell 2007WFP Ultrasharp 20″ LCD monitor this week using BINalert.com.
First, about the monitor and setup. It is a great monitor, nice and bright! My friend, Matt, encouraged me to spend a little more and get the Ultrasharp. I am glad I did (although I didn’t pay much more, see below). I REALLY love the portrait mode. In the picture I have Mailplane, Pyro, Skype, and Twitterific all stacked nicely. And it doesn’t feel crowded. I use VirtueDesktops and keep all my work on the another virtual desktop. On the “work” desktop I put Textmate and can see lots of lines of code. Plus I still have room to keep open console windows at the bottom to see autotest results, server logs, etc. My browser can stay open on the laptop for easy inspection of whatever I am developing.

Now about BINalert.com. (Disclosure: I built this site with a friend and I do make money with it.) BINalert lets you setup up alerts so you can get notifications on new Buy-It-Now auctions on eBay. There are lots of items listed with Buy-It-Now prices that are REALLY good deals. For example, this monitor. I setup an alert to watch for Dell 2007WFP Ultrasharp monitors with a Buy-It-Now price of $250 or less. As soon as this one was listed, I got an email letting me know. I went and checked it out (it was used but in great condition), and a week later I have my new monitor (or at least it’s new to me). And I saved about $150 in the process.
Filed under: Entrepreneurial, Development Environment
Geoffrey on November 8, 2007 at 8:22 pm
Last night, Adam Keys and I did a little ping pong pairing for the Dallas.rb meeting. It was fun. Of course it highlighted how much I have to jump back to the Ruby docs to get much done. But I don’t see that as a problem, since it leaves more room in my head for other things. It also showed my lack of regex-fu.
Here is the code we worked on. We were trying to solve the Ruby Quiz Credit Card problem, and got most of the way through. The fun part about pairing was bouncing ideas off of each other. Others in attendance were also helpful with their suggestions. It was especially interesting as we looked back over the code and discussed even more ways to clean it up.
Would I do it again? You bet. But I think next time, I would like to work on something that I am more comfortable with, like a Rails related app. I love writing specs for that.
Filed under: RSpec, Ruby, Dallas
Geoffrey on September 13, 2007 at 10:51 am
I love JQuery! I did a short 10-15 minute presentation at the last Dallas.rb to let others in on the joys of using JQuery.
But one thing that doesn’t work right when using JQuery with Rails applications is the JQuery AJAX features and Rails respond_to. It turns out the Rails it looking for a specific request header, but JQuery sends something different one.
It is easily solved with this at the top of your application.js file:
$.ajaxSetup({
beforeSend: function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");}
});
Filed under: Rails, JavaScript, JQuery, AJAX