Class: RainforestRubyRuntime::Runner
- Inherits:
-
Object
- Object
- RainforestRubyRuntime::Runner
- Defined in:
- lib/rainforest_ruby_runtime/runner.rb
Instance Attribute Summary collapse
-
#config_options ⇒ Object
readonly
Returns the value of attribute config_options.
Instance Method Summary collapse
- #driver ⇒ Object
- #extract_results(code, fake_session_id: nil) ⇒ Object
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #run(code) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
5 6 7 8 |
# File 'lib/rainforest_ruby_runtime/runner.rb', line 5 def initialize( = {}) = .dup.freeze @step_variables = [:step_variables] end |
Instance Attribute Details
#config_options ⇒ Object (readonly)
Returns the value of attribute config_options.
3 4 5 |
# File 'lib/rainforest_ruby_runtime/runner.rb', line 3 def end |
Instance Method Details
#driver ⇒ Object
53 54 55 |
# File 'lib/rainforest_ruby_runtime/runner.rb', line 53 def driver ENV.fetch("CAPYBARA_DRIVER") { "selenium" } end |
#extract_results(code, fake_session_id: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rainforest_ruby_runtime/runner.rb', line 29 def extract_results(code, fake_session_id: nil) stdout = stderr = nil payload = nil begin stdout, stderr = capture_output2 do run(code) end rescue RSpec::Expectations::ExpectationNotMetError => e payload = exception_to_payload e, status: 'failed' rescue StandardError => e payload = exception_to_payload e, status: 'error' rescue SyntaxError, Exception => e payload = exception_to_payload e, status: 'fatal_error' end payload ||= { status: 'passed' } payload.merge({ stdout: stdout, stderr: stderr, session_id: fake_session_id || session_id }) end |
#run(code) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rainforest_ruby_runtime/runner.rb', line 10 def run(code) extend RainforestRubyRuntime::DSL .default_driver = :"#{driver}" .default_wait_time = wait_time apply_config! setup_scope_registery! test = eval(code) if Test === test test.run else raise WrongReturnValueError, test end test ensure terminate_session! end |