mirror of
				https://gitea.invidious.io/iv-org/shard-spectator.git
				synced 2024-08-15 00:53:35 +00:00 
			
		
		
		
	Fix reporting for should syntax
This commit is contained in:
		
							parent
							
								
									97923d6bcd
								
							
						
					
					
						commit
						3ec267abbb
					
				
					 1 changed files with 16 additions and 16 deletions
				
			
		|  | @ -17,21 +17,19 @@ class Object | ||||||
|   # require "spectator/should" |   # require "spectator/should" | ||||||
|   # ``` |   # ``` | ||||||
|   def should(matcher) |   def should(matcher) | ||||||
|     # First argument of the `Expectation` initializer is the expression label. |     actual = ::Spectator::Value.new(self) | ||||||
|     # However, since this isn't a macro and we can't "look behind" this method call |     match_data = matcher.match(actual) | ||||||
|     # to see what it was invoked on, the argument is an empty string. |     expectation = ::Spectator::Expectation.new(match_data) | ||||||
|     # Additionally, the source file and line can't be obtained. |     ::Spectator::Harness.current.report(expectation) | ||||||
|     actual = ::Spectator::TestValue.new(self) |  | ||||||
|     source = ::Spectator::Source.new(__FILE__, __LINE__) |  | ||||||
|     ::Spectator::Expectations::ExpectationPartial.new(actual, source).to(matcher) |  | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   # Works the same as `#should` except the condition is inverted. |   # Works the same as `#should` except the condition is inverted. | ||||||
|   # When `#should` succeeds, this method will fail, and vice-versa. |   # When `#should` succeeds, this method will fail, and vice-versa. | ||||||
|   def should_not(matcher) |   def should_not(matcher) | ||||||
|     actual = ::Spectator::TestValue.new(self) |     actual = ::Spectator::Value.new(self) | ||||||
|     source = ::Spectator::Source.new(__FILE__, __LINE__) |     match_data = matcher.negated_match(actual) | ||||||
|     ::Spectator::Expectations::ExpectationPartial.new(actual, source).to_not(matcher) |     expectation = ::Spectator::Expectation.new(match_data) | ||||||
|  |     ::Spectator::Harness.current.report(expectation) | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   # Works the same as `#should` except that the condition check is postphoned. |   # Works the same as `#should` except that the condition check is postphoned. | ||||||
|  | @ -51,17 +49,19 @@ struct Proc(*T, R) | ||||||
|   # Extension method to create an expectation for a block of code (proc). |   # Extension method to create an expectation for a block of code (proc). | ||||||
|   # Depending on the matcher, the proc may be executed multiple times. |   # Depending on the matcher, the proc may be executed multiple times. | ||||||
|   def should(matcher) |   def should(matcher) | ||||||
|     actual = ::Spectator::TestBlock.new(self) |     actual = ::Spectator::Block.new(self) | ||||||
|     source = ::Spectator::Source.new(__FILE__, __LINE__) |     match_data = matcher.match(actual) | ||||||
|     ::Spectator::Expectations::ExpectationPartial.new(actual, source).to(matcher) |     expectation = ::Spectator::Expectation.new(match_data) | ||||||
|  |     ::Spectator::Harness.current.report(expectation) | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   # Works the same as `#should` except the condition is inverted. |   # Works the same as `#should` except the condition is inverted. | ||||||
|   # When `#should` succeeds, this method will fail, and vice-versa. |   # When `#should` succeeds, this method will fail, and vice-versa. | ||||||
|   def should_not(matcher) |   def should_not(matcher) | ||||||
|     actual = ::Spectator::TestBlock.new(self) |     actual = ::Spectator::Block.new(self) | ||||||
|     source = ::Spectator::Source.new(__FILE__, __LINE__) |     match_data = matcher.negated_match(actual) | ||||||
|     ::Spectator::Expectations::BlockExpectationPartial.new(actual, source).to_not(matcher) |     expectation = ::Spectator::Expectation.new(match_data) | ||||||
|  |     ::Spectator::Harness.current.report(expectation) | ||||||
|   end |   end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue