How to remove duplication for similar behaviour?


On a website I created the is two commentable model, “project” and “actuality”. You can view pages here : and here : (only in french for the momeent).

At the end of each page there is a form to create a new comment and a list for all comments. They have the same behaviour and they use the same partials. My problem is for specs. I created two specs. Here : and here : There is a duplication and I want, if it’s possible, to have only one spec for this.

I tried to create an engine but I’m not satisfied. The behaviour is really related to my application. For example, I have this inherited routes like this :

resources :actualities do
resources :comments

resources :projects do
resources :comments

If I try to put only “resources :comments” it break my controller’s code. To find the related model I must to add the class name into the params. I didn’t find another solution and I think it’s uggly.

Do you have and Idea? Is it better to have two specs for a similar feature or is it better to remove an spec and keep the other?

Thanks for your help!