grappa icon indicating copy to clipboard operation
grappa copied to clipboard

Conditional assertions for more fine-grained logic

Open tomas-fp opened this issue 8 years ago • 3 comments

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'])

tomas-fp avatar Apr 04 '17 12:04 tomas-fp

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

ab-anand avatar Sep 01 '18 18:09 ab-anand

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.

h2non avatar Sep 02 '18 08:09 h2non

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

ab-anand avatar Sep 03 '18 14:09 ab-anand