Zia Qamar
Zia Qamar

Reputation: 1775

How to access instance variable in rails minitest?

I have following code of line in my controller file

@filters[:temp] = Job.find_all_for_referrals(@company_id, @filters[:from_time], @filters[:to_time], @filters[:temp_id])

When i try to access this variable in my test with assigns(filters) or assigns(filters[:temp]) then it says

undefined local variable or method `filters'

Is there anything that i am doing wrong or there is some other way to access filters variable in test environment ?

Upvotes: 0

Views: 1308

Answers (1)

Petr Gazarov
Petr Gazarov

Reputation: 3821

assigns expects a symbol as an argument, and you are passing it a variable filters that is not defined in the current scope.

This should solve your issue:

assigns(:filters)

assigns(:filters)[:temp]

Upvotes: 2

Related Questions