Sha256: b960d9efb7176e94ec026bbd472a286090b7f3e7f848e166541ff63311f5edfa

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

require 'spec_helper'
module Myrrha
  describe "Coercions#dup" do
    let(:rules){ Coercions.new{|r|
      r.coercion String, Integer, lambda{|s,t| Integer(s)}
    }}
    
    it "should duplicate the rules" do
      rules.dup.coerce("12", Integer).should eql(12)
    end
    
    it "should not touch the original" do
      dupped = rules.dup.append do |r|
        r.coercion String, Float, lambda{|s,t| Float(s)}
      end
      dupped.coerce("12", Float).should eql(12.0)
      lambda{ rules.coerce("12", Float) }.should raise_error(Myrrha::Error)
    end
    
    it "should not forget main_target_domain" do
      rules = Coercions.new do |r|
        r.main_target_domain = Integer
      end
      rules.dup.main_target_domain.should eql(Integer)
    end
      
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
myrrha-1.2.1 spec/coercions/test_dup.rb
myrrha-1.2.0 spec/coercions/test_dup.rb
myrrha-1.1.0 spec/coercions/test_dup.rb