Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: cb3d1e06be
Fetching contributors…

Cannot retrieve contributors at this time

file 83 lines (57 sloc) 2.18 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<h2>This is a neat Sinatra template!</h2>

<pre>
This is the source code for the sinatra-template project on github.
It's the basic structure I use for my Sinatra projects and it make things a bit more organized.

What's inside?
--------------

* Modular Sinatra app version 1.3.2 using ruby 1.9.3@p125
* minitest for unit-level tests
* rack-test for routes tests
* capybara + minitest for integration tests (no need for rspec)
* yard for documentation
* Rakefile, Gemfile, .rvmrc, .gitignore

Folders Structure
------------------

    app.rb # require sinatra, vendor'd gems, models/init, routes/init, helpers/init

    helpers/
      init.rb # Require each helper file
      helper1.rb # Related helper methods

    models/
      init.rb # Require each model, in controlled order
      user.rb # model
      picture.rb # model

    routes/
      init.rb # Require each route, in controlled order
      user.rb # One or more routes related to some feature
      admin.rb # One or more routes related to administration

    views/
      layout.erb # Common layout
      index.erb # Specific view

    test/
      models # minitest
      routes # rack-test
      interaction # capybara + minitest

Setup
-----

Install Ruby 1.9.3 (if necessary). RVM is optional, but highly recommended

    rvm install ruby-1.9.3-p125
    git clone https://github.com/oren/sinatra-template.git
    cd sinatra-template (it will create sinatra-template gemset)

[Install QT](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-QT) (needed for capybara-webkit)

Install bundler

    gem install bundler

Install the gems

    bundle install --without production staging

View all available rake commands

    rake -T

    rake # Run all tests
    rake test:acceptance # Run acceptance tests
    rake test:models # Run models tests
    rake test:routes # Run routes tests
    rake yard # Generate YARD Documentation

Run the server

    shotun

Go to [http://127.0.0.1:9393](http://127.0.0.1:9393)
</pre>

<p><%= @flash %><p>

<%= erb :my_partial %>
Something went wrong with that request. Please try again.