次のコードは動作しませんが、それは最高の私はまた私が対象と を初期化し、内部コンテキスト内のローカル変数を使用しようとした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
ではない、それを初期化している作品