-
Notifications
You must be signed in to change notification settings - Fork 22
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
GUILD-619: Test helpers don't automatically reset to test config #120
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9d8b8e9
GUILD-619: First pass at the config function
angad-singh 0d7c5a1
GUILD-619: Rubocop fixes
angad-singh a8e87dc
GUILD-619: Remove old code and add default config
angad-singh 9423cb0
GUILD-619: Update README
angad-singh d7c8da6
GUILD-619: Update CHANGELOG and README
angad-singh a1c1926
GUILD-619: Update README index
angad-singh 60787fc
GUILD-619: Fix the PR link in CHANGELOG
angad-singh eeb2243
GUILD-619: Add presets for unit test and kafka related tests
angad-singh 3ff1d7e
GUILD-619: Update README
angad-singh 8040edb
GUILD-619: Address PR comments
angad-singh bcf8bef
GUILD-619: Rename a method
angad-singh 1fc082c
Merge branch 'master' into GUILD-619
angad-singh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ Built on Phobos and hence Ruby-Kafka. | |
* [Running Consumers](#running-consumers) | ||
* [Metrics](#metrics) | ||
* [Testing](#testing) | ||
* [Test Helpers](#test-helpers) | ||
* [Integration Test Helpers](#integration-test-helpers) | ||
* [Utilities](#utilities) | ||
* [Contributing](#contributing) | ||
|
@@ -946,6 +947,32 @@ require 'deimos/test_helpers' | |
# Can pass a file path, a string or a hash into this: | ||
Deimos::TestHelpers.schemas_compatible?(schema1, schema2) | ||
``` | ||
### Test Helpers | ||
|
||
There are helper methods available to configure Deimos for different types of testing scenarios. | ||
Currently there is a helper defined for unit tests and for testing Kafka releated code. You can use it as follows: | ||
|
||
```ruby | ||
# The following can be added to a rpsec file so that each unit | ||
# test can have the same settings every time it is run | ||
around(:each) do |example| | ||
Deimos::TestHelpers.unit_test! | ||
example.run | ||
Deimos.config.reset | ||
end | ||
|
||
|
||
# Similarly you can use the Kafka test helper | ||
around(:each) do |example| | ||
Deimos::TestHelpers.kafka_test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing ! |
||
example.run | ||
Deimos.config.reset | ||
end | ||
``` | ||
|
||
With the help of these helper methods, rspec examples can be written without having to tinker with Deimos settings. | ||
This also prevents Deimos setting changes from leaking in to other examples. | ||
dorner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
### Integration Test Helpers | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should call out in bold that this is a breaking change.