sfeley at gmail.com
Thu Feb 19 12:30:17 EST 2009
On Thu, Feb 19, 2009 at 12:15 PM, Stephen Eley <sfeley at gmail.com> wrote:
> But I did not write any code yet setting the message. Because I
> haven't written any tests for the message. At this point I don't care
> what the message is, just that I have the right data. I care about
> the message when I start focusing on presentation.
By the way, this spun off a whole line of thought in my head that
maybe the way Rails handles validation messages in general is wrong.
It's certainly a violation of separation of concerns: models aren't
supposed to care about presentation, and yet we're putting plain
English (or other language, or internationalized, or whatever) text in
then that isn't relevant to the data, just for the purpose of
presenting it to the user.
*This* is backwards, and maybe that's why I felt some conflict about
where the spec on that message should go. The responsibility of the
model is to report a problem, not to declare the exact wording of that
report. In an ideal MVC world models wouldn't be filling up hashes
with message text at all. They'd return exceptions on save, and the
standard create/update boilerplate in the controller would contain a
rescue instead of an if-then, and responsibility of turning the
properties of that exception into English would happen somewhere at
the view level.
Am I onto something here?
(Heh. Maybe I agree with Pat after all: I just went from a very minor
"I can't figure out how to test this" to the arrogance of suggesting
that pretty much every Ruby ORM should be rewritten.) >8->
Steve Eley (sfeley at gmail.com)
ESCAPE POD - The Science Fiction Podcast Magazine
More information about the rspec-users