optional relation + RSpec w/shoulda-matchers
October 13, 2020
User 1 - 0..1 Laptop
- Model
a/m/user.rb has\_one :laptop
a/m/laptop.rb belongs_to :user, optional: true
- spec
*ruby
s/m/laptop\_spec.rb
it \{ should belong\_to(:user).optional }*
User 1 - 0..1 Laptop
a/m/user.rb
has\_one :laptop
a/m/laptop.rb belongs_to :user, optional: true
- spec
*ruby
s/m/laptop\_spec.rb
it \{ should belong\_to(:user).optional }*
We use leading dot notation a lot now e.g.
Sometimes you want to use Ruby's Heredoc without interpolation ('#{....}'). You can do this by adding single dashes around your keyword:
All intermediate-level hashtables will be created automagically