Posted 12 months ago. Visible to the public. Repeats.

When defining methods in specs, you can super into previous definitions

When you def methods in RSpec tests, you can use super to call a method definition that was created in a surrounding describe/context block.


describe User do def build_user(attributes = {}) end describe '#my_method' do it 'does something' do # ... end context 'when the user has an e-mail address' do def build_user(attributes = {}) super({ email: '' }.merge(attributes)) end it 'does something special' do # ... end end end end
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Arne Hartherz
Last edit:
11 months ago
by Judith Roth
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more