Raise ArgumentError for argument errors
This commit is contained in:
		
							parent
							
								
									20452f3edc
								
							
						
					
					
						commit
						acc1c35f35
					
				@ -78,8 +78,8 @@ class SoftwareSpec
 | 
			
		||||
  def option name, description=nil
 | 
			
		||||
    name = 'c++11' if name == :cxx11
 | 
			
		||||
    name = name.to_s if Symbol === name
 | 
			
		||||
    raise "Option name is required." if name.empty?
 | 
			
		||||
    raise "Options should not start with dashes." if name[0, 1] == "-"
 | 
			
		||||
    raise ArgumentError, "option name is required" if name.empty?
 | 
			
		||||
    raise ArgumentError, "options should not start with dashes" if name.start_with?("-")
 | 
			
		||||
    build.add(name, description)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -48,11 +48,11 @@ class SoftwareSpecTests < Homebrew::TestCase
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_option_raises_when_begins_with_dashes
 | 
			
		||||
    assert_raises(RuntimeError) { @spec.option('--foo') }
 | 
			
		||||
    assert_raises(ArgumentError) { @spec.option("--foo") }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_option_raises_when_name_empty
 | 
			
		||||
    assert_raises(RuntimeError) { @spec.option('') }
 | 
			
		||||
    assert_raises(ArgumentError) { @spec.option("") }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_option_accepts_symbols
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user