Sha256: 9118e93cf5b7fac113faccadc07eb738dbc54ef83dee5abe6b2aec901ffe1aed

Contents?: true

Size: 418 Bytes

Versions: 4

Compression:

Stored size: 418 Bytes

Contents

require 'spec_helper'
describe "Myrrha.coercions" do
  
  it "should support using user-defined domains" do
    name = Myrrha.domain{|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

4 entries across 4 versions & 1 rubygems

Version Path
myrrha-1.2.2 spec/myrrha/test_coercions.rb
myrrha-1.2.1 spec/myrrha/test_coercions.rb
myrrha-1.2.0 spec/myrrha/test_coercions.rb
myrrha-1.1.0 spec/myrrha/test_coercions.rb