require 'spec_helper' module DistribBuilder module Versioner describe Main do let(:versioner) { described_class.new([]) } before do allow( versioner ).to receive(:logger).and_return(Logger.new) allow( versioner ).to receive(:arg_processor).and_return(ArgumentProcessor.new([])) allow( versioner ).to receive(:file_processor).and_return(FileProcessor.new) allow( versioner ).to receive(:version_processor).and_return(VersionProcessor.new([1,2,3,4])) end context "#run" do it "does call prepare_processors method" do expect( versioner ).to receive(:prepare_processors) versioner.run end end context "#increment_build" do before(:each) do allow( versioner.file_processor ).to receive(:replace_version_and_build_in_files) end it "does call version_processor.build_up! method" do expect( versioner.version_processor ).to receive(:build_up!) versioner.increment_build end it "does call file_processor.replace_version_and_build_in_files method" do expect( versioner.file_processor ).to receive(:replace_version_and_build_in_files) versioner.increment_build end end context "#decrement_build" do before(:each) do allow( versioner.file_processor ).to receive(:replace_version_and_build_in_files) end it "does call version_processor.build_up! method" do expect( versioner.version_processor ).to receive(:build_down!) versioner.decrement_build end it "does call file_processor.replace_version_and_build_in_files method" do expect( versioner.file_processor ).to receive(:replace_version_and_build_in_files) versioner.decrement_build end end context "#setup_build" do before(:each) do allow( versioner.file_processor ).to receive(:replace_version_and_build_in_files) allow( versioner.arg_processor ).to receive(:setup_build).and_return("123") end it "does call version_processor.setup_build! method" do expect( versioner.version_processor ).to receive(:setup_build!).with("123") versioner.setup_build end it "does call file_processor.replace_version_and_build_in_files method" do expect( versioner.file_processor ).to receive(:replace_version_and_build_in_files) versioner.setup_build end end context "#setup_version" do before(:each) do allow( versioner.file_processor ).to receive(:replace_version_and_build_in_files) allow( versioner.arg_processor ).to receive(:setup_version).and_return("1.2.3") end it "does call version_processor.setup_version! method" do expect( versioner.version_processor ).to receive(:setup_version!).with("1.2.3") versioner.setup_version end it "does call file_processor.replace_version_and_build_in_files method" do expect( versioner.file_processor ).to receive(:replace_version_and_build_in_files) versioner.setup_version end end context "#show" do it "does call logger.show_current_version method" do allow( versioner.arg_processor ).to receive(:show).and_return(:version) expect( versioner.logger ).to receive(:show_current_version) versioner.show end it "does call logger.show_current_build method" do allow( versioner.arg_processor ).to receive(:show).and_return(:build) expect( versioner.logger ).to receive(:show_current_build) versioner.show end it "does call logger's show_current_version and show_current_build methods" do allow( versioner.arg_processor ).to receive(:show).and_return(:all) expect( versioner.logger ).to receive(:show_current_version) expect( versioner.logger ).to receive(:show_current_build) versioner.show end end end end end