Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --insights flag to install command #564

Merged
merged 2 commits into from
Jun 14, 2024
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
4 changes: 4 additions & 0 deletions lib/honeybadger/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def run

# Enable verbose debug logging (useful for troubleshooting).
debug: false

# Enable Honeybadger Insights
insights:
enabled: #{options["insights"]}
CONFIG
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/honeybadger/cli/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def help(*args, &block)
end

desc 'install API_KEY', 'Install Honeybadger into a new project'
option :insights, type: :boolean, aliases: :'-i', default: false, desc: 'Enable Honeybadger Insights'
def install(api_key)
Install.new(options, api_key).run
rescue => e
Expand Down
12 changes: 12 additions & 0 deletions spec/features/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
end
end

context "with the insights flag" do
it "enables insights" do
run_command_and_stop('honeybadger install asdf --insights', fail_on_error: true)
expect(YAML.load_file(config_file).dig("insights", "enabled")).to eq(true)
end

it "disables insights" do
run_command_and_stop('honeybadger install asdf --no-insights', fail_on_error: true)
expect(YAML.load_file(config_file).dig("insights", "enabled")).to eq(false)
end
end

scenario "when the configuration file already exists" do
before { File.write(config_file, <<-YML) }
---
Expand Down