Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSimon Walsh
Courses Plus Student 1,741 PointsUse of curly braces versus parenthesis with "expect"
Could someone explain the difference between passing a code block to expect such as...
expect{todo_item.toggle_completion!}.to change { todo_item.completed_at }
and passing and argument to expect....
expect(todo_item.completed?).to be_true
I apologise if this question is somewhat basic....
Simon
1 Answer
Dennis Brown
28,742 PointsI know this is old, but I had this same question.
While I am not sure on the actual specifics yet I found after some tests that using braces returns the actual output of the method, where the parens sends back a single value defining the result.