Skip to content

Instantly share code, notes, and snippets.

@leandrosilva
Created July 8, 2010 22:54
Show Gist options
  • Save leandrosilva/468767 to your computer and use it in GitHub Desktop.
Save leandrosilva/468767 to your computer and use it in GitHub Desktop.
Some snippets to build a Sinatra+Mongoid app
require 'init'
set :run, false
set :environment, :production
set :mongo_db, 'my_db'
run Sinatra::Application
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
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 }
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