@@ -88,6 +88,45 @@ module CC::Engine::Analyzers
8888 expect ( run_engine ( engine_conf ) ) . to eq ( "" )
8989 } . to output ( /Skipping file/ ) . to_stderr
9090 end
91+
92+ it "analyzes erb files" do
93+ create_source_file ( "recipe.erb" , <<-EOERB )
94+ < div class ="container ">
95+ < h1 > Select a Category</ h1 >
96+ < ul >
97+ <% categories . each do |category | %>
98+ < li > < a href = "/category/ <%= category . id%> "> <%= category . name%> | <%= category . recipes . count%> Recipes </ a > </ li >
99+ <% end%>
100+
101+ <% categories . each do |category | %>
102+ < li > < a href = "/category/ <%= category . id%> "> <%= category . name%> | <%= category . recipes . count%> Recipes </ a > </ li >
103+ <% end%>
104+
105+ <% categories . each do |category | %>
106+ < li > < a href = "/category/ <%= category . id%> "> <%= category . name%> | <%= category . recipes . count%> Recipes </ a > </ li >
107+ <% end %>
108+ </ ul >
109+ </ div >
110+ EOERB
111+
112+ issues = run_engine ( engine_conf ) . strip . split ( "\0 " )
113+ result = issues . first . strip
114+ json = JSON . parse ( result )
115+
116+ expect ( json [ "type" ] ) . to eq ( "issue" )
117+ expect ( json [ "check_name" ] ) . to eq ( "Similar code" )
118+ expect ( json [ "description" ] ) . to eq ( "Similar code found in 2 other locations (mass = 30)" )
119+ expect ( json [ "categories" ] ) . to eq ( [ "Duplication" ] )
120+ expect ( json [ "location" ] ) . to eq ( {
121+ "path" => "recipe.erb" ,
122+ "lines" => { "begin" => 4 , "end" => 5 } ,
123+ } )
124+ expect ( json [ "remediation_points" ] ) . to eq ( 2_700_000 )
125+ expect ( json [ "other_locations" ] ) . to eq ( [
126+ { "path" => "recipe.erb" , "lines" => { "begin" => 8 , "end" => 9 } } ,
127+ { "path" => "recipe.erb" , "lines" => { "begin" => 12 , "end" => 13 } }
128+ ] )
129+ end
91130 end
92131
93132 describe "#calculate_points(mass)" do
0 commit comments