Guest User

Untitled

a guest
Jun 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. ## test_helper.rb defines an anchor
  2.  
  3. # BEGIN custom_assertion
  4. class ActiveSupport::TestCase
  5. def assert_size(collection, size, message = nil)
  6. message ||= "expected #{collection.inspect} to have #{size} elements but instead had #{collection.size}"
  7. assert_block message do
  8. collection.size == size
  9. end
  10. end
  11. end
  12. # END custom_assertion
  13.  
  14.  
  15.  
  16. ## test_helper_custom_assertion.rb.inc references the anchor
  17.  
  18. testing/example/test/test_helper.rb#custom_assertion
  19.  
  20.  
  21.  
  22. ## rake render complains
  23.  
  24. code/output/testing/test_helper_custom_assertion.rb:7: syntax error, unexpected $end, expecting kEND
  25. end
  26. ^
  27. Validating syntax of code samples: 112 valid, 1 invalid
  28. Invalid files:
  29. code/output/testing/test_helper_custom_assertion.rb
  30. Rendering code samples
  31.  
  32.  
  33.  
  34. ## the outputted test_helper_custom_assertion.rb is missing the last line
  35.  
  36. class ActiveSupport::TestCase
  37. def assert_size(collection, size, message = nil)
  38. message ||= "expected #{collection.inspect} to have #{size} elements but instead had #{collection.size}"
  39. assert_block message do
  40. collection.size == size
  41. end
  42. end
Add Comment
Please, Sign In to add comment