Module: Committee::Test::Methods
- Defined in:
- lib/committee/test/methods.rb
Instance Method Summary collapse
- #assert_schema_conform ⇒ Object
- #assert_schema_content_type ⇒ Object
-
#schema_contents ⇒ Object
can be overridden alternatively to #schema_path in case the schema is easier to access as a string blob.
- #schema_path ⇒ Object
- #schema_url_prefix ⇒ Object
- #warn_string_deprecated ⇒ Object
Instance Method Details
#assert_schema_conform ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/committee/test/methods.rb', line 3 def assert_schema_conform if (data = schema_contents).is_a?(String) warn_string_deprecated data = MultiJson.decode(data) end @schema ||= begin schema = JsonSchema.parse!(data) schema. schema end @router ||= Committee::Router.new(@schema, prefix: schema_url_prefix) unless link = @router.find_request_link(last_request) response = "`#{last_request.request_method} #{last_request.path_info}` undefined in schema." raise Committee::InvalidResponse.new(response) end data = MultiJson.decode(last_response.body) Committee::ResponseValidator.new(link).call(last_response.status, last_response.headers, data) end |
#assert_schema_content_type ⇒ Object
25 26 27 |
# File 'lib/committee/test/methods.rb', line 25 def assert_schema_content_type Committee.warn_deprecated("Committee: use of #assert_schema_content_type is deprecated; use #assert_schema_conform instead.") end |
#schema_contents ⇒ Object
can be overridden alternatively to #schema_path in case the schema is easier to access as a string blob
32 33 34 |
# File 'lib/committee/test/methods.rb', line 32 def schema_contents MultiJson.decode(File.read(schema_path)) end |
#schema_path ⇒ Object
36 37 38 |
# File 'lib/committee/test/methods.rb', line 36 def schema_path raise "Please override #schema_contents or #schema_path." end |
#schema_url_prefix ⇒ Object
40 41 42 |
# File 'lib/committee/test/methods.rb', line 40 def schema_url_prefix nil end |
#warn_string_deprecated ⇒ Object
44 45 46 |
# File 'lib/committee/test/methods.rb', line 44 def warn_string_deprecated Committee.warn_deprecated("Committee: returning a string from `#schema_contents` is deprecated; please return a deserialized hash instead.") end |