Guest User

Untitled

a guest
Jun 30th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. ## a simple remarkable test script
  2. require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
  3.  
  4. describe Feedback, 'A Feedback instance' do
  5.  
  6. VALID = {
  7. :name => "firstname lastname",
  8. :email => "email.email@email.com",
  9. :topic => "some topic",
  10. :message => "some message"
  11. }
  12.  
  13. it 'should accept VALID attributes' do
  14. assert f = Feedback.new(VALID)
  15. assert f.valid?
  16. end
  17.  
  18. should_require_attributes(:name, :message => "..hey you can't be anonymous!")
  19. should_require_attributes(:email, :message => "..I need your contact details.")
  20. should_require_attributes(:topic, :message => "..what are you writing to me about?")
  21. should_require_attributes(:message, :message => "..so you were saying?")
  22.  
  23. should_ensure_length_at_least(:name, 3, :short_message => "..uhm, can you be more specific?")
  24. should_ensure_length_at_least(:message, 5, :short_message => "..uhm, can you be more specific?")
  25. should_ensure_length_at_least(:topic, 5, :short_message => "..uhm, can you be more specific?")
  26.  
  27. should_allow_values_for(:name, "maricris", "ace", "greg", "john paul", "mary jesus joseph")
  28. should_not_allow_values_for(:name, "aa", "at", "jp", "1", "s", :message => "..uhm, can you be more specific?")
  29.  
  30. should_allow_values_for(:email, "email.email@email.com", "email_email@yahoo.com", "123@yahoo.com")
  31. should_not_allow_values_for(:email, "123@.com", "testing!@!yahoocom", "3@11234.#8com", :message => "..it should look something like yourname@something.com")
  32. end
Add Comment
Please, Sign In to add comment