Created
November 15, 2011 10:18
-
-
Save djo/1366658 to your computer and use it in GitHub Desktop.
Sinatra, Bundler, RSpec2 Example
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
# ./app.rb | |
get '/' do | |
'Sinatra' | |
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
# ./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 |
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
# ./config.ru | |
require 'rubygems' | |
require 'bundler' | |
Bundler.require | |
require './app' | |
run Sinatra::Application |
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
# ./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 |
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
# ./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