Need some help understanding:
In
rspec-2, every example and example group comes with metadata
information like the file and line number on which it was declared,
the arguments passed todescribeandit, etc. This metadata can be
appended to through a hash argument passed todescribeorit, allowing
us to pre and post-process each example in a variety of ways.
https://github.com/rspec/rspec-core/blob/master/features/Upgrade.md — «Metadata!» section
I’d like to have the following shortcut:
describe 'DELETE destroy', :as => :admin do
it 'destroys...' do
# ...
end
end
for
describe 'DELETE destroy as admin' do
before { login_as :admin }
it 'destroys...' do
# ...
end
end
Is metadata-based example pre/post-processing appropriate in the case or it was made for «external» things like filtering?
I believe this should work:
spec_helper.rb
Then your spec should work as expected with the
:as => :adminoption. See also this article.