Joined May 2011
·

Luke van der Hoeven

Software Engineer at Articulate
·
Bluffton, SC
·
·
·

Posted to Wisely pick your dates for specs over 1 year ago

Why are you testing assignment at all? I assume that set_start_date = '01/02/2012' is actually supposed to be set_start_date('01/02/2012')? Or maybe start_date = '01/02/2012'

Assignment is a language construct and so I would assume it to be correct and thus not worth testing. If you're overriding the assignment operator, I think that's sort of a bad idea because of this problem. I would assume from the code that:

profile.set_start_date = '01/02/2012'
expect(profile.start_date).to eq('01/02/2012')

Would be true... I realize Rails does this all the time, but I think it's bad practice and should be avoided for clarity. Otherwise I agree with the point: "us[ing] that method in both the test and the spec, you're certain it is getting set, but it might be getting set one month off without you realizing it."

SO MUCH CTRL

if using zsh, it's even faster. all you need is the -

Achievements
324 Karma
13,999 Total ProTip Views