Skip to content

Instantly share code, notes, and snippets.

@Goles

Goles/test.rb Secret

Created February 28, 2012 15:35
Show Gist options
  • Save Goles/cce1ff6bf5cca01ccf5d to your computer and use it in GitHub Desktop.
Save Goles/cce1ff6bf5cca01ccf5d to your computer and use it in GitHub Desktop.
# checking what's in the email subject
emails.each { |m| puts m.subject }
# outputs
Propuesta Ganadora!
Propuesta perdida
Propuesta perdida
Propuesta perdida
Propuesta perdida
Propuesta perdida
Propuesta perdida
Propuesta perdida
Propuesta perdida
Propuesta perdida
Pago
Concurso finalizado!
# If I try to delete all the emails with the subject containing the word 'perdida'
counter = emails.delete_if { |m| m.subject.include? ('perdida') }.count
counter.should eq 9 # Counter is equal to 3
# If I negate my delete_if block I get the expected result
counter = emails.delete_if { |m| not m.subject.include? ('perdida') }.count
counter.should eq 9 # Counter is equal to 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment