Save 36% for Black Friday! Learn more

New Discussion

Notifications

You’re not receiving notifications from this thread.

How do I find on an object in an api/v1/controller requested spec?

0
Testing

Hi there, this my first question =), am so happy!.... =)

I have a this:

RSpec.describe Api::V1::Controller, type: :request do
  describe 'on initialize' do
    let(:thing) { FactoryBot.create(:thing, :trait) }

    before { sign_in }

    it 'is named' do
      get '/api/v1/controller#index'
      expect(@controller.view_assigns["name_of_the_thing"]).not_to be_empty
    end
  end
end

I know controller_assigns is not correct, I know assigns is deprecated, I know about instance_variables but they do not find what I look for, I need the variables in the controller managed by the index method, I do not know how to get them. I cannot add gems.

Thank you guys, please correct me, in the way of ask or stuff, thank you so much! =)

Join the discussion
Create an account Log in