All threads / How do I find on an object in an api/v1/controller requested spec?
Ask A Question

Notifications

You’re not receiving notifications from this thread.

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

Diego Mota asked in 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

Want to stay up-to-date with Ruby on Rails?

Join 62,791+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.