다음 코드는 작동하지 않지만, 최고의 나는 또한 내가 주제로 를 초기화 내부 맥락에서 지역 변수를 사용하려고Rspec에서 주변 컨텍스트의 주제에 액세스 할 수 있습니까?
context "this context describes the class" do
subject do
# described class is actually a module here
c = Class.new.extend(described_class)
c.some_method_that_has_been_added_through_extension
c
end
# ... testing the class itself here ...
context "instances of this class" do
subject do
# this doesn't work because it introduces a endless recursion bug
# which makes perfectly sense
subject.new
end
end
end
달성하기 위해 노력하고있어 보여,하지만 운. 내부 범위의 내 주제 정의 내에서 외부 범위의 주제에 액세스 할 수있는 방법이 있습니까? 분명히 내부 상황에 인스턴스 변수를 사용하는 대신 subject
하지만 subject.call
하지를 초기화 작동