Sha256: 535192a8b667f91cd228ae79121aff38163991d49fdd1570d1728cc5bc643d30

Contents?: true

Size: 1.76 KB

Versions: 20

Compression:

Stored size: 1.76 KB

Contents

require "helper"

class TestSnapshotFormatter < Test::Unit::TestCase
  def described_class
    CC::Formatters::SnapshotFormatter::Base
  end

  def test_quality_alert_with_new_constants
    f = described_class.new({"new_constants" => [{"to" => {"rating" => "D"}}], "changed_constants" => []})
    refute_nil f.alert_constants_payload
  end

  def test_quality_alert_with_decreased_constants
    f = described_class.new({"new_constants" => [],
                             "changed_constants" => [{"to" => {"rating" => "D"}, "from" => {"rating" => "A"}}]
    })
    refute_nil f.alert_constants_payload
  end

  def test_quality_improvements_with_better_ratings
    f = described_class.new({"new_constants" => [],
                             "changed_constants" => [{"to" => {"rating" => "A"}, "from" => {"rating" => "D"}}]
    })
    refute_nil f.improved_constants_payload
  end

  def test_nothing_set_without_changes
    f = described_class.new({"new_constants" => [], "changed_constants" => []})
    assert_nil f.alert_constants_payload
    assert_nil f.improved_constants_payload
  end

  def test_snapshot_formatter_test_with_relaxed_constraints
    f = CC::Formatters::SnapshotFormatter::Sample.new({
       "new_constants" => [{"name" => "foo", "to" => {"rating" => "A"}}, {"name" => "bar", "to" => {"rating" => "A"}}],
       "changed_constants" => [
         {"from" => {"rating" => "B"}, "to" => {"rating" => "C"}},
         {"from" => {"rating" => "D"}, "to" => {"rating" => "D"}},
         {"from" => {"rating" => "D"}, "to" => {"rating" => "D"}},
         {"from" => {"rating" => "A"}, "to" => {"rating" => "B"}},
         {"from" => {"rating" => "C"}, "to" => {"rating" => "B"}}
       ]})

    refute_nil f.alert_constants_payload
    refute_nil f.improved_constants_payload
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
codeclimate-services-1.6.1 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.6.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.5.1 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.5.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.4.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.3.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.2.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.1.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.0.1 test/formatters/snapshot_formatter_test.rb
codeclimate-services-1.0.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.6.2 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.6.1 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.6.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.5.3 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.5.2 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.5.1 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.5.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.4.1 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.4.0 test/formatters/snapshot_formatter_test.rb
codeclimate-services-0.3.0 test/formatters/snapshot_formatter_test.rb