0
votes

I have a good understanding of the differences between unit and intergration tests in RoR in theory. I'm using rspec and capybara to do a lot of testing on my site. What I don't understand is how do you run different tests? If I do

bundle exec rspec

it will run all of my specs in all of my spec folders (model, controller, views, integration, etc). If I want to run an integration test, is it as simple as ?

bundle exec rspec spec/integration

I know there are some differences between these types of test behind the scenes. Specifically this problem (which I also have) has me thinking about unit vs. integration: How to test for a redirect with Rspec and Capybara

What does Rails do differently when running integration tests? The solution posted in the above problem is

Checking for redirect is not supported in rspec-rails request specs, but is supported in Rails integration tests.

So how do I make one of my tests an integration test? Is it just a matter of putting it in the right spec folder?

1

1 Answers

0
votes

As I understand it rspec is designed specifically for unit testing purposes, thus you'll need to use something else for integration testing. The message seems it imply that Rails can do integration tests as well. I don't have any experience or knowledge of testing in rails alone, but I do know of the cucumber gem that is built very well for integration tests.

It has it's own domain specific language and other quirks you'll need to get used to but it should have the capability you're looking for.