Testing
RSPEC is the latest cool thing.
Test::Unit is no longer in. It's like having
a Walkman instead of an iPod.
It's difficult to find out how to use RSpec, or what
it is supposed to do. If you run
rake rspec
you get all manner of odd messages.
However, I found a good intro to RSpec here:
blog.davidchelimsky.net/articles/2007/05/14/an-introduction-to-rspec-part-i
Create a new model, Person, with nothing in it.
Create spec/models/person_spec.rb and run it:
|
What puzzled me about test-driven-development
is when you write code you know is wrong, because it's the
simplest thing that will make the test pass:
|
But David Chelimsky explains it perfectly:
This is what I ended up with:
|
Getting this site up. The people at
railsplayground.com
are fantastic.
After deploying the site, I got this rather cryptic message
from one of their tireless elves:
'I have been asked to install merb- gems of version 1.0.1 when run the site...'
It took a lot of googling, installing and uninstalling gems
and changing dependencies.rb to read
When I tried to set db_gems_version to 0.9.7, this happened:
|
and when I set it to 0.9.9, this happened:
|
The solution was to set db_gems_version to 0.9.7 in dependencies.rb
and uninstall datamapper and data_objects version 0.9.9:
|
(That's good, by the way).
The site is now up and running. But you know that.
Added file uploads - see
www.idle-hacking.com/2007/09/scalable-file-uploads-with-merb/
but the internals of controller uploader.rb
are slightly different, and I created folder public/data
|
and you need app/views/uploader/index.html.erb:
Upload a new file |
The next step is to change authentication so
1. I can write on the site
2. Anyone can read it
This was difficult enough in Rails, but more difficult in
Merb. The comments in the Merb code are like this:
|
<% if session.user %> |
means 'if you are logged on' - thanks
singlecell.angryamoeba.co.uk/post/60951656/an-introduction-to-merb-auth-and-the-wonderful-secrets
Now I've done the site in Merb. This shows I am a Ruby developer, since Merb is difficult. All the documentation is just plain wrong, etc.. Fortunately, Merb is being taken over by the Ruby on Rails team, whose motto is "Web development that doesn't hurt". What I meant to say is the two teams are merging.
So the next plan is to move the site from Merb to Rails. I will document the process of doing this for the edification of others.