inferno_core 0.4.9 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 470abbacaa895d2d3451f130734c0e34eec9303ec19858976f79b0456c0d619b
4
- data.tar.gz: c60351312c3116c39260332b88675f2d8e2b0a3732be2dbf68c2a41c63cd62ab
3
+ metadata.gz: 79e59753922bf1c5a06e2603a27f267e6b75aed91d46b5531b2ecffcf13a95a8
4
+ data.tar.gz: 318edf53524ede718e5331b9ec4eb626537553cd0d88ff2df3a4237dc83c2f3e
5
5
  SHA512:
6
- metadata.gz: 1ff98dd5180315c77a4627710a7bb9c5eaf82d87f81a173f849e24aadf6cad908feb71ac3d92b6a9ca14b38163cf9a821ce236c407e5eb688467e36295fd148e
7
- data.tar.gz: 324efe61696b3e86b061adede76bd6c3a1d997f15e2c2e1225dc5edb3bc1f24f3ca7ec21b6363c060ed68eb1d66306baa247d34df8cb465a82c7d70b239a1bec
6
+ metadata.gz: 6ab836f245a7172c320405d75649be9ab8281b9d7e9520818b160f75aecdac21a7a94aa8d91f9337361475e27560260b36896e7ee5c7f7f6b749123e4b75f4a4
7
+ data.tar.gz: 3c1f9dbd1209817b38114a609a20c4e6cca27c89743d7c91a8fe954be70a4450112ee72f07ceabf7e9e9c40a8140e7990a6280b70625f71596d8aa0b0ee2b569
@@ -18,12 +18,25 @@ module Inferno
18
18
  end
19
19
 
20
20
  desc 'start', 'Start Inferno'
21
+ option :watch,
22
+ default: false,
23
+ type: :boolean,
24
+ desc: 'Automatically restart Inferno when a file is changed.'
21
25
  def start
26
+ command = 'foreman start --env=/dev/null'
22
27
  if `gem list -i foreman`.chomp == 'false'
23
- puts "You must install foreman with 'gem install foreman' prior to running inferno."
28
+ puts "You must install foreman with 'gem install foreman' prior to running Inferno."
24
29
  end
25
30
 
26
- system 'foreman start --env=/dev/null'
31
+ if options[:watch]
32
+ if `gem list -i rerun`.chomp == 'false'
33
+ puts "You must install 'rerun' with 'gem install rerun' to restart on file changes."
34
+ end
35
+
36
+ command = "rerun \"#{command}\" --background"
37
+ end
38
+
39
+ system command
27
40
  end
28
41
 
29
42
  desc 'suites', 'List available test suites'
@@ -0,0 +1,40 @@
1
+ module Inferno
2
+ module Web
3
+ module Controllers
4
+ module TestSessions
5
+ class ClientShow < Controller
6
+ config.default_response_format = :html
7
+
8
+ CLIENT_PAGE =
9
+ ERB.new(
10
+ File.read(
11
+ File.join(
12
+ Inferno::Application.root, 'lib', 'inferno', 'apps', 'web', 'index.html.erb'
13
+ )
14
+ )
15
+ ).result.freeze
16
+
17
+ def handle(req, res)
18
+ test_session_id = req.params[:id]
19
+ test_suite_id = req.params[:test_suite_id]
20
+
21
+ test_session = repo.find(test_session_id)
22
+ halt 404 if test_session.nil?
23
+
24
+ if test_suite_id.blank? || test_suite_id != test_session.test_suite_id
25
+ test_suite_id = test_session.test_suite_id
26
+
27
+ res.redirect_to "#{Inferno::Application['base_url']}/#{test_suite_id}/#{test_session_id}"
28
+ end
29
+
30
+ test_suite = Inferno::Repositories::TestSuites.new.find(test_suite_id)
31
+
32
+ halt 404 if test_suite.nil?
33
+
34
+ res.body = CLIENT_PAGE
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -53,7 +53,6 @@ module Inferno
53
53
  # Should not need Content-Type header but GitHub Codespaces will not work without them.
54
54
  # This could be investigated and likely removed if addressed properly elsewhere.
55
55
  get '/', to: ->(_env) { [200, { 'Content-Type' => 'text/html' }, [client_page]] }
56
- get '/test_sessions/:id', to: ->(_env) { [200, { 'Content-Type' => 'text/html' }, [client_page]] }
57
56
 
58
57
  Inferno.routes.each do |route|
59
58
  cleaned_id = route[:suite].id.gsub(/[^a-zA-Z\d\-._~]/, '_')
@@ -70,6 +69,9 @@ module Inferno
70
69
  Application['logger'].info("Registering suite route: #{suite_path}")
71
70
  get suite_path, to: ->(_env) { [200, {}, [client_page]] }
72
71
  end
72
+
73
+ get '/test_sessions/:id', to: Inferno::Web::Controllers::TestSessions::ClientShow, as: :client_session_show
74
+ get '/:test_suite_id/:id', to: Inferno::Web::Controllers::TestSessions::ClientShow, as: :client_suite_session_show
73
75
  end
74
76
 
75
77
  Router = # rubocop:disable Naming/ConstantName
@@ -22,13 +22,15 @@ module Inferno
22
22
  "Unexpected response status: expected #{Array.wrap(expected).join(', ')}, but received #{received}"
23
23
  end
24
24
 
25
- # Check an response's status
25
+ # Check a response's status
26
26
  #
27
27
  # @param status [Integer, Array<Integer>] a single integer or an array of
28
28
  # integer status codes
29
+ # @param request [Inferno::Entities::Request]
29
30
  # @param response [Hash]
30
31
  # @return [void]
31
- def assert_response_status(status, response: self.response)
32
+ def assert_response_status(status, request: self.request, response: nil)
33
+ response ||= request&.response
32
34
  assert Array.wrap(status).include?(response[:status]), bad_response_status_message(status, response[:status])
33
35
  end
34
36
 
@@ -171,7 +173,8 @@ module Inferno
171
173
  assert uri =~ /\A#{URI::DEFAULT_PARSER.make_regexp(['http', 'https'])}\z/, error_message
172
174
  end
173
175
 
174
- # Check the Content-Type header of a response
176
+ # Check the Content-Type header of a response. This assertion will fail if
177
+ # the response's content type does not begin with the provided type.
175
178
  #
176
179
  # @param type [String]
177
180
  # @param request [Inferno::Entities::Request]
@@ -40,7 +40,7 @@ module Inferno
40
40
 
41
41
  self.suite_options ||= []
42
42
 
43
- test_suite.suite_options&.each do |option|
43
+ test_suite&.suite_options&.each do |option|
44
44
  if suite_options.none? { |selected_option| selected_option.id == option.id }
45
45
  suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
46
46
  end