ruby - Which style,lambda..should or expect..to, is preferred for testing expectations in RSpec? -


i have seen both styles used widely: #1 lambda { raise "boom" }.should raise_error , #2 expect { raise "boom" }.to raise_error. expect..to more reads better , hides creation of proc.

i looked @ rspec code , seems expect..to suggested, regularly come across libraries using lambda..should. expect..to newer , hence not "famous" yet?

expect used since rspec-2, lambda had used.

rspec "officially" recommends use expect , possible decide "obsolete" lambda syntax.

the lambda syntax used in of libraries started life in rspec1 days. haven't yet migrated (and why if still supported).

so, use expect instead of lambda.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -