Sha256: 78a6078099a279d018c0d43492033674e3367e610de2acb5c165cb22bae0b982

Contents?: true

Size: 516 Bytes

Versions: 12

Compression:

Stored size: 516 Bytes

Contents

require 'spec_helper'
describe :clojures_and_scoping do

  class Foo
    
    def a_method
      :inside
    end
    
    def evaluate(lamb)
      if RUBY_VERSION <= "1.9"
        self.instance_eval(&lamb)
      else
        self.instance_exec(&lamb)
      end
    end
    
  end
  
  specify "when no name clash" do
    Foo.new.evaluate(lambda{ a_method }).should == :inside 
  end
  
  specify "with name clash" do
    a_method = :outside
    Foo.new.evaluate(Proc.new{ a_method }).should == :outside 
  end
  
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-core/assumptions/test_scoping.rb
alf-core-0.14.0 spec/unit/alf-core/assumptions/test_scoping.rb
alf-core-0.13.1 spec/unit/alf-core/assumptions/test_scoping.rb
alf-core-0.13.0 spec/unit/alf-core/assumptions/test_scoping.rb
alf-0.12.2 spec/unit/alf-core/assumptions/test_scoping.rb
alf-0.12.1 spec/unit/alf-core/assumptions/test_scoping.rb
alf-0.12.0 spec/unit/alf-core/assumptions/test_scoping.rb
alf-0.11.1 spec/unit/alf-core/assumptions/test_scoping.rb
alf-0.11.0 spec/unit/alf-core/assumptions/test_scoping.rb
alf-0.10.1 spec/unit/assumptions/test_scoping.rb
alf-0.10.0 spec/unit/assumptions/test_scoping.rb
alf-0.9.3 spec/unit/assumptions/test_scoping.rb