Created
July 8, 2010 22:54
-
-
Save leandrosilva/468767 to your computer and use it in GitHub Desktop.
Some snippets to build a Sinatra+Mongoid app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'init' | |
| set :run, false | |
| set :environment, :production | |
| set :mongo_db, 'my_db' | |
| run Sinatra::Application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source :rubygems | |
| source :rubyforge | |
| gem 'sinatra' | |
| gem 'sinatra-mongoid', :require => 'sinatra/mongoid' | |
| gem 'bson_ext' | |
| gem 'activesupport' | |
| group :test do | |
| gem 'rspec' | |
| gem 'rack-test' | |
| gem 'test-unit', '1.2.3' | |
| gem 'awesome_print' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'sinatra' | |
| require 'sinatra/mongoid' | |
| require 'active_support' | |
| # Set the not found page for URIs that don't match to any specified route. | |
| not_found do | |
| status 404 | |
| end | |
| # Set page of occoured a error (Internal Server Error). | |
| error do | |
| status 500 | |
| end | |
| # Load lib files. | |
| Dir["lib/**/*.rb"].each { |file| load file } | |
| # Load the application. | |
| Dir["app/**/*.rb"].each { |file| load file } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'spec' | |
| require 'spec/autorun' | |
| require 'spec/interop/test' | |
| require 'rack/test' | |
| require 'ap' | |
| require 'init' | |
| require 'data/xml' | |
| set :environment, :test | |
| set :run, false | |
| set :raise_errors, true | |
| set :logging, false | |
| module Sinatra | |
| module Test | |
| module App | |
| def app | |
| Sinatra::Application | |
| end | |
| end | |
| end | |
| end | |
| Spec::Runner.configure do |conf| | |
| conf.include Rack::Test::Methods | |
| conf.include Sinatra::Test::App | |
| end | |
| # To improve readability such as: | |
| # this { new_order.save! }.should raise_error Mongoid::Errors::Validations | |
| alias :this :lambda |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment