My friend once asked me how do you check whether 2 strings have the same charecters ie
"a c b" == "b c a"
So I wrote this quick stub to help my testers
class String #=> cause I dont need it for anyting else
def flatten_and_sort!
self.gsub!(/(\n|\t)/,'') #remove new lines so code could be formated batter
self.split(//).sort{|a,b| a <=> b}.delete_if{|str| str =~ / /}.join.downcase
end
end
So you can do
assert_equal @expected_alert_message.flatten_and_sort!,testing_value.flatten_and_sort!
This method is also useful when you build strings from hash which, due to indiferent sort on hash, will always produce different results.