Skip to content

HTTPS clone URL

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

integrity

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
README.md Added code climate badge
Rakefile integrity
app.rb Added log/ creation if not exist
ci.rake integrity
config.ru Initial commit
helpers.rb Initial commit
models.rb Initial commit

README.md

Sinatra Template Build Status Code Climate

About

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.

App

  • 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.

HTML

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

Helpers

  • 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

$ rake -T

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

Installation

$ git clone https://github.com/shell/sinatra-template.git
$ cd sinatra-template
$ rake db:create && rake db:migrate
$ ruby app.rb

Testing

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

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

Todo

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

Author

Vladimir Penkin

Something went wrong with that request. Please try again.