Sha256: ba4fe4a9cfd13c72318a74525cc78c9141cea9e80fcf2362e80c3d85f0309416

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

RSpec.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

10 entries across 10 versions & 1 rubygems

Version Path
reek-3.2.1 spec/reek/smells/behaves_like_variable_detector.rb
reek-3.2 spec/reek/smells/behaves_like_variable_detector.rb
reek-3.1 spec/reek/smells/behaves_like_variable_detector.rb
reek-3.0.4 spec/reek/smells/behaves_like_variable_detector.rb
reek-3.0.3 spec/reek/smells/behaves_like_variable_detector.rb
reek-3.0.2 spec/reek/smells/behaves_like_variable_detector.rb
reek-3.0.1 spec/reek/smells/behaves_like_variable_detector.rb
reek-3.0.0 spec/reek/smells/behaves_like_variable_detector.rb
reek-2.2.1 spec/reek/smells/behaves_like_variable_detector.rb
reek-2.2.0 spec/reek/smells/behaves_like_variable_detector.rb