Skip to content
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

RSpec/ReturnFromStub-20220903011215 #775

Merged
merged 3 commits into from
Sep 3, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 3, 2022

Rubocop challenge!

RSpec/ReturnFromStub

Safe autocorrect: Yes
✅ The autocorrect a cop does is safe (equivalent) by design.

Description

Overview

Checks for consistent style of stub's return setting.

Enforces either and_return or block-style return in the cases
where the returned value is constant. Ignores dynamic returned values
are the result would be different

This cop can be configured using the EnforcedStyle option

Examples

EnforcedStyle: and_return (default)

# bad
allow(Foo).to receive(:bar) { "baz" }
expect(Foo).to receive(:bar) { "baz" }

# good
allow(Foo).to receive(:bar).and_return("baz")
expect(Foo).to receive(:bar).and_return("baz")
# also good as the returned value is dynamic
allow(Foo).to receive(:bar) { bar.baz }

EnforcedStyle: block

# bad
allow(Foo).to receive(:bar).and_return("baz")
expect(Foo).to receive(:bar).and_return("baz")

# good
allow(Foo).to receive(:bar) { "baz" }
expect(Foo).to receive(:bar) { "baz" }
# also good as the returned value is dynamic
allow(Foo).to receive(:bar).and_return(bar.baz)

Auto generated by rubocop_challenger

@mathieujobin mathieujobin force-pushed the rubocop-challenge/20220903011215 branch from c1c1f58 to c51bb06 Compare September 3, 2022 01:19
@mathieujobin mathieujobin merged commit 2a2a593 into master Sep 3, 2022
@mathieujobin mathieujobin deleted the rubocop-challenge/20220903011215 branch September 3, 2022 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant