summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMax Lincoln <max@devopsy.com>2014-08-08 14:03:42 -0400
committerMax Lincoln <max@devopsy.com>2014-08-08 14:03:42 -0400
commit555c1b9273b9af9d61fefabf185f6ae662e1a2d5 (patch)
tree3a469c978cd84c3cd754714b83aef168c4d96f09 /spec
parentdcde6199006fb77dc9e87408bfed9b9215b4c559 (diff)
downloadhashie-555c1b9273b9af9d61fefabf185f6ae662e1a2d5.tar.gz
Add support for coercion to Complex and Rational
Diffstat (limited to 'spec')
-rw-r--r--spec/hashie/extensions/coercion_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/hashie/extensions/coercion_spec.rb b/spec/hashie/extensions/coercion_spec.rb
index 4c1e295..cae8aa8 100644
--- a/spec/hashie/extensions/coercion_spec.rb
+++ b/spec/hashie/extensions/coercion_spec.rb
@@ -145,6 +145,14 @@ describe Hashie::Extensions::Coercion do
include_examples 'coerces from alphabetical types', String, :to_s
include_examples 'coerces from alphabetical types', Symbol, :to_sym
+ it 'can coerce String to Rational when possible' do
+ test_coercion '2/3', Rational, :to_r
+ end
+
+ it 'can coerce String to Complex when possible' do
+ test_coercion '2/3+3/4i', Complex, :to_c
+ end
+
it 'can coerce booleans via a proc' do
subject.coerce_key :foo, ->(v) do
case v