question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does it make sense to have an expect block with no subject?

See original GitHub issue

Currently 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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
christophsturmcommented, Sep 6, 2018

or maybe rename the original expect to expectThat (expectThat("fnord").isLowerCase()) , and use the block syntax like

expect {
  that("fnord").isLowerCase()
  that("FNORD").isUpperCase()
}

it would also make tests nicer to read.

0reactions
christophsturmcommented, Sep 7, 2018

It’s also pretty easy to migrate to the new syntax by just defining a method expect that calls expectThat and then inlining that method. Also I agree about softly it’s just the first thing that came to mind.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found