Skip to content

Instantly share code, notes, and snippets.

@MarkNijhof
Created November 28, 2010 00:30
Show Gist options
  • Save MarkNijhof/718432 to your computer and use it in GitHub Desktop.
Save MarkNijhof/718432 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'bundler'
SINATRA_ENV = ENV["RACK_ENV"] ||= "development" unless defined? SINATRA_ENV
SINATRA_ROOT = File.dirname(__FILE__) + '/..' unless defined? SINATRA_ROOT
begin
# Require the preresolved locked set of gems.
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
# Fallback on doing the resolve at runtime.
require 'rubygems'
require 'bundler'
Bundler.setup()
end
Bundler.require(:default, SINATRA_ENV.to_sym)
puts "=> Located Gemfile for #{SINATRA_ENV}"
require 'haml'
require './lib/web_application'
require ::File.dirname(__FILE__) + '/config/boot.rb'
run WebApplication
task :spec do
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:client) do |t|
t.pattern = "spec/**/*_spec.rb"
end
end
$: << File.join(File.dirname(__FILE__), '..', 'lib') # File.join(File.dirname(__FILE__), '..', 'myapp.rb')
require 'rubygems'
require 'sinatra'
require 'haml'
require 'rack/test'
require 'rspec'
# set test environment
set :environment, :test
set :run, false
set :raise_errors, true
set :logging, false
require './config/boot.rb'
class WebApplication < Sinatra::Base
configure do
set :public, './public'
set :haml, :format => :html5
end
get '/' do
File.read(File.join('public', 'index.html'))
end
get '/blog/index' do
haml :'root/index', :title => "Cre8ive Thought"
end
end
require File.dirname(__FILE__) + '/spec_helper'
describe "WebApplication" do
include Rack::Test::Methods
def app
@app ||= WebApplication
end
it "should respond to /" do
get '/'
last_response.should be_ok
last_response.body.should == 'Hello'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment