Sha256: 4d479ec5f72eb37b619f77b36f432756f302594a02e826aac5889190ffe832ea

Contents?: true

Size: 1.92 KB

Versions: 16

Compression:

Stored size: 1.92 KB

Contents

require File.dirname(__FILE__) << "/test_helper"
require 'date'

#weird problems with flexmock resulted in this
module Fiveruns
  module Dash
    class SvnSCM
      private
      def svn_info
        <<-EOF
        Path: .
        URL: http://me.svnrepository.com/svn/dash/trunk
        Repository Root: http://me.svnrepository.com/svn/dash/trunk
        Repository UUID: f206d12c-05cc-4c44-99a1-426015a0eef1
        Revision: 123
        Node Kind: directory
        Schedule: normal
        Last Changed Author: acf
        Last Changed Rev: 123
        Last Changed Date: 2008-07-27 18:44:52 +0100 (Sun, 27 Jul 2008)
        EOF
      end
    end
  end
end

class ScmTest < Test::Unit::TestCase

  include Fiveruns::Dash  
  
  context "All SCMs" do
    should "find .git in gems/fiveruns_dash on locate_upwards" do
      assert_match File.expand_path(File.join(File.dirname(__FILE__), '..')), 
                   SCM.send(:locate_upwards, File.dirname(__FILE__), ".git" )
    end

    should "return nil from locate_upwards when no .git" do
      assert_nil SCM.send(:locate_upwards, '/tmp', ".git" )
    end
  
    should "return nil from locate_upwards when root on posix" do
      assert_nil SCM.send(:locate_upwards, "/", ".git" )
    end
    
    should "select the longest path when two available" do
      assert_equal( "/Users/acf/foo/bar/baz" , SCM.send(:best_match, ["/Users/acf/foo/bar/baz", "/Users/acf/foo/bar/baz", "/Users/acf"]) )
    end
    
  end
  
  
  context "Subversion SCM" do
    setup do
      @scm = SvnSCM.new( File.dirname(__FILE__) )
    end
    
    should "extract revision properly from svn info" do
      assert_equal 123, @scm.revision
    end

    should "extract time properly from svn info" do
      assert_equal DateTime.parse("2008-07-27 18:44:52 +0100"), @scm.time
    end

    should "extract URL properly from svn info" do
      assert_equal "http://me.svnrepository.com/svn/dash/trunk", @scm.url
    end 
  end
  
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fiveruns-dash-ruby-0.7.0 test/scm_test.rb
fiveruns-dash-ruby-0.7.1 test/scm_test.rb
fiveruns-dash-ruby-0.7.2 test/scm_test.rb
fiveruns-dash-ruby-0.7.3 test/scm_test.rb
fiveruns-dash-ruby-0.7.4 test/scm_test.rb
fiveruns-dash-ruby-0.7.5 test/scm_test.rb
fiveruns-dash-ruby-0.7.6 test/scm_test.rb
fiveruns-dash-ruby-0.8.0 test/scm_test.rb
fiveruns-dash-ruby-0.8.1 test/scm_test.rb
fiveruns-dash-ruby-0.8.10 test/scm_test.rb
fiveruns-dash-ruby-0.8.3 test/scm_test.rb
fiveruns-dash-ruby-0.8.4 test/scm_test.rb
fiveruns-dash-ruby-0.8.5 test/scm_test.rb
fiveruns-dash-ruby-0.8.6 test/scm_test.rb
fiveruns-dash-ruby-0.8.8 test/scm_test.rb
fiveruns-dash-ruby-0.8.9 test/scm_test.rb