spec/reek/smells/repeated_conditional_spec.rb in reek-1.4.0 vs spec/reek/smells/repeated_conditional_spec.rb in reek-1.5.0

- old
+ new

@@ -61,15 +61,21 @@ ast = src.to_reek_source.syntax_tree @ctx = CodeContext.new(nil, ast) @conds = @detector.conditional_counts(@ctx) end + it 'finds both conditionals' do expect(@conds.length).to eq(2) end + + it 'returns the condition expr' do + expect(@conds.keys[1]).to eq(@cond_expr) + end + it 'knows there are three copies' do - expect(@conds[@cond_expr].length).to eq(3) + expect(@conds.values[1].length).to eq(3) end context 'looking at the YAML' do before :each do @detector.examine(@ctx) @@ -84,11 +90,11 @@ end it 'reports the subclass' do expect(@yaml).to match(/subclass:\s*RepeatedConditional/) end it 'reports the expression' do - expect(@yaml).to match(/expression:\s*"?\(#{@cond}\)"?/) + expect(@yaml).to match(/expression:\s*(! )?['"]?#{@cond}["']?/) end it 'reports the number of occurrences' do expect(@yaml).to match(/occurrences:\s*3/) end it 'reports the referring lines' do @@ -123,11 +129,11 @@ expect(@conds.length).to eq(1) end it 'returns the condition expr' do expect(@conds.keys[0]).to eq(@cond_expr) end - it 'knows there are three copies' do - expect(@conds[@cond_expr].length).to eq(2) + it 'knows there are two copies' do + expect(@conds.values[0].length).to eq(2) end end # And count code in superclasses, if we have it end