Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Preconfigured sinatra template with essentials like: HAML, ActiveRecord, Rspec testing suite
CSS Ruby
branch: master


latest commit ad5cf034f8
@shell authored
Failed to load latest commit information.
config integrity
db Initial commit
public Initial commit
spec Initial commit
views Initial commit
.autotest Initial commit
.gitignore Initial commit
.rvmrc Initial commit
.travis.yml fffffuuuuuu
Gemfile Test
Gemfile.lock erererer Added code climate badge
Rakefile integrity
app.rb Added log/ creation if not exist
ci.rake integrity Initial commit
helpers.rb Initial commit
models.rb Initial commit

Sinatra Template Build Status Code Climate


Recently I found myself doing a very simple services for my cliens with Sinatra. There is a lot of guides, tutorials and FAQs around the internet. But it seems that there is no good Sinatra template with testing coverate, basic files structure, etc. So I made one.


  • HTTP basic authentication
  • ActiveRecord orm
  • Sqlite3 for development, Mysql2 for production
  • 2 very basic but associated models
  • HAML, blueprint, jquery
  • User and Admin interfaces
  • Scroller with products
  • Full rake tasks for db management(hacked sinatra-activerecord gem)
  • Testing suite out of the box(RSpec)
  • Some essential Rails helpers
  • Ready for deploy with passenger(/config/setup_load_paths.rb)

    You can switch environments with RACK_ENV=test If you have old version of rake installed in gemset, you need to prepend all rake commands with bundle exec

    Some prefer to extract controllers, models, helpers in corresponding folders and split them over files. It is a matter of taste, bit if you have a lot of files, consider using Rails instead.


  • HAML
  • jquery
  • blueprint
  • basic forms for models
  • kitten placeholders - everything is better with bluetooth(or Kittens)


  • link_to - it is not full copy of Rails's link_to, this version produces only anchor tag with parameters
  • in_groups_of - iteration over collection by groups
  • options_for_select


$ rake -T

rake db:create
rake db:create_migration
rake db:drop
rake db:migrate
rake db:reset
rake db:rollback
rake db:seed


$ git clone
$ cd sinatra-template
$ rake db:create && rake db:migrate
$ ruby app.rb


Testing suite include overall application behaviour(/spec/app_spec.rb) and model specific testing(products_spec.rb, categories_spec.rb). Specific test include unit testing for model and actions tests for app

Do not forget to create and migrate testing database before:

$ RACK_ENV=test rake db:create
$ RACK_ENV=test rake db:migrate

Run tests once

$ rspec spec/

Autotest friendly

$ ./autotest

Testing coverate generated with SimpleCov flavor

  $ open coverage/index.html


Deploy it as regular rack/rails application. Just point root to /app/public and set RACK_ENV variable


  • additional essential rails helpers
  • might need to use a Spork


Vladimir Penkin

Something went wrong with that request. Please try again.