提交 ce38a6b8 编写于 作者: R robertomiranda

Fix Shadowing extensions variable in Register Annotation Exentsions

上级 f43421cb
......@@ -24,8 +24,8 @@ def self.extensions
# Registers new Annotations File Extensions
# SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
def self.register_extensions(*extensions, &block)
self.extensions[/\.(#{extensions.join("|")})$/] = block
def self.register_extensions(*exts, &block)
extensions[/\.(#{exts.join("|")})$/] = block
end
register_extensions("builder", "rb", "rake", "yml", "yaml", "ruby") { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
......
......@@ -25,7 +25,7 @@ def teardown
app_file "lib/tasks/task.rake", "# TODO: note in rake"
app_file 'app/views/home/index.html.builder', '# TODO: note in builder'
app_file 'config/locales/en.yml', '# TODO: note in yml'
app_file 'config/locales/en.yaml', '# TODO: note in yml'
app_file 'config/locales/en.yaml', '# TODO: note in yaml'
app_file "app/views/home/index.ruby", "# TODO: note in ruby"
boot_rails
......@@ -40,13 +40,13 @@ def teardown
lines = output.scan(/\[([0-9\s]+)\](\s)/)
assert_match(/note in erb/, output)
assert_match(/note in ruby/, output)
assert_match(/note in js/, output)
assert_match(/note in css/, output)
assert_match(/note in rake/, output)
assert_match(/note in builder/, output)
assert_match(/note in yml/, output)
assert_match(/note in yaml/, output)
assert_match(/note in ruby/, output)
assert_equal 9, lines.size
......@@ -170,9 +170,9 @@ def teardown
end
test 'register a new extension' do
SourceAnnotationExtractor::Annotation.register_extensions(".test1", ".test2") { |tag| /#{tag}/ }
assert SourceAnnotationExtractor::Annotation.extensions[/(\.test1|\.test2)/]
assert_blank SourceAnnotationExtractor::Annotation.extensions[/(\.haml)/]
SourceAnnotationExtractor::Annotation.register_extensions("test1", "test2"){ |tag| /#{tag}/ }
assert_not_nil SourceAnnotationExtractor::Annotation.extensions[/\.(test1|test2)$/]
assert_nil SourceAnnotationExtractor::Annotation.extensions[/\.(haml)$/]
end
private
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册