Sha256: 3349d4eba3379eadcb9bf6fb31c8e7ce26e50638b18c31a0ed4423a4c8d69273

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require File.join(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))), 'spec_helper')
require File.join(File.dirname(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))), 'lib', 'reek', 'cli', 'yaml_command')

include Reek
include Reek::Cli

describe YamlCommand do
  before :each do
    @view = mock('view', :null_object => true)
    @examiner = mock('examiner')
  end

  context 'with no smells' do
    before :each do
      @examiner.should_receive(:all_smells).and_return([])
      @cmd = YamlCommand.new([@examiner])
    end

    it 'displays nothing on the view' do
      @view.should_not_receive(:output)
      @cmd.execute(@view)
    end

    it 'tells the view it succeeded' do
      @view.should_receive(:report_success)
      @cmd.execute(@view)
    end
  end

  context 'with smells' do
    before :each do
      @smell = SmellWarning.new('UncommunicativeName', "self", 27, "self", true)
      @examiner.should_receive(:all_smells).and_return([@smell])
      @cmd = YamlCommand.new([@examiner])
    end

    it 'displays the correct text on the view' do
      @view.should_receive(:output).with(/UncommunicativeName/)
      @cmd.execute(@view)
    end

    it 'tells the view it found smells' do
      @view.should_receive(:report_smells)
      @cmd.execute(@view)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-1.2.7.1 spec/reek/cli/yaml_command_spec.rb
reek-1.2.7 spec/reek/cli/yaml_command_spec.rb