Sha256: e9c8bc9b3bb4824c9047f65c68014eb37ce03fee9caf493fd43be71ce0cb7f9f

Contents?: true

Size: 948 Bytes

Versions: 10

Compression:

Stored size: 948 Bytes

Contents

require 'spec_helper'

describe AddMetric do
  it 'adds metric to the project' do
    result = stub(:result)
    metric = stub(:metric)
    project = stub(:project).tap { |p| p.should_receive(:add_metric).with(metric) { result } }
    subject.call(project, metric)
  end

  it 'find project' do
    result = stub(:result)
    project_name = stub(:project_name)
    Project.should_receive(:find_by).with(name: project_name) { result }
    subject.project(project_name).should == result
  end

  it 'creates appropriate metric class' do
    subject.metric_class(:string).should == StringMetric
    subject.metric_class(:number).should == NumberMetric
    subject.metric_class(nil).should == Metric
  end

  it 'creates metric' do
    result = stub(:result)
    name = stub(:name)
    metric_class = stub(:metric_class).tap { |mc| mc.should_receive(:new).with(name: name) { result } }

    subject.metric(metric_class, name).should == result
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
techcor-0.0.10 spec/lib/commands/add_metric_spec.rb
techcor-0.0.9 spec/lib/commands/add_metric_spec.rb
techcor-0.0.8 spec/lib/commands/add_metric_spec.rb
techcor-0.0.7 spec/lib/commands/add_metric_spec.rb
techcor-0.0.6 spec/lib/commands/add_metric_spec.rb
techcor-0.0.5 spec/lib/commands/add_metric_spec.rb
techcor-0.0.4 spec/lib/commands/add_metric_spec.rb
techcor-0.0.3 spec/lib/commands/add_metric_spec.rb
techcor-0.0.2 spec/lib/commands/add_metric_spec.rb
techcor-0.0.1 spec/lib/commands/add_metric_spec.rb