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, #print, #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
|
#rebuild_db(before_or_after:) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/brut/cli/apps/test.rb', line 59
def rebuild_db(before_or_after:)
option, default, verb = if before_or_after == :before
[ :rebuild?, :rebuild_by_default?, "Rebuilding" ]
elsif before_or_after == :after
[ :rebuild_after?, :rebuild_after_by_default?, "Re-rebuilding" ]
else
bug!("before_or_after must be :before or :after")
end
if options.send(option, default: self.send(default))
puts "#{verb} testing datbase"
Bundler.with_unbundled_env do
system! "brut db rebuild --env=test"
end
end
end
|
#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
|
# File 'lib/brut/cli/apps/test.rb', line 52
def run
rebuild_db(before_or_after: :before)
run_tests
rebuild_db(before_or_after: :after)
0
end
|