Archives

Older posts coming eventually.

When I started blogging, it had everything: links, short posts, long posts, pictures. Web 2.0 has brought new ways of creating that content, but it feels scattered. This site brings my multiple streams of content back to one place, like we did in the good old days.

Friday, November 09, 2007

Why I am a DataMapper convert (it makes BDD happy)

T here’s lots of buzz around DataMapper right now, especially among the #merb crowd. I haven’t had any major issues with ActiveRecord, so I haven’t needed to look at a new ORM…but I like to play with new things, so last night I really gave the DM a try.

I’m a complete convert, if for no other reason that the awesome way automigrations play along with BDD.

First, tell your spec_helper to use automigrations:

DataMapper::Base.auto_migrate!

This will cause your database tables to be dropped and re-created so use with caution.

Next, let’s spec some behavior:

it "should have a username field" do
  @person.username = "jjames"
  @person.username.should == "jjames"
end

And see what autotest says:


....F.....

1)
NoMethodError in 'Person should have a username field'
undefined method `username=' for #<person:0x13f720c>
./spec/models/person_spec.rb:38:

Finished in 0.049775 seconds

10 examples, 1 failure

Cool, that’s what we expected. Now, with ActiveRecord, to get to green, we’d need to create a migration and run it. With DataMapper, we stay in our model:

class Person < DataMapper::Base
  property :username, :string
end

And autotest says…


..........

Finished in 0.040584 seconds

10 examples, 0 failures

Now, is this perfect? Not yet. DM has a good amount of work still. There’s some smart folks working on it, and I bet it will be pretty sweet in a few more weeks.

But, man…that’s just awesome.

Wednesday, November 07, 2007

Merb 0.4.0 released

A bout 6 months ago or so I looked at Merb as a potential replacement for small apps that I didn’t want to use Rails for. It seemed cool, but pretty rough, and I didn’t have a good reason to use it.

Fast forward to the Ruby Hoedown in August. Ezra Zygmuntowicz, Merb’s creator, gave a talk about Merb. I saw some things I had missed, that were really exciting.

  • HTTP Status Codes handled via Exceptions
  • Emphasis on speed and small code base
  • Closer match between the framework and the flavor of the HTTP spec

I checked out the code.

I played around.

I got excited about how I could keep most of the code in my head at the same time.

I submitted some patches.

Ez gave me commit.

I wrote some sample controllers and specs.

I wrote a replacement for `respond_to` that I think is pretty awesome.

I flew to Charlotte for about 18 hours for a Merb hack session at RubyConf.

Tonight, Ez pushed Merb 0.4.0 to Rubyforge.

It’s just crazy to think how quickly I’ve gotten involved in this project, how excited I am about this 0.4.0 release, and how much I’m looking forward to using this framework to build some cool apps.

If you’re interested in Merb, pop over to http://merbivore.com or join us on IRC in #merb. We’re pretty sure you’ll like it.