| 
									
										
										
										
											2020-05-17 12:52:39 -05:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require "rubocops/version" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-18 15:11:11 -08:00
										 |  |  | RSpec.describe RuboCop::Cop::FormulaAudit::Version do | 
					
						
							| 
									
										
										
										
											2020-05-17 12:52:39 -05:00
										 |  |  |   subject(:cop) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-14 18:55:31 -08:00
										 |  |  |   context "when auditing version" do | 
					
						
							|  |  |  |     it "reports an offense if `version` is an empty string" do | 
					
						
							| 
									
										
										
										
											2020-05-17 12:52:39 -05:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           url 'https://brew.sh/foo-1.0.tgz' | 
					
						
							|  |  |  |           version "" | 
					
						
							| 
									
										
										
										
											2023-04-07 17:16:48 +01:00
										 |  |  |           ^^^^^^^^^^ FormulaAudit/Version: version is set to an empty string | 
					
						
							| 
									
										
										
										
											2020-05-17 12:52:39 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |       RUBY | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-14 18:55:31 -08:00
										 |  |  |     it "reports an offense if `version` has a leading 'v'" do | 
					
						
							| 
									
										
										
										
											2020-05-17 12:52:39 -05:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           url 'https://brew.sh/foo-1.0.tgz' | 
					
						
							|  |  |  |           version "v1.0" | 
					
						
							| 
									
										
										
										
											2023-04-07 17:16:48 +01:00
										 |  |  |           ^^^^^^^^^^^^^^ FormulaAudit/Version: version v1.0 should not have a leading 'v' | 
					
						
							| 
									
										
										
										
											2020-05-17 12:52:39 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |       RUBY | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-14 18:55:31 -08:00
										 |  |  |     it "reports an offense if `version` ends with an underline and a number" do | 
					
						
							| 
									
										
										
										
											2020-05-17 12:52:39 -05:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           url 'https://brew.sh/foo-1.0.tgz' | 
					
						
							|  |  |  |           version "1_0" | 
					
						
							| 
									
										
										
										
											2023-04-07 17:16:48 +01:00
										 |  |  |           ^^^^^^^^^^^^^ FormulaAudit/Version: version 1_0 should not end with an underline and a number | 
					
						
							| 
									
										
										
										
											2020-05-17 12:52:39 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |       RUBY | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |