Report abuse

a simple remarkable test script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Feedback, 'A Feedback instance' do

    VALID = {
      :name => "firstname lastname",
      :email => "email.email@email.com",
      :topic => "some topic",
      :message => "some message"
    }

  it 'should accept VALID attributes' do
    assert f = Feedback.new(VALID)
    assert f.valid?
  end

  should_require_attributes(:name, :message => "..hey you can't be anonymous!")
  should_require_attributes(:email, :message => "..I need your contact details.")
  should_require_attributes(:topic, :message => "..what are you writing to me about?")
  should_require_attributes(:message, :message => "..so you were saying?")

  should_ensure_length_at_least(:name, 3, :short_message => "..uhm, can you be more specific?")
  should_ensure_length_at_least(:message, 5, :short_message => "..uhm, can you be more specific?")
  should_ensure_length_at_least(:topic, 5, :short_message => "..uhm, can you be more specific?")

  should_allow_values_for(:name, "maricris", "ace", "greg", "john paul", "mary jesus joseph")
  should_not_allow_values_for(:name, "aa", "at", "jp", "1", "s", :message => "..uhm, can you be more specific?")

  should_allow_values_for(:email, "email.email@email.com", "email_email@yahoo.com", "123@yahoo.com")
  should_not_allow_values_for(:email, "123@.com", "testing!@!yahoocom", "3@11234.#8com", :message => "..it should look something like yourname@something.com")
end