Do you ALWAYS use "bundle exec rspec spec" tests?

I’m going through Michael Hartl’s Rails tutorial, and I am happy to report that (as of the end of section 7) I’m able to get things working. (That said, I skipped the section on automated testing, as Hartl warned that automated testing is the most likely part of his book to become outdated.)

There is a heavy emphasis on the “bundle exec rspec spec” tests. I agree that testing is a very necessary part of development. As I go through the rest of this tutorial, I will continue to test when instructed.

That said, how essential are the “bundle exec rspec spec” tests in most real world apps? My reasons for possibly not using them or not using them as thoroughly as the tutorial does:

  1. I still feel more comfortable testing by accessing my web site in the browser and trying things out as if I were one of my users.
  2. Creating the tests does add to the workload.
  3. Garbage in → garbage out: If you don’t write the proper tests, your results don’t matter but could cause you to needlessly obsess over something that actually works but you erroneously think is in error, or you could think something works when it doesn’t.

After I finish railstutorial.org, I will start my first Ruby on Rails web site, which will profile mutual funds and ETFs. How important is it that I do the “bundle exec rspec spec” testing as thoroughly as the tutorial does?

testing is important for when you try to introduce new features down the road or if you plan on refactoring your code. Its nice to have test that lets you know you didn’t break stuff. Imagine making a change and having to check every page in your app… not fun and time consuming. If you are making a small site, personal blog or something then yeah, don’t worry about it but if you plan on having user that use your product and you plan on introducing new feature to your project then test everything. It only helps :slight_smile:

Matt

I'm going through Michael Hartl's Rails tutorial, and I am happy to report that (as of the end of section 7) I'm able to get things working. (That said, I skipped the section on automated testing, as Hartl warned that automated testing is the most likely part of his book to become outdated.)

Don't skip it. The fact that the details may change does not alter the fact that testing is critical. The tutorial will give you the basics even if the details change over the years.

There is a heavy emphasis on the "bundle exec rspec spec" tests. I agree that testing is a very necessary part of development. As I go through the rest of this tutorial, I will continue to test when instructed.

That said, how essential are the "bundle exec rspec spec" tests in most real world apps? My reasons for possibly not using them or not using them as thoroughly as the tutorial does: 1. I still feel more comfortable testing by accessing my web site in the browser and trying things out as if I were one of my users.

That is ok when your site has 5 pages. What about when it has 100? Are you going to manually test everything every time you make a change.

2. Creating the tests does add to the workload.

Only in the short term. In the long term it will pay for itself.

3. Garbage in -> garbage out: If you don't write the proper tests, your results don't matter but could cause you to needlessly obsess over something that actually works but you erroneously think is in error, or you could think something works when it doesn't.

Obviously true. That just means that you have to do your best to design the tests well.

After I finish railstutorial.org, I will start my first Ruby on Rails web site, which will profile mutual funds and ETFs. How important is it that I do the "bundle exec rspec spec" testing as thoroughly as the tutorial does?

Vitally important. Apart from anything else it will allow you to sleep at night being reasonably confident that the change you made to the site today will not have messed up some other aspect of the site that you had not considered, so you will not wake up to an inbox full of messages from irate customers complaining.

Colin

RSpec tests are really quite necessary for a couple of reasons (there's a lot more, but these are crucial to me)

1) They let you test the various units of your code independent of other elements, which makes verifying them a lot easier 2) They give you a much better insight into your code when it is failing by providing a better means of seeing which parts actually fail.

External tests, such as driven from a web driver, are equally essential:

1) They ensure that the whole program is working together well (integration testing) 2) They test your program from the point of view of the user

Don't skip either, in any "real program" -- anything you plan on using beyond a learning exercise. Don't skip them on your learning exercises either, really, as it is a habit well engrained.

There are several reasons for this, but to me it involves addressing 3 questions:

1) what do you want? (the spec) 2) what will having that get you? (the problem this solves) 3) how will you know when you have it? (the tests)