Fixed configurable.rb regular expression name check
This commit is contained in:
parent
cc1f0b4c2d
commit
4cb30d9f8b
@ -107,7 +107,7 @@ def config_accessor(*names)
|
|||||||
options = names.extract_options!
|
options = names.extract_options!
|
||||||
|
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
raise NameError.new('invalid config attribute name') unless name =~ /^[_A-Za-z]\w*$/
|
raise NameError.new('invalid config attribute name') unless name =~ /\A[_A-Za-z]\w*\Z/
|
||||||
|
|
||||||
reader, reader_line = "def #{name}; config.#{name}; end", __LINE__
|
reader, reader_line = "def #{name}; config.#{name}; end", __LINE__
|
||||||
writer, writer_line = "def #{name}=(value); config.#{name} = value; end", __LINE__
|
writer, writer_line = "def #{name}=(value); config.#{name} = value; end", __LINE__
|
||||||
|
@ -95,6 +95,12 @@ class Child < Parent
|
|||||||
config_accessor "invalid attribute name"
|
config_accessor "invalid attribute name"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
assert_raises NameError do
|
||||||
|
Class.new do
|
||||||
|
include ActiveSupport::Configurable
|
||||||
|
config_accessor "invalid attribute\nname"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_method_defined(object, method)
|
def assert_method_defined(object, method)
|
||||||
|
Loading…
Reference in New Issue
Block a user