Class: Capsium::Package::Testing::RouteTest
- Defined in:
- lib/capsium/package/testing/route_test.rb,
sig/capsium/package/testing/route_test.rbs
Overview
A "route" test (05x-testing): requests the URL path from the reactor serving the package and checks the expected status, and optionally the content type and a response body substring.
Instance Attribute Summary collapse
-
#expected_content_type ⇒ String?
readonly
Returns the value of attribute expected_content_type.
-
#expected_status ⇒ Integer
readonly
Returns the value of attribute expected_status.
-
#response_contains ⇒ String?
readonly
Returns the value of attribute response_contains.
-
#url ⇒ String
readonly
Returns the value of attribute url.
Attributes inherited from TestCase
Instance Method Summary collapse
-
#initialize(name:, url:, expected_status:, response_contains: nil, expected_content_type: nil) ⇒ RouteTest
constructor
A new instance of RouteTest.
- #run(context) ⇒ TestCase::Result
Methods inherited from TestCase
build, from_h, register, types
Constructor Details
#initialize(name:, url:, expected_status:, response_contains: nil, expected_content_type: nil) ⇒ RouteTest
Returns a new instance of RouteTest.
15 16 17 18 19 20 21 22 |
# File 'lib/capsium/package/testing/route_test.rb', line 15 def initialize(name:, url:, expected_status:, response_contains: nil, expected_content_type: nil) super(name: name) @url = url @expected_status = expected_status @response_contains = response_contains @expected_content_type = expected_content_type end |
Instance Attribute Details
#expected_content_type ⇒ String? (readonly)
Returns the value of attribute expected_content_type.
13 14 15 |
# File 'lib/capsium/package/testing/route_test.rb', line 13 def expected_content_type @expected_content_type end |
#expected_status ⇒ Integer (readonly)
Returns the value of attribute expected_status.
13 14 15 |
# File 'lib/capsium/package/testing/route_test.rb', line 13 def expected_status @expected_status end |
#response_contains ⇒ String? (readonly)
Returns the value of attribute response_contains.
13 14 15 |
# File 'lib/capsium/package/testing/route_test.rb', line 13 def response_contains @response_contains end |
#url ⇒ String (readonly)
Returns the value of attribute url.
13 14 15 |
# File 'lib/capsium/package/testing/route_test.rb', line 13 def url @url end |
Instance Method Details
#run(context) ⇒ TestCase::Result
24 25 26 27 28 29 |
# File 'lib/capsium/package/testing/route_test.rb', line 24 def run(context) response = Net::HTTP.get_response(URI.join(context.base_url, request_path)) problems = status_problems(response) + content_type_problems(response) + body_problems(response) Result.new(name: name, ok: problems.empty?, messages: problems) end |