notes 1 - Evanto/qna GitHub Wiki
Questions:
- How
dependent: :destroy
is used? - How to detect when to link to model tables via foreign key or an id (and what to use when)? Commands to do it?
- How do I view my Postgres DB? (both in console and with viewer)?
- What and why should I add to
spec/factories/answers.rb
in module 3 task (FactoryGirl)? A: Initials contents of the file:
FactoryGirl.define do
factory :answer do
body "MyText"
end
end
It should be:
FactoryGirl.define do
factory :answer do
body "Test answer"
association :question, factory: :question
end
end
For explanation see: Factory Girl Associations
Example found in: Dmitry Kolobaev's repo
Discussion
Прогнать тест answer: rspec spec/models/answer_spec.rb
Чтобы запустить 1 конкретный тест (спеку), а не весь файл, после названия теста через двоеточие указать номер строки it 'test' do
спеки, которую хотите запустить: rspec spec/models/answer_spec.rb:10
Run all tests with 1 command: bundle exec rspec
SO: RSpec - Is there a way to run all tests with one command?
SO: RSspec how to run a single test?
-
dependent: :destroy
отвечает за автоматическое удаление связанных моделей.
Postgres DB viewer: check out Valentina Studio, phpPgAdmi
linking db tables: you can link with question_id or ..
Findings: - Созданные в postgresql базы данных не будут находится в папке db. Чтобы узнать список БД: `psql -U [имя учетной записи Linux] -l
- to push a brunch with just
git push
in future, do:
git push --set-upstream origin Vetka_1
- Фикстуры - это тестовые данные (данные для тестирования)
- What is Factory Girl? Youtube Научись Rails: Factory Girl