Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

update starts_with() and ends_with() assertions to support lists #24

Copy link
Copy link
@saturnboy

Description

@saturnboy
Issue body actions

Extend these assertions to support both lists and tuples (aka ordered collections), not just strings.

Currently starts_with() and ends_with() only support strings, like this:

assert_that('foo').starts_with('f')
assert_that('foo').ends_with('oo')

Add support for lists:

assert_that([1,2,3]).starts_with(1)
assert_that([1,2,3]).ends_with(3)

Add support for tuples:

assert_that((1,2,3)).starts_with(1)
assert_that((1,2,3)).ends_with(3)

Also, support multiple args (starts with the given sequence, or ends with the given sequence):

assert_that([1,2,3]).starts_with(1,2)
assert_that([1,2,3]).ends_with(2,3)
assert_that((1,2,3)).starts_with(1,2)
assert_that((1,2,3)).ends_with(2,3)

Lastly, we need to have a great error message for this failing case:

assert_that([1,2,3]).starts_with([1,2])
Reactions are currently unavailable

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.