require 'spec_helper' describe LayoutFile do before(:all) do @file = 'layouts/new_layout1.layout' @content = <<-EOF layout :name1 do end EOF create_file @file, @content @full_path = File.join(working_directory, @file ) @layout_file = LayoutFile.new(@full_path) end it "returns the path of the layout" do expect(@layout_file.path).to eq(@full_path) end it "returns the content of the layout file" do expect(@layout_file.content).to eq(@content) end it "raises an Error if an unexisting layout file is given" do expect { LayoutFile.new('invalid path') }.to raise_error Exceptions::FileNotFound end it "let you compare instances by path" do file1 = 'layouts/layout1.layout' file2 = 'layouts/layout2.layout' create_file file1 create_file file2 layout_file1 = LayoutFile.new(File.join(working_directory, file1)) layout_file2 = LayoutFile.new(File.join(working_directory, file2)) result = ( layout_file1 == layout_file1 ) expect(result).to eq(true) result = ( layout_file1 == layout_file2 ) expect(result).to eq(false) end end