Câu hỏi phỏng vấn Ruby on Rails
Câu hỏi

What exactly are Harnesses and Fixtures in the Ruby?

Câu trả lời

Fixtures and test harnesses are important concepts in Ruby on Rails testing:

Fixtures are sample data that you can use to populate your testing database before running tests. They are stored in YAML files, one file per model, in the test/fixtures directory[1][3]. Fixtures allow you to create predefined data to use in your tests, rather than having to create it manually each time[4].

For example, a fixture for an Article model might look like this[3]:

first:
  title: Welcome to Rails!
  category: about

This creates a fixture named first with a title and category attribute.

Test harnesses provide automation to run your tests. Rails includes a built-in test harness that allows you to run unit tests to verify individual components like models and controllers work correctly[5]. The test harness will automatically load fixtures into the test database before running tests[1]....

middle

middle

Gợi ý câu hỏi phỏng vấn

middle

Can you explain the difference between ActiveSupport’s HashWithIndifferentAccess and Ruby’s Hash ?

senior

How would you choose between Belongs_to And Has_one ?

middle

Mention what is the difference between calling super() and super call ?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào