Class: OasRails::Spec::MediaType
- Inherits:
-
Object
- Object
- OasRails::Spec::MediaType
- Includes:
- Specable
- Defined in:
- lib/oas_rails/spec/media_type.rb
Instance Attribute Summary collapse
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#example ⇒ Object
Returns the value of attribute example.
-
#examples ⇒ Object
Returns the value of attribute examples.
-
#schema ⇒ Object
Returns the value of attribute schema.
Class Method Summary collapse
-
.search_for_examples_in_tests(klass, context: :incoming, utils: Utils) ⇒ Hash
Searches for examples in test files based on the provided class and test framework.
Instance Method Summary collapse
-
#initialize(specification) ⇒ MediaType
constructor
Initializes a new MediaType object.
- #oas_fields ⇒ Object
Methods included from Specable
Constructor Details
#initialize(specification) ⇒ MediaType
Initializes a new MediaType object.
15 16 17 18 19 20 |
# File 'lib/oas_rails/spec/media_type.rb', line 15 def initialize(specification) @specification = specification @schema = {} @example = {} @examples = {} end |
Instance Attribute Details
#encoding ⇒ Object
Returns the value of attribute encoding.
6 7 8 |
# File 'lib/oas_rails/spec/media_type.rb', line 6 def encoding @encoding end |
#example ⇒ Object
Returns the value of attribute example.
6 7 8 |
# File 'lib/oas_rails/spec/media_type.rb', line 6 def example @example end |
#examples ⇒ Object
Returns the value of attribute examples.
6 7 8 |
# File 'lib/oas_rails/spec/media_type.rb', line 6 def examples @examples end |
#schema ⇒ Object
Returns the value of attribute schema.
6 7 8 |
# File 'lib/oas_rails/spec/media_type.rb', line 6 def schema @schema end |
Class Method Details
.search_for_examples_in_tests(klass, context: :incoming, utils: Utils) ⇒ Hash
Searches for examples in test files based on the provided class and test framework.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oas_rails/spec/media_type.rb', line 32 def search_for_examples_in_tests(klass, context: :incoming, utils: Utils) @context = context case utils.detect_test_framework when :factory_bot fetch_factory_bot_examples(klass:) when :fixtures fetch_fixture_examples(klass:) else {} end end |
Instance Method Details
#oas_fields ⇒ Object
22 23 24 |
# File 'lib/oas_rails/spec/media_type.rb', line 22 def oas_fields [:schema, :example, :examples, :encoding] end |