Sha256: a85425e45356f2933005d954a6b6b4aadb6a8de4762ec3abc61b2d731253c7ca

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require 'helper'

describe Mercurial::Shell do
  
  before do
    @repository = Mercurial::Repository.open(Fixtures.test_repo)
    @shell = @repository.shell
  end
  
  it "should compile commands" do    
    command_mock = mock('command', :execute => true)
    Mercurial::Command.expects(:new).with("cd #{ @repository.path } && /usr/local/bin/hg log", :repository => @repository, :cache => true).returns(command_mock).once
    @shell.hg('log')
  end
  
  it "should sanitize command arguments" do
    command_mock = mock('command', :execute => true)
    Mercurial::Command.expects(:new).with(%Q[ls 'file with nasty '\\''quote'], :repository => nil, :cache => true).returns(command_mock).once
    @shell.run(["ls ?", "file with nasty 'quote"])
  end
  
  it "should work with string and array commands" do
    @shell.hg('tip')
    @shell.hg(['tip ?', '-g'])
  end
  
  it "should execute commands without cache" do
    command_mock = mock('command', :execute => true)
    Mercurial::Command.expects(:new).with('ls -l /', :repository => nil, :cache => false).returns(command_mock).once
    Mercurial::Shell.run('ls -l /', :cache => false)
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mercurial-ruby-0.5.0 test/test_shell.rb
mercurial-ruby-0.4.0 test/test_shell.rb
mercurial-ruby-0.3.0 test/test_shell.rb