Attempt to require the custom export class.
This commit is contained in:
1 parent
d54b46806c
commit
84c49ae2b8
2 files changed
+4
-1
No files matched your search
@@ -47,10 +47,13 @@ class Foreman::CLI < Thor
|
|||||||
check_procfile!
|
check_procfile!
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
require "foreman/export/#{ format.tr('-', '_') }"
|
||||||
classy_format = classify(format)
|
classy_format = classify(format)
|
||||||
formatter = constantize("Foreman::Export::#{ classy_format }")
|
formatter = constantize("Foreman::Export::#{ classy_format }")
|
||||||
rescue NameError => ex
|
rescue NameError => ex
|
||||||
error "Unknown export format: #{format} (no class Foreman::Export::#{ classy_format })."
|
error "Unknown export format: #{format} (no class Foreman::Export::#{ classy_format })."
|
||||||
|
rescue LoadError => ex
|
||||||
|
error "Unknown export format: #{format} (unable to load file 'foreman/export/#{ format.tr('-', '_') }')."
|
||||||
end
|
end
|
||||||
|
|
||||||
formatter.new(engine, options).export(location)
|
formatter.new(engine, options).export(location)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ describe "Foreman::CLI", :fakefs do
|
|||||||
|
|
||||||
describe "with an invalid formatter" do
|
describe "with an invalid formatter" do
|
||||||
it "prints an error" do
|
it "prints an error" do
|
||||||
mock_error(subject, "Unknown export format: invalidformatter.") do
|
mock_error(subject, "Unknown export format: invalidformatter (unable to load file 'foreman/export/invalidformatter').") do
|
||||||
subject.export("invalidformatter")
|
subject.export("invalidformatter")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user