require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES class Record include DataMapper::Resource property :id, Serial property :name, String end describe DataMapper::Trimmer do before do Record.auto_migrate!(:default) @record = Record.new end describe "setting a value" do describe "to text surrounding with blanks" do before do @record.name = " Simon Harris " end it "removes surrounding blanks" do @record.name.should == "Simon Harris" end end describe "to all blanks" do before do @record.name = " " end it "converts to nil" do @record.name.should be_nil end end describe "to nil" do before do @record.name = nil end it "leaves the value untouched" do @record.name.should be_nil end end end end end