spec/reek/smells/data_clump_spec.rb in reek-1.3.8 vs spec/reek/smells/data_clump_spec.rb in reek-1.4.0

- old
+ new

@@ -12,11 +12,11 @@ def first(pa) @field == :sym ? 0 : 3; end def second(pa) @field == :sym; end def third(pa) pa - pb + @fred; end end EOS - src.should_not smell_of(DataClump) + expect(src).not_to smell_of(DataClump) end context 'with 3 identical pairs' do before :each do @module_name = 'Scrunch' @@ -32,29 +32,29 @@ @smells = detector.examine_context(ctx) @warning = @smells[0] # SMELL: too cumbersome! @yaml = @warning.to_yaml end it 'records only the one smell' do - @smells.length.should == 1 + expect(@smells.length).to eq(1) end it 'reports all parameters' do - @smells[0].smell[DataClump::PARAMETERS_KEY].should == ['pa', 'pb'] + expect(@smells[0].smell[DataClump::PARAMETERS_KEY]).to eq(['pa', 'pb']) end it 'reports the number of occurrences' do - @smells[0].smell[DataClump::OCCURRENCES_KEY].should == 3 + expect(@smells[0].smell[DataClump::OCCURRENCES_KEY]).to eq(3) end it 'reports all methods' do - @smells[0].smell[DataClump::METHODS_KEY].should == ['first', 'second', 'third'] + expect(@smells[0].smell[DataClump::METHODS_KEY]).to eq(['first', 'second', 'third']) end it 'reports the declaration line numbers' do - @smells[0].lines.should == [2,3,4] + expect(@smells[0].lines).to eq([2, 3, 4]) end it 'reports the correct smell class' do - @smells[0].smell_class.should == DataClump::SMELL_CLASS + expect(@smells[0].smell_class).to eq(DataClump::SMELL_CLASS) end it 'reports the context fq name' do - @smells[0].context.should == @module_name + expect(@smells[0].context).to eq(@module_name) end end it 'reports 3 swapped pairs' do src = <<EOS @@ -62,47 +62,50 @@ def one(pa, pb) @field == :sym ? 0 : 3; end def two(pb, pa) @field == :sym; end def tri(pa, pb) pa - pb + @fred; end end EOS - src.should smell_of(DataClump, {DataClump::OCCURRENCES_KEY => 3, - DataClump::PARAMETERS_KEY => ['pa', 'pb']}) + expect(src).to smell_of(DataClump, + DataClump::OCCURRENCES_KEY => 3, + DataClump::PARAMETERS_KEY => ['pa', 'pb']) end it 'reports 3 identical parameter sets' do src = <<EOS #{@context} Scrunch def first(pa, pb, pc) @field == :sym ? 0 : 3; end def second(pa, pb, pc) @field == :sym; end def third(pa, pb, pc) pa - pb + @fred; end end EOS - src.should smell_of(DataClump, {DataClump::OCCURRENCES_KEY => 3, - DataClump::PARAMETERS_KEY => ['pa', 'pb', 'pc']}) + expect(src).to smell_of(DataClump, + DataClump::OCCURRENCES_KEY => 3, + DataClump::PARAMETERS_KEY => ['pa', 'pb', 'pc']) end it 'reports re-ordered identical parameter sets' do src = <<EOS #{@context} Scrunch def first(pb, pa, pc) @field == :sym ? 0 : 3; end def second(pc, pb, pa) @field == :sym; end def third(pa, pb, pc) pa - pb + @fred; end end EOS - src.should smell_of(DataClump, {DataClump::OCCURRENCES_KEY => 3, - DataClump::PARAMETERS_KEY => ['pa', 'pb', 'pc']}) + expect(src).to smell_of(DataClump, + DataClump::OCCURRENCES_KEY => 3, + DataClump::PARAMETERS_KEY => ['pa', 'pb', 'pc']) end it 'counts only identical parameter sets' do src = <<EOS #{@context} RedCloth def fa(p1, p2, p3, conten) end def fb(p1, p2, p3, conten) end def fc(name, windowW, windowH) end end EOS - src.should_not smell_of(DataClump) + expect(src).not_to smell_of(DataClump) end it 'gets a real example right' do src = <<EOS #{@context} Inline @@ -111,11 +114,11 @@ def c_singleton (src, options) end def c_raw (src, options) end def c_raw_singleton (src, options) end end EOS - src.should smell_of(DataClump, DataClump::OCCURRENCES_KEY => 5) + expect(src).to smell_of(DataClump, DataClump::OCCURRENCES_KEY => 5) end it 'correctly checks number of occurences' do src = <<-EOS #{@context} Smelly @@ -124,22 +127,22 @@ def fc(p3, p4, p5) end def fd(p4, p5, p1) end def fe(p5, p1, p2) end end EOS - src.should_not smell_of(DataClump) + expect(src).not_to smell_of(DataClump) end it 'detects clumps smaller than the total number of arguments' do src = <<-EOS #{@context} Smelly def fa(p1, p2, p3) end def fb(p1, p3, p2) end def fc(p4, p1, p2) end end EOS - src.should smell_of(DataClump, - { DataClump::PARAMETERS_KEY => %w(p1 p2) }) + expect(src).to smell_of(DataClump, + DataClump::PARAMETERS_KEY => %w(p1 p2)) end end describe DataClump do before(:each) do