Module: FailFast::CheckUrl
- Defined in:
- lib/fail_fast/extensions/check_url.rb
Instance Method Summary collapse
-
#has_url_for(key, *params) ⇒ Object
Usage test if the url is valid : has_url_for ‘test/server_url’ test if the url is reachable : has_url_for ‘test/server_url’, :reachable => true test if the url is reachable, possibly after adding a trailing slash.
Instance Method Details
#has_url_for(key, *params) ⇒ Object
Usage
test if the url is valid :
has_url_for 'test/server_url'
test if the url is reachable :
has_url_for 'test/server_url', :reachable => true
test if the url is reachable, possibly after adding a trailing slash.
(ex: http://example.com + http://example.com/)
has_url_for 'test/server_url', :reachable => true, :may_add_trailing_slash => true
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fail_fast/extensions/check_url.rb', line 13 def has_url_for(key, *params) p = (key, params) key, = p.key, p. return unless has_value_for key, :message => [:message] value = value_for_deep_key(key) if UrlValidator.invalid_url?(value) add_error ErrorDetails.new(key, :not_a_url, value, [:message]) return end if true==.delete(:reachable) && UrlValidator.unreachable_url?(value, ) add_error ErrorDetails.new(key, :url_not_reachable, value, [:message]) end end |