Challenge 1: A Model Spec — Solution # spec/models/post_spec.rb RSpec.describe Post, type: :model do it "is invalid without a title" do post = Post.new(title: nil) expect(post).to_not be_valid end it "belongs to a user" do expect(Post.reflect_on_association(:user).macro).to eq(:belongs_to) end end =begin Notes: - Post.new(title: nil) builds an in-memory record without saving it -- valid? runs the validations without touching the database, which is all this example needs. - be_valid is RSpec's auto-generated matcher for the valid? predicate method every ActiveRecord model has; to_not be_valid calls post.valid? and expects false. - reflect_on_association(:user) inspects Post's declared associations without needing an actual saved record -- .macro returns the association type (:belongs_to, :has_many, etc.) as a symbol, which is compared directly against what the model is expected to declare. - Each example checks exactly one rule, matching the chapter's model-spec example (one for validates presence, one for belongs_to). =end