Created
November 28, 2010 00:30
-
-
Save MarkNijhof/718432 to your computer and use it in GitHub Desktop.
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 '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' |
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 ::File.dirname(__FILE__) + '/config/boot.rb' | |
run WebApplication |
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
task :spec do | |
require "rspec/core/rake_task" | |
RSpec::Core::RakeTask.new(:client) do |t| | |
t.pattern = "spec/**/*_spec.rb" | |
end | |
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
$: << 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' | |
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
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 |
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 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