Sha256: 80b64bce94f643ccb1834cfb8b5927202aa34fff71b842132ea1428b51f7f7e4

Contents?: true

Size: 1.03 KB

Versions: 12

Compression:

Stored size: 1.03 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
      code = <<-END
        case foo
          when "bar": "ok"
          else "good"
          end
      END
      @excellent.check_code(code)
      warnings = @excellent.warnings

      warnings.should be_empty
    end

    it 'should reject case statements that do not have an else clause' do
      code = <<-END
        case foo
          when "bar": "ok"
          when "bar": "bad"
          end
      END
      @excellent.check_code(code)
      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

12 entries across 12 versions & 2 rubygems

Version Path
simplabs-excellent-1.2.2 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.3.0 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.3.1 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.4.0 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.4.1 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.4.2 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.5.0 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.5.1 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.5.2 spec/checks/case_missing_else_check_spec.rb
simplabs-excellent-1.5.3 spec/checks/case_missing_else_check_spec.rb
excellent-1.6.0 spec/checks/case_missing_else_check_spec.rb
excellent-1.5.4 spec/checks/case_missing_else_check_spec.rb