Skip to content

Instantly share code, notes, and snippets.

@omgitsads
Created November 18, 2009 13:15
Show Gist options
  • Save omgitsads/237833 to your computer and use it in GitHub Desktop.
Save omgitsads/237833 to your computer and use it in GitHub Desktop.
# Application
class App < Sinatra::Base
set :hi, "Hello"
configure :test do
set :hi, "Hello There!"
end
end
# Registering a extention
module App
class Hi
def self.registered(app)
if app.test?
app.set :hi, "Hello There!"
else
app.set :hi, "Hello"
end
end
end
end
class App < Sinatra::Base
register App::Hi
end
# Rspec Tests
# You need to include Rack::Test::Methods so you get like be_nil etc
Spec::Runner.configure do |conf|
conf.include Rack::Test::Methods
end
Sinatra::Base.set :environment, :test
# You can overide settings like this too
# Sinatra::Base.set :hi, "Hi There!"
describe App do
def app
@app ||= App
end
it "should be in environment test" do
app.environment.should == :test
end
it "should say 'Hello There!'" do
app.hi.should == "Hello There!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment