Posted 2 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.

Example:

Copy
describe User do def build_user(attributes = {}) User.new(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: 'user@example.com' }.merge(attributes)) end it 'does something special' do # ... end end end end

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
about 1 month 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