Sha256: b3418dd0d48fd03d6cea9867e44b083c8569fd680293169d20580b570cb888c9

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require "spec_helper"

describe FlayGrapher do
  before :each do
    @flay_grapher = MetricFu::FlayGrapher.new
    MetricFu.configuration
  end

  it "should respond to flay_score and labels" do
    @flay_grapher.should respond_to(:flay_score)
    @flay_grapher.should respond_to(:labels)
  end

  describe "responding to #initialize" do
    it "should initialise flay_score and labels" do
      @flay_grapher.flay_score.should == []
      @flay_grapher.labels.should == {}
    end
  end

  describe "responding to #get_metrics" do
    context "when metrics were not generated" do
      before(:each) do
        @metrics = FIXTURE.load_metric("metric_missing.yml")
        @date = "1/2"
      end

      it "should not push to flay_score" do
        @flay_grapher.flay_score.should_not_receive(:push)
        @flay_grapher.get_metrics(@metrics, @date)
      end

      it "should not update labels with the date" do
        @flay_grapher.labels.should_not_receive(:update)
        @flay_grapher.get_metrics(@metrics, @date)
      end
    end

    context "when metrics have been generated" do
      before(:each) do
        @metrics = FIXTURE.load_metric("20090630.yml")
        @date = "1/2"
      end

      it "should push to flay_score" do
        @flay_grapher.flay_score.should_receive(:push).with(476)
        @flay_grapher.get_metrics(@metrics, @date)
      end

      it "should update labels with the date" do
        @flay_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
        @flay_grapher.get_metrics(@metrics, @date)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
metric_fu-4.6.0 spec/metric_fu/metrics/flay/flay_grapher_spec.rb
metric_fu-4.5.2 spec/metric_fu/metrics/flay/flay_grapher_spec.rb
metric_fu-4.5.1 spec/metric_fu/metrics/flay/flay_grapher_spec.rb