Sha256: 7b338d0e75eee88ac211c03818330e0521d27fe179b283f3d5d09db12bd838b0

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-trimmer-0.1.0 spec/dm-trimmer/trimmer_spec.rb