<commit_before>require File.expand_path('../../../spec_helper', __FILE__)

module Pod
  describe Command::Trunk::AddOwner do
    describe 'CLAide' do
      it 'registers it self' do
        Command.parse(%w(        trunk add-owner        )).should.be.instance_of Command::Trunk::AddOwner
      end
    end
  end
end<commit_msg>[Specs] Test input validation in `trunk add-owner`<commit_after>require File.expand_path('../../../spec_helper', __FILE__)

module Pod
  describe Command::Trunk::AddOwner do
    describe 'CLAide' do
      it 'registers it self' do
        Command.parse(%w( trunk add-owner )).should.be.instance_of Command::Trunk::AddOwner
      end
    end

    describe 'validation' do
      it "should error if we don't have a token" do
        Netrc.any_instance.stubs(:[]).returns(nil)
        command = Command.parse(%w( trunk push ))
        exception = lambda { command.validate! }.should.raise CLAide::Help
        exception.message.should.include 'register a session'
      end

      it 'should error if pod name is not supplied' do
        command = Command.parse(%w( trunk add-owner ))
        command.stubs(:token).returns('token')
        exception = lambda { command.validate! }.should.raise CLAide::Help
        exception.message.should.include 'pod name'
      end

      it 'should error if new owners email is not supplied' do
        command = Command.parse(%w( trunk add-owner QueryKit ))
        command.stubs(:token).returns('token')
        exception = lambda { command.validate! }.should.raise CLAide::Help
        exception.message.should.include 'email'
      end

      it 'should should validate with valid pod and email' do
        command = Command.parse(%w( trunk add-owner QueryKit <EMAIL> ))
        command.stubs(:token).returns('token')
        lambda { command.validate! }.should.not.raise CLAide::Help
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11554845580404687, 'fraction_numerical': 0.0, 'mean_word_length': 2.7655310621242486, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7302265', 'n_tokens_mistral': 538, 'n_tokens_neox': 525, 'n_words': 155}