Not able to access variables in RSpec test
<p>I am trying to run some sample <code>RSpec</code> examples from an ebook but it looks the book is having older version of <code>RSpec</code> hence some examples are referencing old <code>RSpec API</code> which is creating problems. I am trying to resolve them as much as I can but since I am new to <code>Ruby</code> &amp; <code>RSpec</code> its a little challenging for me. </p>

<p>From the error log I can figure out that it's a scoping problem but not sure how to resolve it.</p>

<p>Is <code>subject</code> still a part of rspec 3.4.2 version?  </p>

<pre><code>$rspec --version
3.4.2
</code></pre>

<p><strong>DOES NOT WORK</strong> </p>

<pre><code>require "spec_helper"
describe Location do
    describe "#initialize" do
        subject { Location.new(:latitude =&gt; 38.911268, :longitude =&gt; -77.444243) } 
        expect(:latitude).to eq(38.911268)
        expect(:longitude).to eq(-77.444243)
    end
end
</code></pre>

<p><strong>Error Log:</strong></p>

<blockquote>
  <p><code>method_missing</code>: <code>expect</code> is not available on an example group (e.g. a <code>describe</code> or <code>context</code> block). It is only available from within individual examples (e.g. <code>it</code> blocks) or from constructs that run in the scope of an example (e.g. <code>before</code>, <code>let</code>, etc). (RSpec::Core::ExampleGroup::WrongScopeError)</p>
</blockquote>