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

Conditional assertions for more fine-grained logic #35

Open
1 task
tomas-fp opened this issue Apr 4, 2017 · 3 comments
Open
1 task

Conditional assertions for more fine-grained logic #35

tomas-fp opened this issue Apr 4, 2017 · 3 comments

Comments

@tomas-fp
Copy link

tomas-fp commented Apr 4, 2017

New API method:

  • grappa.when
if grappa.when(should.be.os('centos')):
    'nginx' | should.be.running
    80 | should.be.listening
    'eth0' | should.have.interface

if not grappa.when(should.be.os('ubuntu')):
    'apache' | should.be.running
    8080 | should.be.listening

if '/opt' | grappa.when(should.path.exists):
    '/opt/foo' | should.directory.exists
    '/opt' | should.have.subdirectories(['log', 'app', 'run'])
@ab-anand
Copy link

ab-anand commented Sep 1, 2018

Hi @h2non , I wanted to work on it. Can you please tell me how should I approach it?

@h2non
Copy link
Member

h2non commented Sep 2, 2018

This is not a trivial feature. Basically, one idea to implement what is on the examples above would be maintaining a global state everytime grappa.when is invoked in order to change the assertions behavior: avoid them to raise an exception, and instead store it internally so grappa.when can evaluate it accordingly. Just an idea anyway.

@ab-anand
Copy link

ab-anand commented Sep 3, 2018

Hey thanks @h2non I'm working on it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants