Sha256: 08a89097cc611e80fb03024b89aa48513a7cf53f6a371b41168b81165a1a8d3d

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

require File.dirname(__FILE__) + '/helper'

describe Mercurial::Shell do
  
  before do
    @repository = Mercurial::Repository.open(Fixtures.test_repo)
    @shell = @repository.shell
  end

  it "should accept piping" do
    assert_equal '1', @shell.hg('log', :pipe => "grep '9:0f41dd2ec166' -wc").strip
  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, :append_hg => 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'], {}).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 /', :cache => false).returns(command_mock).once
    Mercurial::Shell.run('ls -l /', :cache => false)
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mercurial-ruby-0.7.12 test/test_shell.rb
mercurial-ruby-0.7.11 test/test_shell.rb
mercurial-ruby-0.7.10 test/test_shell.rb
mercurial-ruby-0.7.9 test/test_shell.rb
mercurial-ruby-0.7.8 test/test_shell.rb
mercurial-ruby-0.7.7 test/test_shell.rb