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

More natural language matchers #179

Open
jocutajar opened this issue Jan 20, 2021 · 6 comments
Open

More natural language matchers #179

jocutajar opened this issue Jan 20, 2021 · 6 comments
Labels
ACCEPTABLE Pull requests are welcome!

Comments

@jocutajar
Copy link

Related to #87

I'd like to write

The path /x/y/z should exist
The path /x/y/z should be a file
The path /x/y/z should have setguid

Currently I have to write

The path /x/y/z should be exist
The path /x/y/z should be file
The path /x/y/z should has setguid

Which is feels awkward considering the otherwise neat English definition.

@ko1nksm ko1nksm added the ACCEPTABLE Pull requests are welcome! label Jan 20, 2021
@ko1nksm
Copy link
Member

ko1nksm commented Jan 20, 2021

Thanks!

@robert-gurol-signavio
Copy link
Contributor

robert-gurol-signavio commented Aug 3, 2021

This was just merged - "should exist" will soon be available.
#233

Also, there is this discussion #221 - pointing out that "should be a file" also works. :)
... and there are other issues like #178

@robert-gurol-signavio
Copy link
Contributor

robert-gurol-signavio commented Aug 3, 2021

should have setguid

This could actually be quite easy to add - have a look at shellspec/lib/core/matchers/has.sh.

I think I can give it a try.
EDIT: #235

@kamok
Copy link

kamok commented Nov 23, 2021

Did this feature regress somehow? I'm very confused when trying to write my spec:

This test:
The file '/tmp/repo/dummy.ts' should exist

Fails:

The file /tmp/repo/dummy.ts should exist

            Unknown word 'exist' after should verb. The correct word is one of the following.

              be, end, equal, eq, has, include, match, start,
              satisfy

In the reference document, should exist is recommended.

I'm also using latest:

shellspec --version
0.28.1

@LukeSavefrogs
Copy link
Contributor

LukeSavefrogs commented Nov 11, 2022

Did this feature regress somehow? I'm very confused when trying to write my spec:

This test: The file '/tmp/repo/dummy.ts' should exist

Fails:

The file /tmp/repo/dummy.ts should exist

            Unknown word 'exist' after should verb. The correct word is one of the following.

              be, end, equal, eq, has, include, match, start,
              satisfy

In the reference document, should exist is recommended.

I'm also using latest:

shellspec --version
0.28.1

I have the same problem (0.28.1).

Currently ONLY should be a file works!

$ shellspec --version
0.28.1

My test

Describe "Test"
	Describe "'Old' syntax"
		Example "should be exist"
			The path "${LIBRARY_PATH}" should be exist
		End
		Example "should be file"
			The path "${LIBRARY_PATH}" should be file
		End
		Example "should not has setgid"
			The path "${LIBRARY_PATH}" should not has setgid
		End
	End

	Describe "Natural language"
		Example "should exist"
			The path "${LIBRARY_PATH}" should exist
		End
		Example "should be a file"
			The path "${LIBRARY_PATH}" should be a file
		End
		Example "should not have setuid"
			The path "${LIBRARY_PATH}" should not have setuid
		End
	End
End

Output

As you can see should exist and should not have setuid fail the tests here:

image

@LukeSavefrogs
Copy link
Contributor

LukeSavefrogs commented Nov 14, 2022

I finally figured it out...
This feature did not regress. It just never came out as a release. 😀

The PR #233 introducing the should exist syntax was merged in 3 August 2021 on the master branch, while the latest release (0.28.1) dates back to 1 January 2021.

As said by @ko1nksm in #240, the feature is not yet available:

It is not a typo, a change in the next version. See #233.
Note that the master contains the latest updates.

⚠ Workaround

To use this feature you would have to switch to the master branch.

This however could lead to potential problems, since the master branch could have bugs (it's the development branch). So do it at your own risk (and if you absolutely MUST).

The command to get the latest features is the following:

curl -fsSL https://git.io/shellspec | sh -s -- master --switch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ACCEPTABLE Pull requests are welcome!
Projects
None yet
Development

No branches or pull requests

5 participants