Skip to content

Instantly share code, notes, and snippets.

@djo
Created November 15, 2011 10:18
Show Gist options
  • Save djo/1366658 to your computer and use it in GitHub Desktop.
Save djo/1366658 to your computer and use it in GitHub Desktop.
Sinatra, Bundler, RSpec2 Example
# ./app.rb
get '/' do
'Sinatra'
end
# ./spec/app_spec.rb
require_relative "./spec_helper.rb"
describe "App" do
it "should be success" do
get '/'
last_response.should be_ok
end
it "should successfully return a greeting" do
get '/'
last_response.body.should eq('Sinatra')
end
end
# ./config.ru
require 'rubygems'
require 'bundler'
Bundler.require
require './app'
run Sinatra::Application
# ./Gemfile
source "http://rubygems.org"
gem "sinatra", "~> 1.3.1"
group :test do
gem "rspec", "~> 2.7.0"
gem "rack-test", "~> 0.6.1"
gem "fuubar", "~> 0.0.6"
end
# ./spec/spec_helper.rb
ENV['RACK_ENV'] = 'test'
require 'rubygems'
require 'bundler'
Bundler.require
require 'rack/test'
require_relative '../app.rb'
RSpec.configure do |conf|
conf.include Rack::Test::Methods
def app
Sinatra::Application
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment