Sha256: 13b883f87dfff5b46e6dd4121ff9b1ae56823bb1277df4b067ea3db4e11fc677

Contents?: true

Size: 1014 Bytes

Versions: 8

Compression:

Stored size: 1014 Bytes

Contents

require 'spec_helper'

describe 'mapping method names to ivars' do
  let(:mocked_class) { Surrogate.endow Class.new }

  [ :[]   ,  '@_brackets',
    :**   ,  '@_splat_splat',
    :'!@' ,  '@_ubang',
    :'+@' ,  '@_uplus',
    :'-@' ,  '@_uminus',
    :*    ,  '@_splat',
    :/    ,  '@_divide',
    :%    ,  '@_percent',
    :+    ,  '@_plus',
    :-    ,  '@_minus',
    :>>   ,  '@_shift_right',
    :<<   ,  '@_shift_left',
    :&    ,  '@_ampersand',
    :^    ,  '@_caret',
    :|    ,  '@_bang',
    :<=   ,  '@_less_eq',
    :<    ,  '@_less',
    :>    ,  '@_greater',
    :>=   ,  '@_greater_eq',
    :<=>  ,  '@_spaceship',
    :==   ,  '@_2eq',
    :===  ,  '@_3eq',
    :!=   ,  '@_not_eq',
    :=~   ,  '@_eq_tilde',
    :!~   ,  '@_bang_tilde',
  ].each_slice 2 do |method_name, ivar|
    it "maps #{method_name} to #{ivar}" do
      mocked_class.define method_name
      instance = mocked_class.new
      instance.instance_variable_set ivar, 123
      instance.send method_name
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
surrogate-0.8.1 spec/unit/map_method_name_to_ivar_spec.rb
surrogate-0.8.0 spec/unit/map_method_name_to_ivar_spec.rb
surrogate-0.7.0 spec/unit/map_method_name_to_ivar_spec.rb
surrogate-0.6.5 spec/unit/map_method_name_to_ivar_spec.rb
surrogate-0.6.4 spec/unit/map_method_name_to_ivar_spec.rb
surrogate-0.6.3 spec/unit/map_method_name_to_ivar_spec.rb
surrogate-0.6.2 spec/unit/map_method_name_to_ivar_spec.rb
surrogate-0.6.1 spec/unit/map_method_name_to_ivar_spec.rb