2014-05-09 02:39:16 -04:00
|
|
|
require 'spec_helper'
|
2011-03-25 19:13:26 -04:00
|
|
|
|
2022-02-05 07:27:48 -05:00
|
|
|
RSpec.describe Sinatra::Extension do
|
2011-03-25 19:13:26 -04:00
|
|
|
module ExampleExtension
|
|
|
|
extend Sinatra::Extension
|
|
|
|
|
|
|
|
set :foo, :bar
|
|
|
|
settings.set :bar, :blah
|
|
|
|
|
|
|
|
configure :test, :production do
|
|
|
|
set :reload_stuff, false
|
|
|
|
end
|
|
|
|
|
|
|
|
configure :development do
|
|
|
|
set :reload_stuff, true
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/' do
|
|
|
|
"from extension, yay"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
before { mock_app { register ExampleExtension }}
|
|
|
|
|
2016-05-10 10:08:54 -04:00
|
|
|
it('allows using set') { expect(settings.foo).to eq(:bar) }
|
|
|
|
it('implements configure') { expect(settings.reload_stuff).to be false }
|
2011-03-25 19:13:26 -04:00
|
|
|
|
|
|
|
it 'allows defing routes' do
|
2016-05-10 10:08:54 -04:00
|
|
|
expect(get('/')).to be_ok
|
|
|
|
expect(body).to eq("from extension, yay")
|
2011-03-25 19:13:26 -04:00
|
|
|
end
|
|
|
|
end
|