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 |
# 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 ||= JsonSchema.parse!(data) @router ||= Committee::Router.new(@schema) link = @router.routes_request?(last_request, prefix: schema_url_prefix) unless link 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.headers, data) end |
#assert_schema_content_type ⇒ Object
23 24 25 |
# File 'lib/committee/test/methods.rb', line 23 def assert_schema_content_type Committee.warn_deprecated("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
30 31 32 |
# File 'lib/committee/test/methods.rb', line 30 def schema_contents MultiJson.decode(File.read(schema_path)) end |
#schema_path ⇒ Object
34 35 36 |
# File 'lib/committee/test/methods.rb', line 34 def schema_path raise "Please override #schema_contents or #schema_path." end |
#schema_url_prefix ⇒ Object
38 39 40 |
# File 'lib/committee/test/methods.rb', line 38 def schema_url_prefix nil end |
#warn_string_deprecated ⇒ Object
42 43 44 |
# File 'lib/committee/test/methods.rb', line 42 def warn_string_deprecated Committee.warn_deprecated("Committee: returning a string from `#schema_contents` is deprecated; please return a deserialized hash instead.") end |