Sha256: 053490be402eb492298dcc18067796334fd9e01a54a75ccaf3ba60b7c8c28561

Contents?: true

Size: 1.83 KB

Versions: 18

Compression:

Stored size: 1.83 KB

Contents

describe CC::Formatters::SnapshotFormatter do
  def described_class
    CC::Formatters::SnapshotFormatter::Base
  end

  it "quality alert with new constants" do
    f = described_class.new("new_constants" => [{ "to" => { "rating" => "D" } }], "changed_constants" => [])
    expect(f.alert_constants_payload).not_to be_nil
  end

  it "quality alert with decreased constants" do
    f = described_class.new("new_constants" => [],
                            "changed_constants" => [{ "to" => { "rating" => "D" }, "from" => { "rating" => "A" } }])
    expect(f.alert_constants_payload).not_to be_nil
  end

  it "quality improvements with better ratings" do
    f = described_class.new("new_constants" => [],
                            "changed_constants" => [{ "to" => { "rating" => "A" }, "from" => { "rating" => "D" } }])
    expect(f.improved_constants_payload).not_to be_nil
  end

  it "nothing set without changes" do
    f = described_class.new("new_constants" => [], "changed_constants" => [])
    expect(f.alert_constants_payload).to be_nil
    expect(f.improved_constants_payload).to be_nil
  end

  it "snapshot formatter test with relaxed constraints" do
    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" } },
      ],
    )

    expect(f.alert_constants_payload).not_to be_nil
    expect(f.improved_constants_payload).not_to be_nil
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
codeclimate-services-1.11.4 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.11.3 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.11.2 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.11.1 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.11.0 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.10.1 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.10.0 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.8 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.7 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.6 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.5 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.4 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.3 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.2 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.1 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.9.0 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.8.0 spec/cc/formatters/snapshot_formatter_spec.rb
codeclimate-services-1.7.0 spec/cc/formatters/snapshot_formatter_spec.rb