V
V
Vasily Ivanov2022-02-28 21:40:17
ruby
Vasily Ivanov, 2022-02-28 21:40:17

I don't understand how to test a method in a rails model?

I have a method

def self.test(test_id)
    Admin.joins(:test_roles).where('admins_role.test_id = ?', test_id)
  end


I want to test with rspec and don't understand how to do it
In the Admin model there is:
has_and_belongs_to_many :test_roles  {join_table: :admins_role, class_name: 'Role'}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vayladion Gognazdiak, 2022-03-22
@etspring

What model method? Admin?
If yes, then saw the sinter

describe Admin do
   it '#self.test' do
       expect(described_class.test(zalupa_id)).to eq('ya_obeshau_chitat_dokumentaciu')
   end
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question