mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Use issue expectation helpers in Lint::UselessConditionInWhen rule spec
				
					
				
			This commit is contained in:
		
							parent
							
								
									c8daaf4324
								
							
						
					
					
						commit
						c89d32fcf6
					
				
					 1 changed files with 5 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -5,25 +5,24 @@ module Ameba::Rule::Lint
 | 
			
		|||
 | 
			
		||||
  describe UselessConditionInWhen do
 | 
			
		||||
    it "passes if there is not useless condition" do
 | 
			
		||||
      s = Source.new %(
 | 
			
		||||
      expect_no_issues subject, <<-CRYSTAL
 | 
			
		||||
        case
 | 
			
		||||
        when utc?
 | 
			
		||||
          io << " UTC"
 | 
			
		||||
        when local?
 | 
			
		||||
          Format.new(" %:z").format(self, io) if utc?
 | 
			
		||||
        end
 | 
			
		||||
      )
 | 
			
		||||
      subject.catch(s).should be_valid
 | 
			
		||||
        CRYSTAL
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "fails if there is useless if condition" do
 | 
			
		||||
      s = Source.new %(
 | 
			
		||||
      expect_issue subject, <<-CRYSTAL
 | 
			
		||||
        case
 | 
			
		||||
        when utc?
 | 
			
		||||
          io << " UTC" if utc?
 | 
			
		||||
                        # ^^^^ error: Useless condition in when detected
 | 
			
		||||
        end
 | 
			
		||||
      )
 | 
			
		||||
      subject.catch(s).should_not be_valid
 | 
			
		||||
        CRYSTAL
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "reports rule, location and message" do
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue