Instead of 'parent_id' you can use the column name ancestry uses to store the parent's id which is 'ancestry' by default. You can change the name by setting it as option to the has_ancestry
class method, e.g. has_ancestry(ancestry_column: :parent_id)
.
Your modified test code would look as follows:
assigns(:category).should be_a_new(Category).with(ancestry: root_category.id.to_s)