Sha256: d79e77a72873ac230dd36532695e0ac7bba2dd6e3d388107d8771e61346c6241

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe ListProjects do
  it 'passes format to console formatter' do
    format = '42'
    ConsoleFormatter.should_receive(:new).with(eval(format))

    ListProjects.new(format).formatter
  end

  it 'gets list of projects from catalog according to criteria' do
    result = stub(:result)

    criteria = stub(:criteria)
    catalog = stub(:catalog).tap { |c| c.should_receive(:projects).with(criteria) { result } }

    subject.projects(catalog, criteria).should == result
  end

  it 'presents projects to table view' do
    result = stub(:result)

    projects = stub(:projects)
    formatter = stub(:formatter).tap { |f| f.should_receive(:present).with(projects) { result } }

    subject.call(formatter, projects).should == result
  end

  it 'uses default format if no format string was specified' do
    result = stub(:result)

    command = ListProjects.new(nil)
    command.should_receive(:default_format) { result }

    command.formatter
  end

  it 'builds default format as list of all metrics for all projects' do
    subject.stub(:projects => [
        stub(:metrics => [stub(:name => 'metric1'), stub(:name => 'metric2')]),
        stub(:metrics => [stub(:name => 'metric3')])])
    subject.default_format.should == {'Name' => 'name',
                                      'metric1' => "property('metric1').try(:value)",
                                      'metric2' => "property('metric2').try(:value)",
                                      'metric3' => "property('metric3').try(:value)"}
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
techcor-0.0.4 spec/lib/commands/list_projects_spec.rb
techcor-0.0.3 spec/lib/commands/list_projects_spec.rb
techcor-0.0.2 spec/lib/commands/list_projects_spec.rb
techcor-0.0.1 spec/lib/commands/list_projects_spec.rb