Sha256: 1f7a1cc528bcc45d55111266800403af2f297532250dc44d9ea43f8490f56f35

Contents?: true

Size: 1.09 KB

Versions: 16

Compression:

Stored size: 1.09 KB

Contents

shared_examples_for 'a variable detector' do
  context 'with no variables' do
    it "doesn't record a smell" do
      @detector.examine_context(@ctx)
      expect(@detector.smells_found.length).to eq(0)
    end
  end

  context 'with one variable encountered twice' do
    before :each do
      @ctx.send(@record_variable, :something)
      @ctx.send(@record_variable, :something)
      @detector.examine_context(@ctx)
    end

    it 'records only one smell' do
      expect(@detector.smells_found.length).to eq(1)
    end
    it 'mentions the variable name in the report' do
      expect(@detector).to have_smell([/something/])
    end
  end

  context 'with two variables' do
    before :each do
      @ctx.send(@record_variable, :something)
      @ctx.send(@record_variable, :something_else)
      @detector.examine_context(@ctx)
    end

    it 'records both smells' do
      expect(@detector.num_smells).to eq(2)
    end
    it 'mentions both variable names in the report' do
      expect(@detector).to have_smell([/something/])
      expect(@detector).to have_smell([/something_else/])
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
reek-2.1.0 spec/reek/smells/behaves_like_variable_detector.rb
reek-2.0.4 spec/reek/smells/behaves_like_variable_detector.rb
reek-2.0.3 spec/reek/smells/behaves_like_variable_detector.rb
reek-2.0.2 spec/reek/smells/behaves_like_variable_detector.rb
reek-2.0.1 spec/reek/smells/behaves_like_variable_detector.rb
reek-2.0.0 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.6.6 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.6.5 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.6.4 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.6.3 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.6.2 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.6.1 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.6.0 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.5.1 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.5.0 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.4.0 spec/reek/smells/behaves_like_variable_detector.rb