2019-11-16 12:43:18 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Indenting" do
|
|
|
|
specify "nested blocks" do
|
|
|
|
assert_correct_indenting <<~EOF
|
|
|
|
var.func1(:param => 'value') do
|
|
|
|
var.func2(:param => 'value') do
|
|
|
|
puts "test"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOF
|
|
|
|
|
|
|
|
assert_correct_indenting <<~EOF
|
|
|
|
var.func1(:param => 'value') {
|
|
|
|
var.func2(:param => 'value') {
|
|
|
|
foo({ bar => baz })
|
|
|
|
puts "test one"
|
|
|
|
puts "test two"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2020-12-04 16:15:32 -05:00
|
|
|
vim.command 'let g:ruby_indent_block_style = "expression"'
|
2019-11-16 12:43:18 -05:00
|
|
|
assert_correct_indenting <<~EOF
|
|
|
|
var.
|
|
|
|
func1(:param => 'value') {
|
|
|
|
var.func2(:param => 'value') {
|
|
|
|
puts "test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
end
|
|
|
|
|
|
|
|
specify "nested hashes" do
|
|
|
|
assert_correct_indenting <<~EOF
|
|
|
|
foo, bar = {
|
|
|
|
:bar => {
|
|
|
|
:one => 'two',
|
|
|
|
:five => 'six'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2020-12-04 16:15:32 -05:00
|
|
|
vim.command 'let g:ruby_indent_block_style = "expression"'
|
2019-11-16 12:43:18 -05:00
|
|
|
assert_correct_indenting <<~EOF
|
|
|
|
foo,
|
|
|
|
bar = {
|
|
|
|
:bar => {
|
|
|
|
:foo => { 'bar' => 'baz' },
|
|
|
|
:one => 'two',
|
|
|
|
:three => 'four'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
end
|
|
|
|
|
|
|
|
specify "nested blocks with a continuation and function call inbetween" do
|
2020-12-04 16:15:32 -05:00
|
|
|
vim.command 'let g:ruby_indent_block_style = "expression"'
|
2019-11-16 12:43:18 -05:00
|
|
|
assert_correct_indenting <<~EOF
|
|
|
|
var.
|
|
|
|
func1(:param => 'value') {
|
|
|
|
func1_5(:param => 'value')
|
|
|
|
var.func2(:param => 'value') {
|
|
|
|
puts "test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
end
|
|
|
|
end
|