Sinatra Basics : Running Rspec Tests and Sinatra Console


To learn how to use rake to run all rspec tests in a Sinatra application and to create your own Sinatra console.


Step 1

Create Rakefile:

  require 'rspec/core/rake_task'

  task :default => :spec
rescue LoadError
  # no rspec available

Step 2

Now you can run all the tests by running the rake command.


Step 3

Console for Sinatra application:

desc "Open an irb session preloaded with your model"
task :console do
  require 'active_record'
  require './app/models/article.rb'
  require 'irb'

Step 4

To experiment in a Sinatra console:

$rake console


In this article, you learned how to run all tests using a rake task and how to create your own Sinatra console similar to rails console.


Rake Task Command Line

Related Articles

Ace the Technical Interview

  • Easily find the gaps in your knowledge
  • Get customized lessons based on where you are
  • Take consistent action everyday
  • Builtin accountability to keep you on track
  • You will solve bigger problems over time
  • Get the job of your dreams

Take the 30 Day Coding Skills Challenge

Gain confidence to attend the interview

No spam ever. Unsubscribe anytime.