O'Reilly logo

Instant RSpec Test-Driven Development How-to by Charles Feduke

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

Writing ActiveRecord specifications (Intermediate)

Continuing with the previous recipe, we will see how to write ActiveRecord specifications here.

How to do it...

  1. Create a model to represent the Location class that we've already developed:
    $ rails g model location latitude:decimal longitude:decimal
    

    Note

    g is the shortened form of generate.

  2. Create and migrate the environments:
    $ rake db:create:all && rake db:migrate && rake db:test:clone
    
  3. This creates databases and then migrates the schema of the default development environment. In addition, it also clones the development database structure to the test database. Using && between commands will run each command in succession, provided that the previous command does not fail. You can alternatively enter ...

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