Another workaround would be to catch the exception generated when the expectation fails and then write out something to a file. This isn’t really that great of a solution either:
describe security_policy do
it 'has password complexity enabled' do
security_policy.PasswordComplexity.should_not be 0
rescue Exception => e
File.write('A.txt','PasswordComplexity is disabled')
This is an example of how you could intercept the exception generated from the failure, write out a file upon failure, and then continue to raise the exception up the stack so that the example fails.
This does not include the logic if one passes and the other does not. I assume that these may be tied together so you might not need to worry about that but if you did, you would likely have to combine both of these expectations, maintain some state (hard if the expectations are run in a random order), or do some introspection on RSpec to see if the other example has failed.
I don’t recommend this as a long term solution or something that you would want to litter throughout your controls but wanted to give you something that you could possibly use if you must have this feature.