Example of using bundler for path management.
bundle gem sinatra_gem_spec
Use bundler to make a gem scaffold
source 'https://rubygems.org'
gemspec
group :development, :test do
gem 'sinatra_gem_spec', :path => '.'
end
Specify the library as a gem in the current path for dev and test. When you run bundle
it will recognize the gem.
require 'rubygems'
require 'bundler/setup'
require 'sinatra_gem_spec'
run SinatraGemSpec::Server
Use bunder to load your app and then run it.
require 'rubygems'
require 'bundler/setup'
require 'capybara/rspec'
require 'sinatra_gem_spec'
Capybara.app = SinatraGemSpec::Server
Again, use bundler to load, then give capybara the server.
require "sinatra_gem_spec/version"
module SinatraGemSpec
autoload :Server, 'sinatra_gem_spec/server'
end
Server
will be the sinatra app. Autoload for speed when loading environment.
require 'sinatra'
class SinatraGemSpec::Server < Sinatra::Base
get '/' do
'hello world'
end
end
Basic sinatra app
require 'spec_helper'
describe SinatraGemSpec::Server, :type => :request do
it 'should say hello' do
visit '/'
page.should have_content('hello world')
end
end
Basic request spec.