Module: DaVinciPDexTestKit::UserInputResponse
- Defined in:
- lib/davinci_pdex_test_kit/user_input_response.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
3 4 5 |
# File 'lib/davinci_pdex_test_kit/user_input_response.rb', line 3 def self.included(klass) klass.extend ClassMethods end |
.user_inputted_response(configurable, result) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/davinci_pdex_test_kit/user_input_response.rb', line 7 def self.user_inputted_response(configurable, result) input_key = configurable.config.[:respond_with] return unless input_key.present? JSON.parse(result.input_json)&.find { |i| i['name'] == input_key.to_s }&.dig('value') rescue JSON::ParserError nil end |
Instance Method Details
#check_user_inputted_response(input_key, message = nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/davinci_pdex_test_kit/user_input_response.rb', line 16 def check_user_inputted_response(input_key, = nil) skip_if send(input_key).blank?, || "To run this test a response body must be provided in the '**#{input_title(input_key)}**' input" end |
#input_title(input_key) ⇒ Object
22 23 24 |
# File 'lib/davinci_pdex_test_kit/user_input_response.rb', line 22 def input_title(input_key) config.inputs[input_key]&.title || config.inputs[input_key]&.name end |