Sha256: 432f73f902641dbca7aefee9e5b0a3b3de46572d1f7eb567462697f22452dd57
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
require 'spec_helper' try_spec do describe DataMapper::Property::Regexp do before :all do class User include DataMapper::Resource property :id, Serial property :regexp, Regexp end @property = User.properties[:regexp] end describe '.load' do describe 'when argument is a string' do before :all do @input = '[a-z]\d+' @result = @property.load(@input) end it 'create a regexp instance from argument' do @result.should == Regexp.new(@input) end end describe 'when argument is nil' do before :all do @input = nil @result = @property.load(@input) end it 'returns nil' do @result.should be_nil end end end describe '.dump' do describe 'when argument is a regular expression' do before :all do @input = /\d+/ @result = @property.dump(@input) end it 'escapes the argument' do @result.should == '\\d+' end end describe 'when argument is nil' do before :all do @input = nil @result = @property.dump(@input) end it 'returns nil' do @result.should be_nil end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dm-types-1.0.0 | spec/unit/regexp_spec.rb |
dm-types-1.0.0.rc3 | spec/unit/regexp_spec.rb |
dm-types-1.0.0.rc2 | spec/unit/regexp_spec.rb |
dm-types-1.0.0.rc1 | spec/unit/regexp_spec.rb |