mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Expand Symbol#to_proc specs to be clearer
This commit is contained in:
		
							parent
							
								
									c7b71af9e2
								
							
						
					
					
						commit
						4aebb49153
					
				
					 1 changed files with 32 additions and 10 deletions
				
			
		|  | @ -12,22 +12,44 @@ describe "Symbol#to_proc" do | |||
|     :to_s.to_proc.call(obj).should == "Received #to_s" | ||||
|   end | ||||
| 
 | ||||
|   expected_arity = ruby_version_is("2.8") {-2} || -1 | ||||
|   it "produces a proc with arity #{expected_arity}" do | ||||
|     pr = :to_s.to_proc | ||||
|     pr.arity.should == expected_arity | ||||
|   ruby_version_is ""..."2.8" do | ||||
|     it "returns a Proc with #lambda? false" do | ||||
|       pr = :to_s.to_proc | ||||
|       pr.lambda?.should == false | ||||
|     end | ||||
| 
 | ||||
|     it "produces a Proc with arity -1" do | ||||
|       pr = :to_s.to_proc | ||||
|       pr.arity.should == -1 | ||||
|     end | ||||
| 
 | ||||
|     it "produces a Proc that always returns [[:rest]] for #parameters" do | ||||
|       pr = :to_s.to_proc | ||||
|       pr.parameters.should == [[:rest]] | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   ruby_version_is "2.8" do | ||||
|     it "returns a Proc with #lambda? true" do | ||||
|       pr = :to_s.to_proc | ||||
|       pr.lambda?.should == true | ||||
|     end | ||||
| 
 | ||||
|     it "produces a Proc with arity -2" do | ||||
|       pr = :to_s.to_proc | ||||
|       pr.arity.should == -2 | ||||
|     end | ||||
| 
 | ||||
|     it "produces a Proc that always returns [[:req], [:rest]] for #parameters" do | ||||
|       pr = :to_s.to_proc | ||||
|       pr.parameters.should == [[:req], [:rest]] | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   it "raises an ArgumentError when calling #call on the Proc without receiver" do | ||||
|     -> { :object_id.to_proc.call }.should raise_error(ArgumentError, "no receiver given") | ||||
|   end | ||||
| 
 | ||||
|   expected_parameters = ruby_version_is("2.8") {[[:req], [:rest]]} || [[:rest]] | ||||
|   it "produces a proc that always returns #{expected_parameters} for #parameters" do | ||||
|     pr = :to_s.to_proc | ||||
|     pr.parameters.should == expected_parameters | ||||
|   end | ||||
| 
 | ||||
|   it "passes along the block passed to Proc#call" do | ||||
|     klass = Class.new do | ||||
|       def m | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benoit Daloze
						Benoit Daloze