O'Reilly logo

Rails, Angular, Postgres, and Bootstrap by David B. Copeland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Installing RSpec for Testing

Rails ships with Test::Unit as the default testing framework. Test::Unit is a fine choice, and demonstrates the concepts of testing in Rails quite well. Despite that, RSpec is quite popular among Ruby developers. An annual survey conducted by Hampton Catlin[47] shows that, of the developers polled, 69.4% prefer RSpec for testing.

While this is a good reason to become familiar with RSpec, it’s not the main reason we want to use it here. When we get to Writing Unit Tests for Angular Components, we’ll be using Jasmine for testing our JavaScript, and both Jasmine and RSpec share a similar syntax. Here’s an RSpec test:

 describe ​"a simple test"​ ​do
  it ​"should test something"​ ​do
  expect(number).to eq(10) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required