Does it make sense to have an expect block with no subject?
See original GitHub issueCurrently expect
takes a subject parameter. There’s no way to group assertions on multiple subjects (at least without abusing Assertion.Builder.map
).
Does it make sense to have a form of expect
that just takes a block? For example:
expect {
that("fnord").isLowerCase()
that("FNORD").isUpperCase()
}
The receiver of such a block would be a new interface with just fun <T> that(subject: T): Assertion.Builder<T>
and fun <T> that(subject: T, block: Assertion.Builder<T> -> Unit): Unit
.
The main problem would be that method dispatch would be ambiguous between the new expect
method and the existing fun <T> expect(subject: T): Assertion.Builder<T>
. One of them would need a different name (or to be removed).
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
What's the difference between RSpec's subject and let? When ...
Summary: RSpec's subject is a special variable that refers to the object being tested. Expectations can be set on it implicitly, ...
Read more >is_expected with block expectations #805 - GitHub
In the end I want to define one single behaviour with a list of expected specifications it has to fulfil. And the cool...
Read more >do you ever block emails with no subject? - Cisco Community
I think this bait is trying to get people to reply back and catch valid email accounts. I think these are bots or...
Read more >RSpec Style Guide
Leave one empty line between feature , context or describe blocks. Do not leave empty line after the last such block in a...
Read more >1. Intro—What Is Expect? - Exploring Expect [Book] - O'Reilly
Expect is a program to control interactive applications. These applications interactively prompt and expect a user to enter keystrokes in response.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
or maybe rename the original
expect
toexpectThat
(expectThat("fnord").isLowerCase()
) , and use the block syntax likeit would also make tests nicer to read.
It’s also pretty easy to migrate to the new syntax by just defining a method
expect
that callsexpectThat
and then inlining that method. Also I agree about softly it’s just the first thing that came to mind.