class StandaloneTest

Public Instance Methods

setup() click to toggle source
# File test/standalone_test.rb, line 9
def setup
  rm "hub" if File.exist? 'hub'
  rm_rf "/tmp/_hub_private" if File.exist? '/tmp/_hub_private'
  mkdir "/tmp/_hub_private"
  chmod 0400, "/tmp/_hub_private"
end
teardown() click to toggle source
# File test/standalone_test.rb, line 16
def teardown
  rm "hub" if File.exist? 'hub'
  rm_rf "/tmp/_hub_private" if File.exist? "/tmp/_hub_private"
end
test_standalone() click to toggle source
# File test/standalone_test.rb, line 21
def test_standalone
  io = StringIO.new
  Hub::Standalone.build io
  standalone = io.string

  assert_includes "This file is generated code", standalone
  assert_includes "Runner", standalone
  assert_includes "Args", standalone
  assert_includes "Commands", standalone
  assert_includes ".execute(*ARGV)", standalone
  assert_not_includes "module Standalone", standalone

  standalone =~ /__END__\s*(.+)/m
  assert_equal File.read('man/hub.1'), $1
end
test_standalone_save() click to toggle source
# File test/standalone_test.rb, line 37
  def test_standalone_save
    Hub::Standalone.save("hub")
    output = %xRUBYOPT= RUBYLIB= ./hub version 2>&1`
    assert_equal "git version 1.7.0.4
hub version #{Hub::VERSION}
", output
  end
test_standalone_save_doesnt_exist() click to toggle source
# File test/standalone_test.rb, line 52
def test_standalone_save_doesnt_exist
  assert_raises Errno::ENOENT do
    Hub::Standalone.save("hub", "/tmp/something/not/real")
  end
end
test_standalone_save_permission_denied() click to toggle source
# File test/standalone_test.rb, line 46
def test_standalone_save_permission_denied
  assert_raises Errno::EACCES do
    Hub::Standalone.save("hub", "/tmp/_hub_private")
  end
end