Class: CabezaDeTermo::JsonSpec::IsUrlExpectation
- Inherits:
-
Expectation
- Object
- AbstractExpectation
- Expectation
- CabezaDeTermo::JsonSpec::IsUrlExpectation
- Defined in:
- lib/cabeza-de-termo/json-spec/expectations/is-url-expectation.rb
Instance Method Summary collapse
Methods inherited from Expectation
#accept_walker, #expectation_method, #explain, #explain_parameters, #failed_message_block, #failed_message_on, #json_spec, #set_expectation_method, #set_json_spec
Methods inherited from AbstractExpectation
#accept_walker, #explain, #failed_message_on, #set_expectation_method, #set_json_spec
Instance Method Details
#is_satisfied_by?(value_holder) ⇒ Boolean
7 8 9 10 11 12 13 |
# File 'lib/cabeza-de-termo/json-spec/expectations/is-url-expectation.rb', line 7 def is_satisfied_by?(value_holder) begin is_valid_url?(value_holder.value) rescue URI::Error false end end |
#is_valid_url?(value) ⇒ Boolean
15 16 17 18 |
# File 'lib/cabeza-de-termo/json-spec/expectations/is-url-expectation.rb', line 15 def is_valid_url?(value) uri = URI.parse(value) !uri.scheme.nil? && !uri.host.nil? end |