require 'spec_helper' module DistribBuilder module Versioner describe FileProcessor do let(:processor) { described_class.new(Logger.new) } context "#check_existing_files" do it "does raise an error unless config file present" do allow( processor ).to receive(:config_path).and_return("") expect( processor.logger ).to receive(:missing_files) processor.check_existing_files end it "does raise an error unless cmakelist present" do allow( processor ).to receive(:cmakelist_path).and_return("") expect( processor.logger ).to receive(:missing_files) processor.check_existing_files end end context "#check_mandatory_sections_in_config" do it "does raise an error unless files section present" do allow( processor ).to receive(:config).and_return({}) expect( processor.logger ).to receive(:missing_mandatory_sections_in_config) processor.check_mandatory_sections_in_config end it "does raise an error if files section is empty" do allow( processor ).to receive(:config).and_return('files' => {}) expect( processor.logger ).to receive(:missing_mandatory_sections_in_config) processor.check_mandatory_sections_in_config end it "does raise an error unless patterns section present" do allow( processor ).to receive(:config).and_return('files' => { 'CMakeLists.txt' => [] }) expect( processor.logger ).to receive(:missing_mandatory_sections_in_config) processor.check_mandatory_sections_in_config end it "does raise an error if patterns section is empty" do allow( processor ).to receive(:config).and_return('files' => { 'CMakeLists.txt' => [] }, 'patterns' => {}) expect( processor.logger ).to receive(:missing_mandatory_sections_in_config) processor.check_mandatory_sections_in_config end end context "#read_config_files" do before(:each) do allow( processor ).to receive(:check_existing_files) end it "does read config file" do expect( processor.config ).to be_nil processor.read_config_files expect( processor.config ).to_not be_nil end it "does read cmakelist file" do expect( processor.cmakelist ).to be_nil processor.read_config_files expect( processor.cmakelist ).to_not be_nil end end context "#read_version_and_build" do it "does be ok" do processor.read_version_and_build end end context "#replace_version_and_build_in_files", broken: true do before(:each) do @versions_hash = { major: 1 } allow( processor ).to receive(:check_mandatory_sections_in_config) end it "" do processor.replace_version_and_build_in_files(@versions_hash) end end end end end