Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed May 28, 2019
2 parents 63c88b5 + 08f3000 commit a2d7dc4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion objects/maybe_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize(text_if_present, maybe, exclude_if = false)
end

def to_s
if @maybe.nil? || @maybe.empty? || @maybe <=> @exclude_if
if @maybe.nil? || @maybe.empty? || @maybe == @exclude_if
''
else
@text
Expand Down
35 changes: 35 additions & 0 deletions test/test_github_tickets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,41 @@ class << github
assert(github.body.start_with?('The puzzle `55-ab536de` from #123 has'))
end

def test_output_estimates_when_it_is_not_zero
sources = Object.new
def sources.config
YAML.safe_load("\n\n")
end
require_relative 'fake_github'
github = FakeGithub.new
def github.create_issue(_, title, body)
@title = title
@body = body
{ 'number' => 555 }
end
class << github
attr_accessor :body, :title
end
tickets = GithubTickets.new('yegor256/0pdd', github, sources)
tickets.submit(
Nokogiri::XML(
'<puzzle>
<id>55-ab536de</id>
<file>/a/bz.txt</file>
<time>01-05-2017</time>
<author>yegor</author>
<body>как дела? hey, how are you, please see this title!</body>
<ticket>123</ticket>
<estimate>10</estimate>
<role>DEV</role>
<lines>1-3</lines>
</puzzle>'
).xpath('/puzzle')
)
assert(github.body.start_with?('The puzzle `55-ab536de` from #123 has'))
assert(github.body.include?('Estimate:'))
end

def test_skips_estimate_if_0
sources = Object.new
def sources.config
Expand Down
4 changes: 4 additions & 0 deletions test/test_maybe_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ def test_excluded_input_then_blank
def test_present_input_then_output
assert_equal('output', MaybeText.new('output', 'input').to_s)
end

def test_show_output_when_exclude_if_is_present
assert_equal('output', MaybeText.new('output', 'input', 'output').to_s)
end
end

0 comments on commit a2d7dc4

Please sign in to comment.