Splunk SDK for Ruby examples and unit tests

The Splunk SDK for Ruby is deprecated. For more information, see Deprecation notice.

This release of the Splunk® SDK for Ruby includes a few examples and unit tests. More are on the way.

View the examples

You can find examples within the examples/ directory of the Splunk SDK for Ruby. You'll also find helpful code snippets in-line with the code within the SDK, and in the API reference documentation

Prepare for the unit tests

First, do not run the test suite against your production Splunk server! Install another copy and run it against that.

Second, update your installations of both the Rake build tool and the Test::Unit unit test framework from RubyGems:

gem install rake
gem install test-unit

The test suite reads the host to connect to and credentials to use from a .splunkrc file. For more information about creating the .splunkrc file, see Utilities.

Run the unit tests

In the base directory where you installed the Splunk SDK for Ruby, run

rake test

The test suite should run many tests without error.

To generate code coverage of the test suite, first ensure you've installed the latest version of SimpleCov:

gem install simplecov

To generate the code coverage, run:

rake test COVERAGE=true

The test suite will produce a directory called coverage. Open coverage/index.html to see the coverage report.

Note: To protect your Splunk password, remember to delete the .splunkrc file when you are done running the unit tests.