grappa
grappa copied to clipboard
Conditional assertions for more fine-grained logic
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'])
Hi @h2non , I wanted to work on it. Can you please tell me how should I approach it?
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.
Hey thanks @h2non I'm working on it :)