Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/annotate_rb/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def running?
end

def run(args, config_file_options: nil)
config_file_options ||= ConfigLoader.load_config
parser = Parser.new(args, {})

parsed_options = parser.parse
remaining_args = parser.remaining_args

AnnotateRb::ConfigFinder.config_path = parsed_options[:config_path] if parsed_options[:config_path]
config_file_options = ConfigLoader.load_config if config_file_options.nil?
options = config_file_options.merge(parsed_options)

@options = Options.from(options, {working_args: remaining_args})
Expand Down
24 changes: 24 additions & 0 deletions spec/lib/annotate_rb/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,30 @@
end
end

describe "custom config path", :isolated_environment do
let(:command_double) { instance_double(AnnotateRb::Commands::AnnotateModels) }

before do
File.write(".annotaterb.yml", "show_indexes: false\n")
File.write("custom_annotaterb.yml", "show_indexes: true\n")

allow(AnnotateRb::Commands::AnnotateModels).to receive(:new).and_return(command_double)
allow(command_double).to receive(:call)
end

after do
AnnotateRb::ConfigFinder.config_path = nil
end

it "loads the config file specified by --config-path" do
runner.run(["models", "--config-path", "custom_annotaterb.yml"])

expect(command_double).to have_received(:call) do |options|
expect(options[:show_indexes]).to be(true)
end
end
end

describe "Annotating routes" do
let(:args) { ["routes"] }
let(:command_double) { instance_double(AnnotateRb::Commands::AnnotateRoutes) }
Expand Down
Loading