Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec_helper'
- class C
- def a
- 'I am a'
- end
- def b
- 'I am b'
- end
- def m(i)
- methods = {
- 1 => :a,
- 2 => :b
- }
- send(methods[i])
- end
- end
- describe 'Name hash' do
- it 'works' do
- obj = C.new
- expect(obj.m(1)).to eq('I am a')
- expect(obj.m(2)).to eq('I am b')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement