Yet Another Test First Example ... in Ruby

Our local XP group did a Test-Driven Design clinic. Although most of
the group chose to use either Java or .NET, I convinced one haples soul
to pair with me doing Ruby.

I wrote a reconstruction of the evening at …

http://w3.one.net/~jweirich/talks/tdddemo/

I put this together for two reasons.
(1) To reinforce the TDD technique for the those at the meeting who new
to XP.
(2) Provide an excuse to show some Ruby code to the group, in the hopes
recruiting Ruby pair programmers for our next meeing.

If you’ve seen Test-Driven Development before, this will be nothing new,
and there are certainly better Ruby tutorials out there. But I thought
I would post it here on the off chance someone finds it useful.

···


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

The link is dead. Is it correct?

Jim

···

On Tuesday, 14 January 2003 at 11:13:01 +0900, Jim Weirich wrote:

Our local XP group did a Test-Driven Design clinic. Although most of
the group chose to use either Java or .NET, I convinced one haples soul
to pair with me doing Ruby.

I wrote a reconstruction of the evening at …

http://w3.one.net/~jweirich/talks/tdddemo/


Jim Freeze

Excess on occasion is exhilarating. It prevents moderation from
acquiring the deadening effect of a habit.
– W. Somerset Maugham

Very nice …

One question:

In the “Our First Test” section, you say:
Ruby Comments: The require keyword in Ruby looks in the ruby libraries for a file named ‘test/unit.rb’ and will load it in to the running program.

Is “require” a keyword (i.e. reserved) in Ruby ? I always understood it as a function which took filename as argument.

Please correct me if I am wrong.

Thanks,

– shanko

“Jim Weirich” jweirich@one.net wrote in message news:1042510570.8219.177.camel@traken…

···

Our local XP group did a Test-Driven Design clinic. Although most of
the group chose to use either Java or .NET, I convinced one haples soul
to pair with me doing Ruby.

I wrote a reconstruction of the evening at …

http://w3.one.net/~jweirich/talks/tdddemo/

I put this together for two reasons.
(1) To reinforce the TDD technique for the those at the meeting who new
to XP.
(2) Provide an excuse to show some Ruby code to the group, in the hopes
recruiting Ruby pair programmers for our next meeing.

If you’ve seen Test-Driven Development before, this will be nothing new,
and there are certainly better Ruby tutorials out there. But I thought
I would post it here on the off chance someone finds it useful.


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

This is great. I want to sit programmers down with this on their first
day of work, or better yet, I’ll do an exercise along these lines with
them.

···

On Tue, 14 Jan 2003 11:13:01 +0900, Jim Weirich wrote:

Our local XP group did a Test-Driven Design clinic. Although most of
the group chose to use either Java or .NET, I convinced one haples soul
to pair with me doing Ruby.

Great presentation. I am curious how you generated the html for
the writeup.

···

On Tuesday, 14 January 2003 at 11:13:01 +0900, Jim Weirich wrote:

I wrote a reconstruction of the evening at …

http://w3.one.net/~jweirich/talks/tdddemo/


Jim Freeze

“I’d love to go out with you, but I’m having all my plants neutered.”

Jim Freeze wrote:

http://w3.one.net/~jweirich/talks/tdddemo/

The link is dead. Is it correct?

works for me - very nice job too.

cheers
dim

It is a method, but calling it a keyword probably makes more sense to
the target audience, who are expected to be unfamiliar with Ruby.

“require” occupies a space in programming languages usually known as
“keywords”, or in this case, “directives”. Implementation details
don’t really change that.

Gavin

···

On Tuesday, January 14, 2003, 2:53:20 PM, Shashank wrote:

Very nice …

One question:

In the “Our First Test” section, you say:

Ruby Comments: The require keyword in Ruby looks in the ruby
libraries for a file named ‘test/unit.rb’ and will load it in to the
running program.

Is “require” a keyword (i.e. reserved) in Ruby ? I always understood
it as a function which took filename as argument.

I was speaking informally, but you are correct. As Bruce Williams
points out, it is better to label it accurately.

Thanks.

···

On Mon, 2003-01-13 at 22:53, Shashank Date wrote:

Is “require” a keyword (i.e. reserved) in Ruby ?
I always understood it as a function which took filename as argument.


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

I have a propgram that generates a set of HTML pages from a text
description. It uses Wiki like markup and I can include source directly
from the source code file (so you don’t have to retype or cut-n-paste
code). I do a lot of technical presentations and use this to generate
the slides.

The program was written in the days before Dave put out RDoc and its
simple markup. I like the RDoc markup much better and it on my TODO
list to rework the program to use SM::SimpleMarkup.

···

On Tue, 2003-01-14 at 15:40, Jim Freeze wrote:

On Tuesday, 14 January 2003 at 11:13:01 +0900, Jim Weirich wrote:

I wrote a reconstruction of the evening at …

http://w3.one.net/~jweirich/talks/tdddemo/

Great presentation. I am curious how you generated the html for
the writeup.


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

I keep getting a failure/timeout. Is it working for you now?

···

On Tuesday, 14 January 2003 at 11:51:13 +0900, Dmitri Colebatch wrote:

Jim Freeze wrote:

http://w3.one.net/~jweirich/talks/tdddemo/

The link is dead. Is it correct?

works for me - very nice job too.


Jim Freeze

'I generally avoid temptation unless I can’t resist it."
– Mae West

Very nice …

One question:

In the “Our First Test” section, you say:

Ruby Comments: The require keyword in Ruby looks in the ruby
libraries for a file named ‘test/unit.rb’ and will load it in to the
running program.

Is “require” a keyword (i.e. reserved) in Ruby ? I always understood
it as a function which took filename as argument.

It is a method, but calling it a keyword probably makes more sense to
the target audience, who are expected to be unfamiliar with Ruby.

“require” occupies a space in programming languages usually known as
“keywords”, or in this case, “directives”. Implementation details
don’t really change that.

Gavin

Gavin,

Although I agree w/ the intent of your comment, the following has always
annoyed me:

“Ok class-- what I taught you over the past three weeks was actually WRONG.
Now let’s try to get rid of your bad habits by teaching you the RIGHT thing.”

If they know what a keyword is (or rather, it matters to them), they can
probably grasp ‘method’ without too much of a stretch-- In the very least, I
think it’s a vital part of anyone’s Ruby knowledge-- I’ve ran across too
many people that don’t know how Ruby is structured at the toplevel because
they learned concepts similar [to the above] and never un-learned them,
assuming the setup was similar to less-OO languages they had used before.

Implementation details, of course, don’t change the fact that people percieve
it as a keyword. But let’s not support it with technical writing as well…
if you have to, don’t label it at all:

Ruby Comments: [Using] ‘require’ in Ruby looks in the ruby
libraries for a file named ‘test/unit.rb’ and will load it in to the
running program.

Just my 2c. I know that doesn’t buy much these days ;-).

···

On Monday 13 January 2003 11:33 pm, Gavin Sinclair wrote:

On Tuesday, January 14, 2003, 2:53:20 PM, Shashank wrote:


Bruce R. Williams :: [iusris/#ruby-lang] :: http://www.codedbliss.com

‘It does not require a majority to prevail, but rather an irate,
tireless minority keen to set brush fires in people’s minds.’
– Samuel Adams

http://w3.one.net/~jweirich/talks/tdddemo/

The link is dead. Is it correct?

works for me - very nice job too.

I keep getting a failure/timeout. Is it working for you now?

as we speak…

http://w3.one.net/~jweirich/talks/tdddemo/index.html (copied from the
browser)

maybe ruby-talk is generating slashdot volumes of traffic to the site (o:

cheers
dim

I think this is totally awesome and I would like to see more like it.
I have been working through the book Test-Driven Development,
translating the Java (which I only barely understand) to Ruby, and have
really enjoyed learning to program in this way. Thank you.

Mark Wilson