Class: QaServer::SearchScenario
- Inherits:
-
AuthorityScenario
- Object
- AuthorityScenario
- QaServer::SearchScenario
- Defined in:
- app/models/qa_server/search_scenario.rb
Constant Summary collapse
- MAX_RECORDS =
'4'
- DEFAULT_REPLACEMENTS =
{ maxRecords: MAX_RECORDS }.freeze
- DEFAULT_POSITION =
nil
- DEFAULT_SUBJECT_URI =
nil
Constants inherited from AuthorityScenario
AuthorityScenario::DEFAULT_SUBAUTH, AuthorityScenario::MIN_EXPECTED_SIZE
Instance Attribute Summary collapse
-
#expected_by_position ⇒ Integer
readonly
Expected_by_position designates the maximum position in search results of subject_uri, if specified, for this scenario to be considered passing.
-
#query ⇒ String
readonly
Query being executed by this scenario.
-
#replacements ⇒ Hash
readonly
Replacements parameters used to construct the URL executed by this scenario.
-
#subject_uri ⇒ String
readonly
Subject_uri, if specified, should be in the search results between position 1 and expected_by_position.
Attributes inherited from AuthorityScenario
#authority, #authority_name, #min_result_size, #service, #subauthority_name
Instance Method Summary collapse
-
#initialize(authority:, authority_name:, authority_scenario_config:, scenario_config:) ⇒ SearchScenario
constructor
A new instance of SearchScenario.
- #pending? ⇒ Boolean
-
#url ⇒ String
Generate an example URL that can be called in a browser or through curl.
Constructor Details
#initialize(authority:, authority_name:, authority_scenario_config:, scenario_config:) ⇒ SearchScenario
Returns a new instance of SearchScenario.
26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/qa_server/search_scenario.rb', line 26 def initialize(authority:, authority_name:, authority_scenario_config:, scenario_config:) # rubocop:disable Metrics/CyclomaticComplexity super @query = scenario_config['query'] @subauthority_name = scenario_config['subauth'] || DEFAULT_SUBAUTH @min_result_size = scenario_config['result_size'] || MIN_EXPECTED_SIZE @replacements = scenario_config['replacements'] || DEFAULT_REPLACEMENTS @expected_by_position = scenario_config['position'] || DEFAULT_POSITION @subject_uri = scenario_config['subject_uri'] || DEFAULT_SUBJECT_URI @pending = scenario_config['pending'] || false end |
Instance Attribute Details
#expected_by_position ⇒ Integer (readonly)
Returns expected_by_position designates the maximum position in search results of subject_uri, if specified, for this scenario to be considered passing.
12 13 14 |
# File 'app/models/qa_server/search_scenario.rb', line 12 def expected_by_position @expected_by_position end |
#query ⇒ String (readonly)
Returns query being executed by this scenario.
6 7 8 |
# File 'app/models/qa_server/search_scenario.rb', line 6 def query @query end |
#replacements ⇒ Hash (readonly)
Returns replacements parameters used to construct the URL executed by this scenario.
9 10 11 |
# File 'app/models/qa_server/search_scenario.rb', line 9 def replacements @replacements end |
#subject_uri ⇒ String (readonly)
Returns subject_uri, if specified, should be in the search results between position 1 and expected_by_position.
15 16 17 |
# File 'app/models/qa_server/search_scenario.rb', line 15 def subject_uri @subject_uri end |
Instance Method Details
#pending? ⇒ Boolean
46 47 48 |
# File 'app/models/qa_server/search_scenario.rb', line 46 def pending? @pending end |
#url ⇒ String
Generate an example URL that can be called in a browser or through curl
39 40 41 42 43 44 |
# File 'app/models/qa_server/search_scenario.rb', line 39 def url subauth = "/#{}" if context = context? ? '&context=true' : '' prefix = "#{QaServer::Engine.qa_engine_mount}/search/linked_data/#{.downcase}#{subauth}" "#{prefix}?q=#{query}#{url_replacements}#{context}" end |