Skip to content

Commit

Permalink
Provide an easy way to run acceptance test via rake rspec
Browse files Browse the repository at this point in the history
When either ZABBIX_RUN_ACCEPTANCE or ZABBIX_HOST_URL is set as an
environment variable, it's considered that the user opts in to
acceptance tests.

The acceptance tests previously didn't have the _spec suffix, so they
weren't picked up by the file filter. The acceptance tests are dangerous
on a production system, so they are now flagged with their own type.
Flagging also makes it possible to include specific contexts just for
acceptance tests.
  • Loading branch information
ekohl committed Dec 30, 2023
1 parent 04bc541 commit 80e0d56
Show file tree
Hide file tree
Showing 26 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rspec ./spec/*
run: bundle exec rake spec
env:
ZABBIX_RUN_ACCEPTANCE: true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
require 'zabbixapi'

RSpec.configure do |config|
config.define_derived_metadata(file_path: %r{/spec/acceptance/}) do |metadata|
metadata[:type] = :acceptance
end

# Don't run acceptance tests unless a host is provided
unless (ENV.key?('ZABBIX_HOST_URL') || ENV.key?('ZABBIX_RUN_ACCEPTANCE'))
config.filter_run_excluding type: :acceptance
end
end

def zbx
# settings
@api_url = ENV['ZABBIX_HOST_URL'] || 'http://localhost:8080/api_jsonrpc.php'
Expand Down

0 comments on commit 80e0d56

Please sign in to comment.