require 'spec_helper' describe "Formatters::Text" do let (:parsed_file) { ParsedFile.new(class_name: "Foo", complexity: 11) } let (:method_1) { ParsedMethod.new( name: "initialize", complexity: 13, type: "instance" ) } let (:method_2) { ParsedMethod.new( name: "report", complexity: 11, type: "instance" ) } let (:formatter) { Formatters::Html.new(parsed_file) } before do allow(parsed_file).to receive(:methods) { [method_1, method_2] } end 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 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" allow(parsed_file).to receive(:methods) { [method_1, method_2] } 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