require 'spec_helper' module DistribBuilder describe Main do let(:opts) { %w(--option value) } it "does return nil if type argument is missing" do #expect( described_class.run ).to be_nil end it "does return nil if type argument is missing" do allow( described_class ).to receive(:duplicate_argv).and_return(['build']) #expect( described_class.run ).to be_nil end it "does call an instance of Builder class" do allow( described_class ).to receive(:duplicate_argv).and_return(['build'] + opts) allow_any_instance_of( Builder::Main ).to receive(:run) expect( Builder::Main ).to receive(:new). with(opts). and_return(Builder::Main.new(opts)) described_class.run end it "does call an instance of Versioner class" do allow( described_class ).to receive(:duplicate_argv).and_return(['version'] + opts) allow_any_instance_of( Versioner::Main ).to receive(:run) expect( Versioner::Main ).to receive(:new). with(opts). and_return(Versioner::Main.new(opts)) described_class.run end end end