зеркало из https://github.com/github/github-ds.git
Merge pull request #19 from github/no-block
Make initialize without block return `true` for `ok?`
This commit is contained in:
Коммит
e42141e1ad
|
@ -15,7 +15,7 @@ module GitHub
|
|||
#
|
||||
def initialize
|
||||
begin
|
||||
@value = yield
|
||||
@value = yield if block_given?
|
||||
@error = nil
|
||||
rescue => e
|
||||
@error = e
|
||||
|
|
|
@ -83,4 +83,8 @@ class GitHub::ResultTest < Minitest::Test
|
|||
|
||||
assert_equal e, GitHub::Result.new { raise e }.error
|
||||
end
|
||||
|
||||
def test_initialize_without_block
|
||||
assert_predicate GitHub::Result.new, :ok?
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче