Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## 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.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
This paste will be private.
From the Design Piracy series on my blog: