require 'spec_helper' describe "Fukuzatsu::Formatters::HTML" do let (:method_summary_1) { Fukuzatsu::Summary.new( :source => "foo.rb", :entity => "::initialize", :container => "Foo", :summaries => [] ) } let (:method_summary_2) { Fukuzatsu::Summary.new( :source => "foo.rb", :entity => "#print", :container => "Foo", :summaries => [] ) } let (:summary) { Fukuzatsu::Summary.new( :source => "foo.rb", :entity => "Foo", :container => "Foo", :summaries => [method_summary_1, method_summary_2] ) } let (:formatter) { Fukuzatsu::Formatters::Html.new(summary: summary) } describe "#header" do it "returns an HTML-formatted header" do expect(formatter.header).to eq( "Class\r\nMethod\r\nComplexity" ) end end describe "#rows" do before do allow(summary).to receive(:container_name).and_return("Foo") allow(summary).to receive(:entity_name).and_return("*") allow(summary).to receive(:complexity).and_return(13) allow(summary).to receive(:averge_complexity).and_return(11) allow(method_summary_1).to receive(:container_name).and_return("Foo") allow(method_summary_1).to receive(:entity_name).and_return("::initialize") allow(method_summary_1).to receive(:complexity).and_return(13) allow(method_summary_2).to receive(:container_name).and_return("Foo") allow(method_summary_2).to receive(:entity_name).and_return("#report") allow(method_summary_2).to receive(:complexity).and_return(11) end it "returns HTML-formatted rows" do expected = "\r\n Foo\r\n ::initialize\r\n 13\r\n\r\n" expected << "\r\n Foo\r\n #report\r\n 11\r\n" expect(formatter.rows).to eq(expected) end end describe "#file_extension" do it "returns the proper extension" do expect(formatter.file_extension).to eq ".htm" end end end