提交 af277fd9 编写于 作者: M Mislav Marohnić

runner shouldn't think that all ruby methods are git commands

closes #64
上级 c2e575fa
......@@ -13,6 +13,7 @@ module Hub
@executable = ENV["GIT"] || "git"
@after = nil
@skip = false
@original_args = args.first
end
# With no arguments, returns the `after` callback.
......@@ -74,5 +75,10 @@ module Hub
def flags
self - words
end
# Tests if arguments were modified since instantiation
def changed?
self != @original_args
end
end
end
......@@ -15,7 +15,7 @@ module Hub
# git commands can have dashes
cmd = @args[0].sub(/(\w)-/, '\1_')
Commands.send(cmd, @args) if Commands.respond_to?(cmd)
Commands.send(cmd, @args) if Commands.method_defined?(cmd)
end
# Shortcut
......
......@@ -70,6 +70,12 @@ class Test::Unit::TestCase
assert_equal expected, Hub(input).command, "$ git #{input}"
end
# Asserts that the command will be forwarded to git without changes
def assert_forwarded(input)
cmd = Hub(input)
assert !cmd.args.changed?, "arguments were not supposed to change: #{cmd.args.inspect}"
end
# Asserts that `hub` will show a specific alias command for a
# specific shell.
#
......
......@@ -711,6 +711,11 @@ config
assert_command 'remotes', 'git remotes'
end
def test_not_choking_on_ruby_methods
assert_forwarded 'id'
assert_forwarded 'name'
end
def test_multiple_remote_urls
stub_repo_url("git://example.com/other.git\ngit://github.com/my/repo.git")
assert_command "browse", "open http://github.com/my/repo"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册