#2 stub WTS HTTP calls with webmock#62
Open
kreinba wants to merge 1 commit into
Open
Conversation
Replace the live calls to https://wts.zold.io with webmock stubs so the test suite no longer depends on the network or on the live WTS service. The previous tests called WebMock.allow_net_connect! and reached the real endpoint for every assertion, turning the suite into an integration test against a third-party host and lengthening every run to roughly 24 seconds; with the stubs the same eight tests now finish in well under a second and exercise the same code paths. Closes zold-io#2
edmoffo
approved these changes
Jun 11, 2026
edmoffo
left a comment
There was a problem hiding this comment.
Closes #2 cleanly. Each of the eight existing tests in test/zold/test_wts.rb now runs against a webmock stub for the WTS endpoint it touches, and setup pins WebMock.disable_net_connect! at the class level so no test can leak to wts.zold.io. Local bundle exec rake test runs all 8 tests in 0.03s with 0 failures and 86.67% line coverage, matching the numbers in the PR body. The four red CI checks on this branch (rubocop-rspec_rails inject_defaults, markdown-lint on README.md, criterias typo, yamllint) are also red on master at 7c79029, so this diff does not introduce them. No inline comments.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue #2 asks for
webmock-based unit tests because the existing suite reaches the live WTS athttps://wts.zold.iofor every test. The existing tests callWebMock.allow_net_connect!, so any failure or latency on the third-party host produces a red CI run, and the suite cannot be relied on as a unit-level signal for the code inlib/zold/wts.rb.This change replaces the live calls in
test/zold/test_wts.rbwithwebmockstubs covering/pull,/job?id=...,/balance,/id,/find?..., and/usd_rate, and movesWebMock.disable_net_connect!into asetuphook so no test can leak to the network. The eight existing tests still cover the same code paths inZold::WTSandZold::WTS::Fake, but each one now finishes in milliseconds and never depends onwts.zold.iobeing reachable.Locally on Ruby 3.3.6:
bundle exec rake testruns all 8 tests in under one second with 0 failures and 86.67% line coverage; the previous run onmastertook roughly 24 seconds against the live host. Therake rubocopstep exhibits the samerubocop-rspec_railsinject_defaults!failure asmaster, so this branch does not introduce a new lint failure.Closes #2