Sha256: a81c7262bfc710b522cc443dc8c91167123bb988490867ea992cd66d1f1e1d8c

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe DescribeProject do

  class DummyDescribeFormatter < Struct.new :format
    def present records
      records
    end
  end


  it 'presents properties to table view' do
    records = stub(:records)

    subject.call(DummyDescribeFormatter, records).should == records
  end

  it 'passes format to formatter class' do
    format = stub(:format)
    formatter = stub.tap { |f| f.should_receive(:new).with(format) }

    subject.formatter(formatter, format)
  end

  it 'collects metrics from project' do
    metrics = stub(:metrics)
    project = stub(:project, :metrics => metrics)
    subject.records(project).should == metrics
  end

  it 'constructs format for console formatter' do
    subject.format("DATE_FORMAT").should == {
        'Metric' => 'name',
        'Value' => 'last_value',
        'Changed at' => "last_updated_at.try :strftime, 'DATE_FORMAT'",
        'Changed by' => "last_updated_by"
    }
  end

  it 'finds project by its name' do
    name, result = stub(:name), stub(:result)
    Project.should_receive(:find_by).with(name: name) { result }

    subject.project(name).should == result
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
techcor-0.0.10 spec/lib/commands/describe_project_spec.rb
techcor-0.0.9 spec/lib/commands/describe_project_spec.rb