Sha256: 7ff6938cd56e2d6d2531fd5854a62a0ef02bf2bbd7191f02c77d4a7c6955087d

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require "helper"
require "cc/presenters/github_pull_requests_presenter"

class TestGitHubPullRequestsPresenter < CC::Service::TestCase
  def test_message_singular
    assert_equal(
      "Code Climate found 1 new issue and 1 fixed issue.",
      build_presenter("fixed" => 1, "new" => 1).success_message
    )
  end

  def test_message_plural
    assert_equal(
      "Code Climate found 2 new issues and 1 fixed issue.",
      build_presenter("fixed" => 1, "new" => 2).success_message
    )
  end

  def test_message_only_fixed
    assert_equal(
      "Code Climate found 1 fixed issue.",
      build_presenter("fixed" => 1, "new" => 0).success_message
    )
  end

  def test_message_only_new
    assert_equal(
      "Code Climate found 3 new issues.",
      build_presenter("fixed" => 0, "new" => 3).success_message
    )
  end

  def test_message_no_new_or_fixed
    assert_equal(
      "Code Climate didn't find any new or fixed issues.",
      build_presenter("fixed" => 0, "new" => 0).success_message
    )
  end

private

  def build_payload(issue_counts)
    { "issue_comparison_counts" => issue_counts }
  end

  def build_presenter(issue_counts)
    CC::Service::GitHubPullRequestsPresenter.new(build_payload(issue_counts))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codeclimate-services-0.4.1 test/presenters/github_pull_requests_presenter_test.rb
codeclimate-services-0.4.0 test/presenters/github_pull_requests_presenter_test.rb
codeclimate-services-0.3.0 test/presenters/github_pull_requests_presenter_test.rb