Sha256: 06b4def1187e56cdfe888d9cfbf4b0227f0d53fa89850ecb3e92c2f450610f3a

Contents?: true

Size: 416 Bytes

Versions: 9

Compression:

Stored size: 416 Bytes

Contents

require 'spec_helper'
describe "Myrrha.coercions" do
  
  it "should support using user-defined domains" do
    name = Domain.sbyc{|s| s.is_a?(Symbol)}
    rules = Myrrha.coercions do |r|
      r.coercion String, name, lambda{|s,t| s.to_sym}
      r.coercion name, String, lambda{|s,t| s.to_s}
    end
    rules.coerce("hello", name).should eq(:hello)
    rules.coerce(:hello, String).should eq("hello")
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
myrrha-3.1.0 spec/myrrha/test_coercions.rb
myrrha-3.0.0 spec/myrrha/test_coercions.rb
myrrha-3.0.0.rc7 spec/myrrha/test_coercions.rb
myrrha-3.0.0.rc6 spec/myrrha/test_coercions.rb
myrrha-3.0.0.rc5 spec/myrrha/test_coercions.rb
myrrha-3.0.0.rc4 spec/myrrha/test_coercions.rb
myrrha-3.0.0.rc3 spec/myrrha/test_coercions.rb
myrrha-3.0.0.rc2 spec/myrrha/test_coercions.rb
myrrha-3.0.0.rc1 spec/myrrha/test_coercions.rb