Sha256: 9d305f79035efbd096f8f4ce6f6ff9d270993030f280eabe27dac351ca0f7cb3

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require 'test/unit'
require 'rubygems'
require 'mocha'

RAILS_ROOT = File.expand_path(File.dirname(__FILE__))
require 'vizres'

class SCMTest < Test::Unit::TestCase
  
  def test_create_tmp_if_missing_with_git
    ignore_path = RAILS_ROOT + '/.gitignore'
    already_exists = File.exists?(ignore_path)
    content = already_exists ? File.read(ignore_path) : nil
    
    SCM.expects(:git?).returns(true)
    tmp_directory = File.join(RAILS_ROOT, 'public', 'tmp')
    
    begin
      SCM.create_tmp_if_missing tmp_directory
      new_content = File.read(ignore_path)
      assert new_content.match('public/tmp/*')
    ensure
      FileUtils.rm_f RAILS_ROOT + '/.gitignore' unless already_exists
      FileUtils.rm_rf RAILS_ROOT + '/public'
      system "echo '#{content.strip}' > #{ignore_path}" if already_exists
    end
  end
  
  def test_create_tmp_if_missing_with_svn
    SCM.expects(:git?).returns(false)
    SCM.expects(:svn?).returns(true)
    SCM.expects(:system).with("svn propset svn:ignore tmp #{RAILS_ROOT}/public")
    
    begin
      SCM.create_tmp_if_missing File.join(RAILS_ROOT, 'public', 'tmp')
    ensure
      FileUtils.rm_rf RAILS_ROOT + '/public'
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiant-0.7.2 vendor/plugins/vizres/test/vizres/scm_test.rb
radiant-0.7.0 vendor/plugins/vizres/test/vizres/scm_test.rb
radiant-0.7.1 vendor/plugins/vizres/test/vizres/scm_test.rb