Created
February 2, 2012 14:53
-
-
Save yknd/1723816 to your computer and use it in GitHub Desktop.
sample sinatra application with haml, sass and rspec.
This file contains 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
Autotest.add_hook(:initialize) {|at| | |
at.add_exception %r{^\.git} | |
at.add_exception %r{^./tmp} | |
at.add_mapping(%r{^lib/.*\.rb$}) {|f, _| | |
Dir['spec/**/*_spec.rb'] | |
} | |
nil | |
} |
This file contains 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
.sass-cache/ |
This file contains 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
-c | |
-fs |
This file contains 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
Test | |
$ autotest | |
Run | |
$ rackup -s thin | |
This file contains 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 'bundler/setup' | |
Bundler.require(:default) | |
class MyApp < Sinatra::Base | |
set :root, File.expand_path('../../', __FILE__) | |
set :haml, format: :html5 | |
set :haml, escape_html: true | |
configure :development do | |
register Sinatra::Reloader | |
end | |
get '/' do | |
haml :index | |
end | |
end |
This file contains 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 'spec_helper' | |
describe MyApp do | |
context "when get '/'" do | |
before do | |
get '/' | |
end | |
subject { last_response } | |
its(:status) { should == 200} | |
its(:body) { should include('Hello World!!')} | |
end | |
end |
This file contains 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
$:.unshift File.join(File.dirname(__FILE__), 'lib') | |
require 'bundler' | |
Bundler.require | |
require 'app' | |
run MyApp |
This file contains 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 | |
gem 'sinatra', require: 'sinatra/base' | |
gem 'sinatra-reloader', require: 'sinatra/reloader' | |
gem 'thin' | |
gem 'haml' | |
gem 'sass' | |
group :test do | |
gem 'rspec' | |
gem 'rack-test', require: 'rack/test' | |
end |
This file contains 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
GEM | |
remote: http://rubygems.org/ | |
specs: | |
backports (2.3.0) | |
daemons (1.1.6) | |
diff-lcs (1.1.3) | |
eventmachine (0.12.10) | |
haml (3.1.4) | |
rack (1.4.1) | |
rack-protection (1.2.0) | |
rack | |
rack-test (0.6.1) | |
rack (>= 1.0) | |
rspec (2.8.0) | |
rspec-core (~> 2.8.0) | |
rspec-expectations (~> 2.8.0) | |
rspec-mocks (~> 2.8.0) | |
rspec-core (2.8.0) | |
rspec-expectations (2.8.0) | |
diff-lcs (~> 1.1.2) | |
rspec-mocks (2.8.0) | |
sass (3.1.12) | |
sinatra (1.3.2) | |
rack (~> 1.3, >= 1.3.6) | |
rack-protection (~> 1.2) | |
tilt (~> 1.3, >= 1.3.3) | |
sinatra-contrib (1.3.1) | |
backports (>= 2.0) | |
eventmachine | |
rack-protection | |
rack-test | |
sinatra (~> 1.3.0) | |
tilt (~> 1.3) | |
sinatra-reloader (1.0) | |
sinatra-contrib | |
thin (1.3.1) | |
daemons (>= 1.0.9) | |
eventmachine (>= 0.12.6) | |
rack (>= 1.0.0) | |
tilt (1.3.3) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
haml | |
rack-test | |
rspec | |
sass | |
sinatra | |
sinatra-reloader | |
thin |
This file contains 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
%h1 Hello World!! |
This file contains 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
!!! | |
%html | |
%head | |
%title My App | |
%link{rel: 'stylesheet', media: 'screen', href: '/css/myapp.css'} | |
%script{type: 'text/javascript', src: '/js/myapp.js'} | |
%body!= yield |
This file contains 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
h1 { | |
margin: 0; | |
color: #000; | |
text-shadow: 1px 1px 2px #555; } |
This file contains 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
// MyApp's javascript file |
This file contains 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
h1 { | |
margin: 0; | |
color: #000; | |
text-shadow: 1px 1px 2px #555; | |
} | |
This file contains 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 'bundler/setup' | |
Bundler.require(:default, :test) | |
require 'app' | |
module MyTestModule | |
def app | |
MyApp | |
end | |
end | |
RSpec.configure do |config| | |
config.include Rack::Test::Methods | |
config.include MyTestModule | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment