Unit Testing and assert_match

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='[email protected]'
c.save

assert_match("that", c.last_name)

Problem is that if I do assert_match(“that”, 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 that -
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!

Try R.Tidy plugin :
http://www.agilewebdevelopment.com/plugins/railstidy