Guest User

Untitled

a guest
Apr 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. # Drop this into /spec/support/matchers
  2. # Usage: result.should be_url
  3. # Passes if result is a valid url, returns error "expected result to be url" if not.
  4.  
  5. # Matcher to see if a string is a URL or not.
  6. RSpec::Matchers.define :be_url do |expected|
  7. # The match method, returns true if valie, false if not.
  8. match do |actual|
  9. # Use the URI library to parse the string, returning false if this fails.
  10. URI.parse(actual) rescue false
  11. end
  12. end
Add Comment
Please, Sign In to add comment