Sha256: 28d74a729cc418a3ad5b47cc335a1980b2b7633d5ffcd6c85cc48c4d2f07b0d4

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper.rb'

require 'reek/method_context'
require 'reek/stop_context'

include Reek

describe MethodContext, 'matching' do
  before :each do
    @element = MethodContext.new(StopContext.new, [0, :mod])
  end

  it 'should recognise itself in a collection of names' do
    @element.matches?(['banana', 'mod']).should == true
    @element.matches?(['banana']).should == false
  end

  it 'should recognise itself in a collection of REs' do
    @element.matches?([/banana/, /mod/]).should == true
    @element.matches?([/banana/]).should == false
  end
end

describe MethodContext, 'matching fq names' do
  before :each do
    element = StopContext.new
    element = ModuleContext.new(element, [0, :mod])
    element = ClassContext.new(element, [0, :klass])
    @element = MethodContext.new(element, [0, :meth])
  end

  it 'should recognise itself in a collection of names' do
    @element.matches?(['banana', 'meth']).should == true
    @element.matches?(['banana', 'klass#meth']).should == true
    @element.matches?(['banana']).should == false
  end

  it 'should recognise itself in a collection of names' do
    @element.matches?([/banana/, /meth/]).should == true
    @element.matches?([/banana/, /klass#meth/]).should == true
    @element.matches?([/banana/]).should == false
  end
end

describe MethodContext do
  it 'should record ivars as refs to self' do
    mctx = MethodContext.new(StopContext.new, [:defn, :feed])
    mctx.envious_receivers.should == []
    mctx.record_call_to([:call, [:ivar, :@cow], :feed_to])
    mctx.envious_receivers.should == []
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
kevinrutherford-reek-1.0.0 spec/reek/method_context_spec.rb
kevinrutherford-reek-1.0.1 spec/reek/method_context_spec.rb
reek-1.0.0 spec/reek/method_context_spec.rb