Merge pull request #1619 from BuonOmo/fix-namespace-set
[sinatra-contrib][namespace] Do not raise when key is an enumerable
This commit is contained in:
commit
e79e9e6c56
|
@ -284,8 +284,8 @@ module Sinatra
|
|||
end
|
||||
|
||||
def set(key, value = self, &block)
|
||||
return key.each { |k,v| set(k, v) } if key.respond_to?(:each) and block.nil? and value == self
|
||||
raise ArgumentError, "may not set #{key}" unless ([:views] + ALLOWED_ENGINES).include?(key)
|
||||
return key.each { |k,v| set(k, v) } if block.nil? and value == self
|
||||
block ||= proc { value }
|
||||
singleton_class.send(:define_method, key, &block)
|
||||
end
|
||||
|
|
|
@ -770,6 +770,20 @@ describe Sinatra::Namespace do
|
|||
expect(last_response.body).to eq('ok')
|
||||
end
|
||||
|
||||
it 'sets hashes correctly' do
|
||||
mock_app do
|
||||
namespace '/foo' do
|
||||
set erb: 'o', sass: 'k'
|
||||
get '/bar' do
|
||||
settings.erb + settings.sass
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expect(get('/foo/bar').status).to eq(200)
|
||||
expect(last_response.body).to eq('ok')
|
||||
end
|
||||
|
||||
it 'uses some repro' do
|
||||
mock_app do
|
||||
set :foo, 42
|
||||
|
|
Loading…
Reference in New Issue