O'Reilly logo

Rails, Angular, Postgres, and Bootstrap, 2nd Edition 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.

While this is a good reason to become familiar with RSpec, it’s not the main reason we want to use it here. When you get to Writing Unit Tests for Angular Components, you’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)
 end
 end

Here’s that same test in Jasmine:

 describe(​"a simple test"​, ​function​() {
  it(​"should test something" ...

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