2

I have an API that has many controllers and models.

I installed Rspec and every new resource I create, the corresponding test files are created automatically.

Is there a way to generate these files for all others old resources including REST tests?

For instance, I have a file costumers_controller.rb created before I install Rspec, is there a way to generate the default file costumers_controller_spec.rb?

2
  • This question has already been answered here: stackoverflow.com/questions/4235763/… Commented Aug 12, 2014 at 19:07
  • OK @mjhlobdell, but this only creates a file 'almost empty', I would like to have the code for all REST methods. Is there a way to do that? Commented Aug 12, 2014 at 19:15

2 Answers 2

3

I found the answer:

rails g rspec:scaffold controller_name

This generate also the request and routing file.

In order to generate the model just use:

rails g rspec:model model_name

And all test files will be ready to use.

Thanks.

Sign up to request clarification or add additional context in comments.

Comments

2

Generate a controller with simple spec examples for the specified actions:

rails g rspec:controller Posts index show create

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.