Guest User

Untitled

a guest
Feb 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Spec::Matchers.create(:be_successful) do
  2. matches do |rack|
  3. rack.status == 200
  4. end
  5.  
  6. message do |not_string, rack|
  7. "Expected #{describe_request(rack)}#{not_string} " \
  8. "to be successful, but it returned a #{rack.status}"
  9. end
  10. end
  11.  
  12. def be_successful
  13. simple_matcher("response to be successful") do |response|
  14. response.status == 200
  15. end
  16. end
  17.  
  18. or
  19.  
  20. def be_successful
  21. simple_matcher("response to be successful") do |response, matcher|
  22. matcher.failure_message = "expected successful response, got #{response.status}"
  23. matcher.negative_failure_message = "expected error response, got #{response.status}"
  24. response.status == 200
  25. end
  26. end
Add Comment
Please, Sign In to add comment