Last active
August 29, 2015 14:16
-
-
Save coreyhaines/db2257c18549b6f87c1e to your computer and use it in GitHub Desktop.
Using super() in rspec's subject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Phew! Turns out this was generated by transpec, not by a human! | |
before do | |
@admin = User.create(username: "user", password: "password", password_confirmation: "password") | |
end | |
subject{ @admin } | |
describe '#remember_token' do | |
subject { super().remember_token } | |
it { is_expected.not_to be_blank } | |
end |
Why not name the subject? Does that not work across context boundaries?
subject(:admin){ @admin }
# ...
subject(:token) { admin.remember_token }
Okay, turns out that this is a result of running transpec. I'm glad to hear nobody actually wrote this. :)
But, in general, my personal style hasn't evolved to using explicit subject / it. I'm pretty old school. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
explicit
subject
has done nothing but harm the readability of my specs imohell, the use of
subject
at all is just weird and foreign to me.