Sha256: 01dfbc09e402eac83dc889de8b00b351c5227d8270f9983bbfc7a8ac615241b0

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 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').as_null_object
    @examiner = mock('examiner')
  end

  context 'with no smells' do
    before :each do
      @examiner.should_receive(: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")
      @examiner.should_receive(: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

3 entries across 3 versions & 1 rubygems

Version Path
reek-1.3.1 spec/reek/cli/yaml_command_spec.rb
reek-1.3 spec/reek/cli/yaml_command_spec.rb
reek-1.2.13 spec/reek/cli/yaml_command_spec.rb