Sha256: 2b38861dd5377994d967f3bf2be541075521dde331b19ad3a04321173ba8d879

Contents?: true

Size: 731 Bytes

Versions: 6

Compression:

Stored size: 731 Bytes

Contents

require 'pathname'
require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'

describe DataMapper::Types::Regexp, ".load" do
  it 'should make a Regexp from the value if a string is provided' do
    Regexp.should_receive(:new).with('regexp_string').once
    DataMapper::Types::Regexp.load('regexp_string', :property)
  end

  it 'should return nil otherwise' do
    DataMapper::Types::Regexp.load(nil, :property).should == nil
  end
end

describe DataMapper::Types::Regexp, ".dump" do
  it 'should dump to a string' do
    DataMapper::Types::Regexp.dump(/\d+/, :property).should == "\\d+"
  end

  it 'should return nil if the value is nil' do
    DataMapper::Types::Regexp.dump(nil, :property).should == nil
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dm-types-0.9.10 spec/unit/regexp_spec.rb
dm-types-0.9.6 spec/unit/regexp_spec.rb
dm-types-0.9.11 spec/unit/regexp_spec.rb
dm-types-0.9.9 spec/unit/regexp_spec.rb
dm-types-0.9.7 spec/unit/regexp_spec.rb
dm-types-0.9.8 spec/unit/regexp_spec.rb