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

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

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