Class: Brut::CLI::Apps::Test::E2e

Inherits:
Run show all
Defined in:
lib/brut/cli/apps/test.rb

Instance Attribute Summary

Attributes inherited from Commands::BaseCommand

#parent_command

Instance Method Summary collapse

Methods inherited from Run

#args_description, #default_rack_env, #opts, #rebuild_db, #rspec_command

Methods inherited from Commands::BaseCommand

#accepts, #args_description, #argv, #bootstrap?, #commands, #default_rack_env, #delegate_to_command, #env, #execute, #name, #options, #opts, #print, #puts, #stdin, #system!, #theme

Instance Method Details

#descriptionObject



94
# File 'lib/brut/cli/apps/test.rb', line 94

def description = "Run end-to-end (browser) tests"

#detailed_descriptionObject



105
106
107
# File 'lib/brut/cli/apps/test.rb', line 105

def detailed_description = %{
Runs all end-to-end tests for the app, or runs a subset of end-to-end tests using RSpec-style syntax. This will run bin/test-server first, so if that fails for some reason, no tests are run.
}

#env_varsObject



95
96
97
98
99
100
# File 'lib/brut/cli/apps/test.rb', line 95

def env_vars = super + [
  [ "E2E_RECORD_VIDEOS","If set to 'true', videos of each test run are saved in `./tmp/e2e-videos`" ],
  [ "E2E_SLOW_MO","If set to, will attempt to slow operations down by this many milliseconds" ],
  [ "E2E_TIMEOUT_MS","ms to wait for any browser activity before failing the test. And here you didn't think you'd get away without using sleep in browse-based tests?" ],
  [ "E2E_STARTUP_TIMEOUT_SEC","seconds to wait for the test server to start before assuming something went wrong" ],
]

#rebuild_after_by_default?Boolean

Returns:

  • (Boolean)


104
# File 'lib/brut/cli/apps/test.rb', line 104

def rebuild_after_by_default? = true

#rebuild_by_default?Boolean

Returns:

  • (Boolean)


103
# File 'lib/brut/cli/apps/test.rb', line 103

def rebuild_by_default?       = true

#rspec_cli_argsObject



102
# File 'lib/brut/cli/apps/test.rb', line 102

def rspec_cli_args = "--tag e2e"

#runObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/brut/cli/apps/test.rb', line 109

def run
  rebuild_db(before_or_after: :before)
  require "brut/spec_support/e2e_test_server"
  test_server = Brut::SpecSupport::E2ETestServer.new(
    bin_dir: Brut.container.project_root / "bin",
    start_timeout_seconds: ENV["E2E_STARTUP_TIMEOUT_SEC"]
  )
  begin
    test_server.start
    run_tests
  ensure
    test_server.stop
    rebuild_db(before_or_after: :after)
  end
  0
end