Sha256: 6addb3a7369fdff6cf7f8087419a60f831319e3e65c253d79e972ff2280f0a94
Contents?: true
Size: 1.43 KB
Versions: 6
Compression:
Stored size: 1.43 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper.rb' require 'reek/block_context' require 'reek/method_context' include Reek describe BlockContext do it "should record single parameter" do element = StopContext.new element = BlockContext.new(element, s(s(:lasgn, :x), nil)) element.variable_names.should == [Name.new(:x)] end it "should record single parameter within a method" do element = StopContext.new element = MethodContext.new(element, s(:defn, :help)) element = BlockContext.new(element, s(s(:lasgn, :x), nil)) element.variable_names.should == [Name.new(:x)] end it "records multiple parameters" do element = StopContext.new element = BlockContext.new(element, s(s(:masgn, s(:array, s(:lasgn, :x), s(:lasgn, :y))), nil)) element.variable_names.should == [Name.new(:x), Name.new(:y)] end it "should not pass parameters upward" do mc = MethodContext.new(StopContext.new, s(:defn, :help, s(:args))) element = BlockContext.new(mc, s(s(:lasgn, :x))) mc.variable_names.should be_empty end it 'records local variables' do bctx = BlockContext.new(StopContext.new, nil) bctx.record_local_variable(:q2) bctx.variable_names.should include(Name.new(:q2)) end it 'copes with a yield to an ivar' do scope = BlockContext.new(StopContext.new, [s(:iasgn, :@list), s(:self)]) scope.record_instance_variable(:@list) scope.variable_names.should == [:@list] end end
Version data entries
6 entries across 6 versions & 2 rubygems