Read my latest article: Ezra Zygmuntowicz -- Farewell, Friend. (posted Mon, 01 Dec 2014 17:53:00 GMT)

Rails, Logger, and those pesky Tests

Posted by Wed, 25 Jan 2006 22:06:00 GMT

7 comments Latest by Jacolyte Fri, 05 Feb 2010 23:38:55 GMT

First of all, I would like to thank all of you who took a moment to gather around the campfire with me and share your stuff. That was much appreciated.

So, I started playing with the idea of logging in unit and functional tests and I quickly realized that calling logger.info wasn’t an option. What’s the deal-e-o? Before I gather up my posse and conspire a train hijacking, I decided that I would see how quickly I could solve my problem before I called you all out to the Rio Rails Grande for an old-fashioned shoot out. Ya know, the kind that results in a Bon Jovi song and a little blood.

You’re all in luck because:
  • A) my holster was eaten by my dog and
  • B) I found a quick solution to clean up this logger situation.

Okay… are you ready?

I know… this is totally groundbreaking!!!

Open up test/test_helper.rb and add the method… logger.

# other stuff at the top of the file... just 
# look down below at def logger
class Test::Unit::TestCase
  self.use_transactional_fixtures = true
  self.use_instantiated_fixtures  = false

  # here... look here! right below this
  def logger
    RAILS_DEFAULT_LOGGER
  end
end

Save that and pick up your pistol…

The next step is to call the logger method in your unit and functional tests.

def test_the_obvious
  logger.info( 'asserting that 1 is 1' )
  assert 1, 1
end

I posted this on Rails Weenie as well.

Overheard at PLANET ARGON

Posted by Fri, 20 Jan 2006 18:54:00 GMT

6 comments Latest by Ian Mon, 23 Jan 2006 18:39:41 GMT

Some random quotes from this week:

“It’s fun coming to work and finding a passport form on your desk.”Jeremy Voorhis, Lead Architect of PLANET ARGON.

“Bright ideas are nearly worthless. Execution is everything.”Jason Watkins, Lead Product Developer of PLANET ARGON.

Debugging Rails

Posted by Fri, 20 Jan 2006 01:57:00 GMT

Isn’t it ironic? I’m working on a chapter related to debugging…. and just spent a few hours scratching my head over the following.

irb(#<ContactTypesController:0x262e570>):009:0> ContactType
=> ContactType
irb(#<ContactTypesController:0x262e570>):010:0> ContactType.methods.include? 'count'
=> true
irb(#<ContactTypesController:0x262e570>):011:0> ContactType.superclass
=> ActiveRecord::Base
irb(#<ContactTypesController:0x262e570>):012:0> 
Server exited. Closing connection...

(reload page...)

No connection to breakpoint service at druby://localhost:42531 (DRb::DRbConnError)
Tries to connect will be made every 2 seconds...
Executing break point at ./script/../config/../app/controllers/contact_types_controller.rb:6 in `index'
irb(#<ContactTypesController:0x277b93c>):001:0> ContactType
=> ContactType
irb(#<ContactTypesController:0x277b93c>):002:0> ContactType.superclass
=> Object
irb(#<ContactTypesController:0x277b93c>):003:0> ContactType.methods.include? 'count'
=> false

This occurs when running in development mode on WEBrick. (Rails 1.0)

I found this Rails bug report.

Switching to production mode fixed it. What’s the deal-e-o?

UPDATE

Tried again with Lighttpd. Same issue.

Ruby eye for the anti-newbie guy

Posted by Wed, 18 Jan 2006 15:44:00 GMT

7 comments Latest by fabert Mon, 30 Jan 2006 15:51:50 GMT

I was skimming over a few RSS feeds ( blogs.thoughtworks.com ) this morning and came across an entry by Griffin Caprio. He shared his thought on the new book by Chris Pine, Learn to Program and says the following:

”...You wouldn’t see these types of books in other professions like medical, engineering, or accounting because there are boards that prevent just any old person from practicing in those fields.

Not so in computing. But is this what we want to encourage? Anyone and everyone picking up software and just giving it a go?

And I understand everyone’s love of Ruby, but come on people. It’s just a language.”

Actually, yes. Learning to program, build, create, test, problem solve, etc… are all things that we should encourage.

Let’s do a quick search on amazon for the following, Learn to Program. I’m pretty sure these books have been common place for the past 20+ years… so, what’s the big deal?

It’s like telling a kid not to build a bird house until he gets a contractors license and a permit.

...or telling someone to not pick up a guitar until they had proper lessons.

...or maybe you shouldn’t be running a business without graduating from college.

I could go on and on.

Oh… and by the way…

puts "Hello World"

is much sexier than

public static void main(String[] args) {
  System.out.println ("Hello World"); 
}

On that note… check out Learn to Program by Chris Pine.

UPDATE Griffin has followed up to my blog entry with another. He goes on to say, “The kid who builds the bird house above would never be hired to build an actual house. Not true in Software Development.” (read more)

I think this problem raises a completely different problem. Why are unqualified people being hired to do things that they aren’t qualified for? Do we blame the people learning to program or do we look at who hires these people in the first place? I’m still confused by his argument.

That kid may not get hired to build a house, but he may get interested in that as a career and continue to pursue it… if someone hires him to build the whole house, then the person hiring should be held accountable do some degree as well. Check references! ;-)

On the flip-side… is this an argument to only take people who have been approved by some board (...MCSE?) seriously when hiring developers?

Update #2

Griffin has outlined his points in more detail in this third entry.

Don't Mock Me said the Dummy Object

Posted by Wed, 18 Jan 2006 15:11:00 GMT

2 comments Latest by J. B. Rainsberger Fri, 02 Jun 2006 21:27:41 GMT

Martin Fowler posted a short entry on his bliki titled, TestDouble where he mentioned Gerard Meszaros’ book which is a collection of patterns for Xunit frameworks. Martin then describes how Gerard has encountered a lot of confusion over similar names for testing objects (stubs, mocks, fakes, dummies,...) in different frameworks and has provided a nice description of each to help you differentiate between them.

Read more…

Rails development in 2006, part 2

Posted by Tue, 17 Jan 2006 15:15:00 GMT

Before I get too excited and make another cool announcement, I just want to say that I am really looking forward to 2006. This is going to be an amazing year.

Many people believe that there is going to be a significant spike in web development in the coming year and much of that is going to surround AJAX/Web2.0… and I can honestly say that this has been the case for the past several months here at PLANET ARGON. To prepare ourselves for the coming year, we have been working with some amazing developers… one of which is named, Jason Watkins, which we’ve just recently hired as our Lead Product Developer. He’s already proving to be a wonderful addition to our Core Team and I would expect that you’ll be hearing a lot more from him on his fairly new blog in the coming months. :-)

Welcome to the team Jason!

Older posts: 1 2