Can I incrementally configure the test subject in nexted contexts?
<p>I'm new to Ruby and RSpec, and I'm looking for a way to incrementally configure the test subject in nested contexts.  The sort of thing I want to do is illustrated by the following, obviously contrived, example:</p>

<pre><code>describe "Array" do
  context "An array" do
    let (:array_length) do
      a = Array.new
      config_array a
      return a.length
    end

    context "with 1 element" do
      def config_array(arr)
        arr &lt;&lt; '1'
      end

      it "should have length 1" do
        expect(array_length).to eq(1) 
      end

      context "and an additional element" do
        def config_array(arr)
          arr &lt;&lt; '1'
          arr &lt;&lt; '2'
        end

        it "should have length 2" do
          expect(array_length).to eq(2)
        end

        context "and yet another additional element" do
          def config_array(arr)
            arr &lt;&lt; '1'
            arr &lt;&lt; '2'
            arr &lt;&lt; '3'
          end

          it "should have length 3" do
            expect(array_length).to eq(3)       
          end
        end
      end
    end
  end
end
</code></pre>

<p>The tests in this example pass, but I'd like to be able to do something like:</p>

<pre><code># snip      
      context "and an additional element" do
        def config_array(arr)
          parent_context_config_array arr
          arr &lt;&lt; '2'
        end

        it "should have length 2" do
          expect(array_length).to eq(2)
        end

        context "and yet another additional element" do
          def config_array(arr)
            parent_context_config_array arr
            arr &lt;&lt; '3'
          end
# snip      
</code></pre>

<p>Is there a simple way to do this?  Obviously the real test subject I'm working with is more complex than this.  I'm basically looking for a way to keep the code DRY while adding additional configuration to the test subject in nested contexts.</p>