You can check validation for an instance, not for the class itself:
it "should be invalid without a name" do
category = build(:category, name: "some name", permalink: "some link")
expect{ category.name = nil }.to change{ category.valid? }.to false
end
Validation of permalink presence in your code is excessive.
The before_validation
callback will provide non-blank value for the permalink before validation. That's why validation of permalink will never fail.