Feedback on feature request

Hey all,

There is a feature request for rspec-core that I’d like to see some
opinions about. The idea is to be able to reference subjects and methods
defined with let() in parent groups from within the subject() and let()
methods in a child group. Two approaches are to use super or a block
argument:

describe “outer” do
subject { “outer thing” }
describe “inner with super” do
subject { super.gsub(“outer”,“inner”) }
end
describe “inner with block arg” do
subject { |outer_outer| outer_subject.gsub(“outer”,“inner”) }
end
end

The same would apply to let:

describe “outer” do
let(:thing) { “outer thing” }
describe “inner with super” do
let(:thing) { super.gsub(“outer”,“inner”) }
end
describe “inner with block arg” do
let(:thing) { |outer_thing| outer_thing.gsub(“outer”,“inner”) }
end
end

Please comment in the github issue:
https://github.com/rspec/rspec-core/issues/294 rather than in this
thread.

Cheers,
David

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs