I''m trying to ensure that various fields are saved to the database
without html, by stripping tags in before_save. However I''m having
trouble setting up the unit test for this and I''m not sure if
it''s my
code or my test that''s wrong.
The model code is:
def before_save
self.first_name = strip_tags(self.first_name)
self.last_name = strip_tags(self.last_name)
self.organisation = strip_tags(self.organisation)
end
The relevant part of my unit test is (obviously I''m doing for each item
in the before_save bit, but since it''s all the same I''m just
showing the
one):
c = Contact.new
c.first_name = "this"
c.last_name = "<html>that</html>"
c.organisation = "there"
c.email=''fran-Ildq/RkQoW9Wk0Htik3J/w@public.gmane.org''
c.save
assert_match("that", c.last_name)
Problem is that if I do assert_match("<html>that</html>",
c.last_name)
it also matches.
What''s my problem? Is it the code or the test?
Also, could someone help me with an assert_no_match regexp. I hate
regexps! I would like to do an assert_no_match with
<html>that</html> -
except I don''t know how to do a regular expression to check for an
exact
match with this.
Thanks to any help I can get!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---