Skip to content

Commit

Permalink
Adds --insights to install command
Browse files Browse the repository at this point in the history
This makes it easy to enable (or disable) Honeybadger Insights when
installing in an application.

```bash
bundle exec honeybadger install apikey --insights
```
  • Loading branch information
excid3 committed Jun 14, 2024
1 parent 1226944 commit 1ee3c1e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
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:
enable: #{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", "enable")).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", "enable")).to eq(false)
end
end

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

0 comments on commit 1ee3c1e

Please sign in to comment.