Skip to content

Instantly share code, notes, and snippets.

@maricris-sn
Created October 23, 2010 09:17
Show Gist options
  • Save maricris-sn/641987 to your computer and use it in GitHub Desktop.
Save maricris-sn/641987 to your computer and use it in GitHub Desktop.
## a simple remarkable test script
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Feedback, 'A Feedback instance' do
VALID = {
:name => "firstname lastname",
:email => "[email protected]",
: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 protected]", "[email protected]", "[email protected]")
should_not_allow_values_for(:email, "[email protected]", "testing!@!yahoocom", "3@11234.#8com", :message => "..it should look something like [email protected]")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment