Hi thanks for the awesome gem as always :)
I want to get spec's name(= context name?) inside let block but IDK if this is possible or not 馃 would help if you can answer 馃檶 thanks.
RSpec.describe Foo do
describe 'bar' do
context 'when something is happening' do
let(:spec_name) { # would be awesome if I can get "Foo bar when something is happening returns true" here }
it 'returns true' do
end
end
end
end
Hi @take
For sure it's possible:
let(:spec_name) do |example|
example.metadata[:full_description] # => "Foo bar when something is happening returns true"
end
I believe you can use the parameter for it
as well to get such information in the example itself.
There are much more other things that are accessible there.
You're always welcome!
aha thank you so much! 馃檶
@pirj
do you know which version of rspec-core includes this feature? :eyes:
in my rspec-core 3.9.2
app, I get the following error 馃
Failure/Error: example.metadata[:full_description]
NoMethodError:
undefined method `metadata' for nil:NilClass
@take Can you please provide a little more context what your code looks like?
The key is the do |example|
in let(:spec_name) do |example|
.
sorry problem is solved, thanks for the help! 馃檶