Sha256: 79e2a801399600d6e0fa5dc4eeb001c4cfea27cb347aa4d698edf0e976be7c3a
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require 'rspec' require Pathname(__dir__) + '../lib/wyrm/core_extensions.rb' describe Method do describe '#kwargs_as_hash' do it 'empty for no keywords' do inst = Class.new do def without_kwargs( one, two ) @kwargs = method(__method__).kwargs_as_hash(binding) end end.new inst.without_kwargs :one, :two inst.instance_variable_get('@kwargs').should == {} end it 'gives back hash of keywords' do inst = Class.new do def with_kwargs( one: 'one', two: 'two') @kwargs = method(__method__).kwargs_as_hash(binding) end end.new inst.with_kwargs inst.instance_variable_get('@kwargs').should == {one: 'one', two: 'two'} end it 'has correct values' do inst = Class.new do def with_kwargs( one: 'one', two: 'two') @kwargs = method(__method__).kwargs_as_hash(binding) end end.new inst.with_kwargs( one: 1, two: 2 ) inst.instance_variable_get('@kwargs').should == {one: 1, two: 2} end it 'gets some default values' do inst = Class.new do def with_kwargs( one: 'one', two: 'two') @kwargs = method(__method__).kwargs_as_hash(binding) end end.new inst.with_kwargs( one: 1 ) inst.instance_variable_get('@kwargs').should == {one: 1, two: 'two'} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wyrm-0.3.1 | spec/core_extensions_spec.rb |
wyrm-0.3.0 | spec/core_extensions_spec.rb |