Class: Brut::CLI::Apps::Test::Run
Direct Known Subclasses
E2e
Instance Attribute Summary
#parent_command
Instance Method Summary
collapse
#accepts, #argv, #bootstrap?, #commands, #delegate_to_command, #env, #execute, #name, #options, #puts, #stdin, #system!, #theme
Instance Method Details
#args_description ⇒ Object
22
|
# File 'lib/brut/cli/apps/test.rb', line 22
def args_description = "specs_to_run..."
|
#default_rack_env ⇒ Object
15
|
# File 'lib/brut/cli/apps/test.rb', line 15
def default_rack_env = "development"
|
#description ⇒ Object
16
|
# File 'lib/brut/cli/apps/test.rb', line 16
def description = "Run non-e2e tests"
|
#detailed_description ⇒ Object
23
24
25
|
# File 'lib/brut/cli/apps/test.rb', line 23
def detailed_description = %{
Runs all non end-to-end tests for the app, or runs a subset of non-end-to-end tests using RSpec-style syntax. Do note that you cannot use this command to run an end-to-end test, since those require the test server to be running.
}
|
#env_vars ⇒ Object
27
28
29
30
31
|
# File 'lib/brut/cli/apps/test.rb', line 27
def env_vars = [
[ "LOGGER_LEVEL_FOR_TESTS","Can be set to debug, info, warn, error, or fatal to control logging during tests. Defaults to 'warn' to avoid verbose test output" ],
[ "RSPEC_WARNINGS", "If set to 'true', configures RSpec warnings for the test run. NOTE: this is used in the app's spec_helper.rb so could've been removed" ],
[ "RSPEC_PROFILE_EXAMPLES", "If set to any value, it is converted to an int and set as RSpec's number of examples to profile. NOTE: this is used in the app's spec_helper.rb so could've been removed" ],
]
|
#opts ⇒ Object
17
18
19
20
21
|
# File 'lib/brut/cli/apps/test.rb', line 17
def opts = [
[ "--[no-]rebuild", "If true, test database is rebuilt before tests are run (default false)" ],
[ "--[no-]rebuild-after", "If true, test database is rebuilt after tests are run (default false)" ],
[ "--seed SEED", "Set the random seed to allow duplicating a test run" ],
]
|
#rebuild_after_by_default? ⇒ Boolean
50
|
# File 'lib/brut/cli/apps/test.rb', line 50
def rebuild_after_by_default? = false
|
#rebuild_by_default? ⇒ Boolean
49
|
# File 'lib/brut/cli/apps/test.rb', line 49
def rebuild_by_default? = false
|
#rspec_cli_args ⇒ Object
47
|
# File 'lib/brut/cli/apps/test.rb', line 47
def rspec_cli_args = "--tag ~e2e"
|
#rspec_command ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/brut/cli/apps/test.rb', line 33
def rspec_command
parts = [
"bin/rspec",
"-I", Brut.container.app_specs_dir,
"-I", Brut.container.app_src_dir,
rspec_cli_args,
"-P '**/*.spec.rb'",
]
if options.seed
parts << "--seed #{options.seed}"
end
parts.join(" ")
end
|
#run ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/brut/cli/apps/test.rb', line 52
def run
if options.rebuild?(default: rebuild_by_default?)
puts "Rebuilding test database schema"
Bundler.with_unbundled_env do
system! "brut db rebuild --env=test"
end
end
run_tests
if options.rebuild_after?(default: rebuild_after_by_default?)
puts "Re-Rebuilding test database schema"
Bundler.with_unbundled_env do
system! "brut db rebuild --env=test"
end
end
0
end
|