Class: Brut::CLI::Apps::Test::Run
Direct Known Subclasses
E2e
Instance Attribute Summary
#parent_command
Instance Method Summary
collapse
#accepts, #argv, #bootstrap?, #commands, #default_command, #default_command_class, #env, #execute, #name, #options, #puts, #stderr, #stdin, #stdout, #system!
Instance Method Details
#args_description ⇒ Object
18
|
# File 'lib/brut/cli/apps/test.rb', line 18
def args_description = "specs_to_run..."
|
#default_rack_env ⇒ Object
11
|
# File 'lib/brut/cli/apps/test.rb', line 11
def default_rack_env = "development"
|
#description ⇒ Object
12
|
# File 'lib/brut/cli/apps/test.rb', line 12
def description = "Run non-e2e tests"
|
#env_vars ⇒ Object
20
21
22
23
24
|
# File 'lib/brut/cli/apps/test.rb', line 20
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
13
14
15
16
17
|
# File 'lib/brut/cli/apps/test.rb', line 13
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
45
|
# File 'lib/brut/cli/apps/test.rb', line 45
def rebuild_after_by_default? = false
|
#rebuild_by_default? ⇒ Boolean
44
|
# File 'lib/brut/cli/apps/test.rb', line 44
def rebuild_by_default? = false
|
#rspec_cli_args ⇒ Object
42
|
# File 'lib/brut/cli/apps/test.rb', line 42
def rspec_cli_args = "--tag ~e2e"
|
#rspec_command ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/brut/cli/apps/test.rb', line 27
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/brut/cli/apps/test.rb', line 47
def run
if options.rebuild?(default: rebuild_by_default?)
stdout.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?)
stdout.puts "Re-Rebuilding test database schema"
Bundler.with_unbundled_env do
system! "brut db rebuild --env=test"
end
end
0
end
|