Sha256: 8bd5da10dbc4c198bfd2d3517531cf89a99290d51de671a8becb4a88ef9af213
Contents?: true
Size: 1.21 KB
Versions: 17
Compression:
Stored size: 1.21 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)) 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 end
Version data entries
17 entries across 17 versions & 3 rubygems