[rspec-users] OT: Implementation Question

James Byrne lists at ruby-forum.com
Fri Dec 19 10:50:06 EST 2008

I have asked about this issue on several different mailing lists and
have had no response. If anyone here can offer some advice then I would
be much obliged.

I have a feature that essentially says:

  Given I have a user "myuser"
  When I fill in "User Name" with "MyUser"
    And I press "Login"
  Then I should find a user "myuser"
    And I should be logged in

The steps definitions for this are all quite conventional and at the
moment "Then I should find the user "myuser"" is failing, as expected.

My question is: What is best practice with respect to normalizing form
input data?  My feeling is that this sort of thing belongs in the model
but I cannot see a way to get this to work.  In short, how to implement
this feature?

I have extended String with a method called hll_keycase which preforms
the desired normalization.  The setter for Users.username is overridden
in the model and the stored values in the database are all properly
normalized.  But, it seems to me at the moment that the only place to
normalize form input data for the SELECT required to determine if the
username exists or not is either in the form or in the controller.  Is
that the case?

This has to be a recurring issue for data input forms and yet I can find
very few resources on the web that address this issue at all, and those
are often terse to the point of unintelligible.

Not exactly a test issue but I really could use some guidance with this
as whatever technique I finally adopt will pervade the entire project.
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list