Sha256: 6a2c1065ab68366031e3980ad005d3d384b76e62beefe7d517091e1523117c74

Contents?: true

Size: 1.72 KB

Versions: 9

Compression:

Stored size: 1.72 KB

Contents

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

class TestSubmodule < Test::Unit::TestCase
  def setup
    @r = Repo.new(GRIT_REPO)
    @s = Submodule.allocate
  end
  
  # config
  
  def test_config
    data = fixture('gitmodules')
    blob = stub(:data => data, :id => 'abc')
    tree = stub(:'/' => blob)
    commit = stub(:tree => tree)
    repo = stub(:commit => commit)
    
    config = Submodule.config(repo)
    
    assert_equal "git://github.com/mojombo/glowstick", config['test/glowstick']['url']
    assert_equal "git://github.com/mojombo/god", config['god']['url']
  end
  
  def test_config_with_windows_lineendings
    data = fixture('gitmodules').gsub(/\n/, "\r\n")
    blob = stub(:data => data, :id => 'abc')
    tree = stub(:'/' => blob)
    commit = stub(:tree => tree)
    repo = stub(:commit => commit)
    
    config = Submodule.config(repo)
    
    assert_equal "git://github.com/mojombo/glowstick", config['test/glowstick']['url']
    assert_equal "git://github.com/mojombo/god", config['god']['url']
  end
  
  def test_no_config
    tree = stub(:'/' => nil)
    commit = stub(:tree => tree)
    repo = stub(:commit => commit)
    
    config = Submodule.config(repo)
    
    assert_equal({}, config)
  end
  
  def test_empty_config
    blob = stub(:data => '', :id => 'abc')
    tree = stub(:'/' => blob)
    commit = stub(:tree => tree)
    repo = stub(:commit => commit)
    
    config = Submodule.config(repo)
    
    assert_equal({}, config)
  end
  
  # inspect
  
  def test_inspect
    @t = Submodule.create(@r, :id => 'abc')
    assert_equal %Q{#<Grit::Submodule "abc">}, @t.inspect
  end
  
  def test_basename
    @submodule = Submodule.create(@r, :name => 'foo/bar')
    assert_equal "bar", @submodule.basename
  end
end

Version data entries

9 entries across 9 versions & 5 rubygems

Version Path
boof-grit-1.1.2 test/test_submodule.rb
davetron5000-grit-1.1.2 test/test_submodule.rb
davetron5000-grit-1.1.3 test/test_submodule.rb
joelmoss-grit-1.1.4 test/test_submodule.rb
joelmoss-grit-1.1.5 test/test_submodule.rb
joelmoss-grit-1.1.6 test/test_submodule.rb
square-circle-triangle-grit-1.1.3 test/test_submodule.rb
square-circle-triangle-grit-1.1.4 test/test_submodule.rb
grit-1.1.0 test/test_submodule.rb