Sha256: 0160d4af4e78c16b9ff6687c3abf5d3e5f13d389582e125af18b44d30159a6bd

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 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)
      @detector.num_smells.should == 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
      @detector.num_smells.should == 1
    end
    it 'mentions the variable name in the report' do
      @detector.should 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
      @detector.num_smells.should == 2
    end
    it 'mentions both variable names in the report' do
      @detector.should have_smell([/something/])
      @detector.should have_smell([/something_else/])
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
reek-1.2.7.2 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.2.7.1 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.2.7 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.2.6 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.2.5 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.2.4 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.2.3 spec/reek/smells/behaves_like_variable_detector.rb
reek-1.2.2 spec/reek/smells/behaves_like_variable_detector.rb