Created
November 18, 2009 13:15
-
-
Save omgitsads/237833 to your computer and use it in GitHub Desktop.
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
# 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