Errors RSpec while testing API
<p>just starting to learn RSpec and TDD, and can't figure out why it's don't work at all.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>#spec/api/event_api_spec.rb
describe 'Messages API' do
  it 'check response' do
    get 'api.mydomain.dev/events'
    json = JSON.parse(response.body)
    # test for the 200 status-code
    expect(response).to be_success
  end
end</code></pre>
</div>
</div>
</p>

<p>I have create my API on api.mydomain.dev and my folder structure looks like app/controllers/api/events_controller.rb</p>

<p>So when I tried to run bundle exec rspec it's shown that </p>

<pre><code>NoMethodError:
   undefined method `get' for #&lt;RSpec::ExampleGroups::MessagesAPI:0x007fc34900cee0&gt;
</code></pre>

<p>if I'm trying to make smth like Event.creat!(:name => 'My Event') in My Spec file #spec/api/event_api_spec.rb   it says</p>

<p><code>NameError:
       uninitialized constant Event</code> </p>

<p>So i don't understand How require my app/controllers/api/events_controller.rb file to the Spec file to get instance of my Event Class to get it work.</p>

<p>With default controllers it's work fine, I only interesting in API setup, thx</p>