Daniel Irvine on building software
RSpec expectations in loops
22 May 2014
In my last past, From C# to Ruby: Test assertions in loops, I mentioned that the following code is an RSpec antipattern:
But what about this?
describe your context do TRUTHS.each |t| do it returns true when running func_under_test with + t.to_s func_under_test?(t).should eq true end end end
This form is much better, because the correct number of expectations will be returned and easily understandable error messages will be returned in case of failure.