Add test case handling NoReturn stub and top-level methods (exit)

Fixes https://github.com/icy-arctic-fox/spectator/issues/29
This commit is contained in:
Michael Miller 2021-07-02 21:55:42 -06:00
parent 92dbfc2a8e
commit f728ab6ad7
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
2 changed files with 24 additions and 0 deletions

View file

@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Fix `expect().to receive()` syntax not implicitly stubbing the method.
- Avoid calling `NoReturn` methods from stubs. [#29](https://github.com/icy-arctic-fox/spectator/issues/29)
### Added
- Added support for `with(no_args)` for method stubs. [#28](https://github.com/icy-arctic-fox/spectator/issues/28)
- Allow creation of doubles without definition block. [#30](https://github.com/icy-arctic-fox/spectator/issues/30)

View file

@ -0,0 +1,20 @@
require "../spec_helper"
Spectator.describe "GitHub Issue #29" do
class SomeClass
def goodbye
exit 0
end
end
mock SomeClass do
stub exit(code)
end
describe SomeClass do
it "captures exit" do
expect(subject).to receive(:exit).with(0)
subject.goodbye
end
end
end