Sha256: 0ac97f8721d8bd4835d26fe71d5cb0a3204c8a4289f71076f6e63dca1bda2a8e

Contents?: true

Size: 1.99 KB

Versions: 18

Compression:

Stored size: 1.99 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

module Gritano
  module Console
    describe Base do
      def create_base(home)
        stdin = double()
        stdin.stub(:read).and_return("Your SSHKEY here...")
        Base.new(stdin, home)
      end
      
      it "should define commands" do
        Base.should_receive(:define_method).with("command_name")
        Base.add_command "command:name", "parameters" do end
      end
      
      it "should execute commands" do
        Base.add_command "command:name", "parameters" do end
        base = create_base('.')
        base.should_receive('command_name')
        base.execute(['command:name'])
      end
      
      it "should show a help message" do
        Base.add_command "command:name", "parameters" do end
        Base.help.should == File.open("spec/data/help_command_name.txt").readlines.join.
            gsub('{{VERSION}}', File.open("VERSION").readlines.join)
      end
      
      it "should check if gritano is not installed" do
        FileUtils.rm_rf(File.join("tmp", ".gritano"))
        base = create_base('tmp')
        lambda { base.check_gritano }.should raise_error SystemExit
      end
      
      it "should check if gritano is installed" do
        base = create_base('.')
        lambda { base.check_gritano }.should_not raise_error SystemExit
      end
      
      it "should check if git is not installed" do
        base = create_base('.')
        base.stub(:unknown_command).and_return(true)
        lambda { base.check_git }.should raise_error SystemExit
      end
      
      it "should check if git is installed" do
        base = create_base('.')
        base.stub(:unknown_command).and_return(false)
        lambda { base.check_git }.should_not raise_error SystemExit
      end
      
      it "should check if a command exists" do
        base = create_base('.')
        base.unknown_command('ls').should be_false
        base.unknown_command('qwertyuioplkjhgfdsa').should be_true
      end
      
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
gritano-1.0.0 spec/console_base_spec.rb
gritano-0.11.2 spec/console_base_spec.rb
gritano-0.11.1 spec/console_base_spec.rb
gritano-0.11.0 spec/console_base_spec.rb
gritano-0.10.3 spec/console_base_spec.rb
gritano-0.10.2 spec/console_base_spec.rb
gritano-0.10.1 spec/console_base_spec.rb
gritano-0.10.0 spec/console_base_spec.rb
gritano-0.9.4 spec/console_base_spec.rb
gritano-0.9.3 spec/console_base_spec.rb
gritano-0.9.2 spec/console_base_spec.rb
gritano-0.9.1 spec/console_base_spec.rb
gritano-0.9.0 spec/console_base_spec.rb
gritano-0.8.1 spec/console_base_spec.rb
gritano-0.8.0 spec/console_base_spec.rb
gritano-0.7.2 spec/console_base_spec.rb
gritano-0.7.1 spec/console_base_spec.rb
gritano-0.7.0 spec/console_base_spec.rb