Skip to content

Instantly share code, notes, and snippets.

View kematzy's full-sized avatar

Kematzy kematzy

View GitHub Profile
# Example of how to use multiple Routes in external files/modules
require 'rubygems'
require 'sinatra/base'
# set the root of the whole app
APP_ROOT = File.dirname(File.expand_path(__FILE__)) unless defined?(APP_ROOT)
require "sinatra-external_routes_example"
### NB!! This file is run within a directory and I've made it into a Git repo, so that each revision is saved.
# Commented out for now.
require "rubygems"
%w(dm-core dm-validations dm-types dm-timestamps dm-is-list dm-is-tree dm-is-paginated).each {|lib| require lib }
# DataMapper::Logger.new(STDERR, :debug)
$dm_log_file = "#{File.dirname(__FILE__)}/dm.album.test.log"
# demo/app.rb
# set the root of the whole app
::APP_ROOT = File.dirname(File.expand_path(__FILE__)) unless defined?(APP_ROOT)
class MyApp < Sinatra::Base
# snip set views etc
set :environment, ENV["RACK_ENV"] ||= 'test'
### NOTE!! Store this file in the
#
# github.com/datamapper/dm-more/tree/next # Next branch
# |
# |--> dm-is-list/spec/integration
require 'pathname'
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
### ActiveRecord => ActsAsList vs DataMapper => dm-is-list
# Scenario Setup:
## ActiveRecord:
create_table :albums do |t|
t.column :name, :string
t.column :position, :integer
t.column :parent_id, :integer, :default => 0
require 'pathname'
require 'rubygems'
gem 'rspec', '~>1.2'
require 'spec'
# gem 'data_objects', '0.9.12'
gem('data_objects', '~>0.9')
require 'data_objects'
# gem 'do_sqlite3', '0.9.12'
require 'rubygems'
require 'spec'
require 'spec/interop/test'
# require 'test/spec'
require 'sinatra/base'
require 'rack/test'
class Dummy < Sinatra::Base
set :public, 'public'
### QUESTION:: Why does this behave in this way ??
#
# Summary:
#
# When adding a Sinatra Extension with instance variables that are essentially buffers during the request
# the new values does NOT get added to the instance variable.
#
# Key Issues:
#
# * Compare using 'app' vs '@app' in the tests below.
# An example of how to use mounted apps and stil have acces to full paths within the apps.
#
# Created by Kematzy [ 2009-07-10 ]
require 'rubygems'
require 'sinatra/base'
# set the root of the whole app
APP_ROOT = File.dirname(File.expand_path(__FILE__)) unless defined?(APP_ROOT)
class MyApp < Sinatra::Base
# ....
# does nothing other than load the <input type="file"> form...
get '/upload' do
erb(:upload)
end