require 'spec_helper' module DistribBuilder module Versioner describe Logger do let(:logger) { described_class.new(true) } # verbose = true it "does raise an error" do expect{ logger.missing_files }.to raise_error(RuntimeError, /DistribBuilder.yml or CMakeLists.txt is missing in current directory/) end it "does print string with current version" do logger.show_current_version("1.2.3") end it "does print string with current build" do logger.show_current_build(1) end it "does print string with new version" do logger.new_version("1.2.3.4") end it "does print string about changing build" do logger.build_changed(2) end it "does print string about changing version" do logger.version_changed("1.2.3") end it "does raise an error" do expect{ logger.file_not_found('CMakeLists.txt') }.to raise_error(RuntimeError, /File not found:/) end it "does print string about replacing pattern in file" do logger.found_and_replace_pattern_in_text("_BUILD \d+", "CMakeLists.txt") end it "does print string about writing changes into file" do logger.write_changes_into_file('CMakeLists.txt') end it "does print string about starting increment build process" do logger.start_increment_build end it "does print string about starting decrement build process" do logger.start_decrement_build end it "does print string about starting setup build process" do logger.start_setup_build end it "does print string about starting setup version process" do logger.start_setup_version end it "does raise an error" do expect{ logger.pattern_not_match("_BUILD \d+", 'CMakeLists.txt') }.to raise_error(RuntimeError, /was not matched in file/) end it "does raise an error" do expect{ logger.missing_mandatory_sections_in_config }.to raise_error(RuntimeError, /DistribBuilder.yml must contains both files and patterns sections/) end it "does raise an error" do expect{ logger.incorrect_setup_build("A") }.to raise_error(RuntimeError, /Incorrect build number. It must be digit but it was 'A'/) end it "does raise an error" do expect{ logger.incorrect_setup_version("123") }.to raise_error(RuntimeError, /Incorrect version number. It must be in format X.X.X but it was '123'/) end end end end