Sha256: 775ebf195c7bc5552b8f9b620e2100de47e50be0c2190178a288f2c588b3496f

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Simplabs::Excellent::Checks::CaseMissingElseCheck do

  before do
    @excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::CaseMissingElseCheck.new)
  end

  describe '#evaluate' do

    it 'should accept case statements that do have an else clause' do
      content = <<-END
        case foo
          when "bar": "ok"
          else "good"
          end
      END
      @excellent.check_content(content)
      warnings = @excellent.warnings

      warnings.should be_empty
    end

    it 'should reject case statements that do not have an else clause' do
      content = <<-END
        case foo
          when "bar": "ok"
          when "bar": "bad"
          end
      END
      @excellent.check_content(content)
      warnings = @excellent.warnings

      warnings.should_not be_empty
      warnings[0].info.should        == {}
      warnings[0].line_number.should == 2
      warnings[0].message.should     == 'Case statement is missing else clause.'
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simplabs-excellent-1.2.1 spec/checks/case_missing_else_check_spec.rb