/
pipeline_spec.rb
67 lines (58 loc) · 1.36 KB
/
pipeline_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# frozen_string_literal: true
require 'spec_helper'
describe 'Indenting' do
it 'using multiline pipeline' do
expect(<<~EOF).to be_elixir_indentation
"a,b,c,d"
|> String.split(",")
|> Enum.reverse
EOF
end
it 'attribuition using multline pipeline operator' do
expect(<<~EOF).to be_elixir_indentation
[ h | t ] = "a,b,c,d"
|> String.split(",")
|> Enum.reverse
EOF
end
it 'function with pipeline operator' do
expect(<<~EOF).to be_elixir_indentation
def test do
[ h | t ] = "a,b,c,d"
|> String.split(",")
|> Enum.reverse
{ :ok, h }
end
EOF
end
it 'do not breaks on `==`' do
expect(<<~EOF).to be_elixir_indentation
def test do
my_post = Post
|> where([p], p.id == 10)
|> where([p], u.user_id == 1)
|> select([p], p)
end
EOF
end
it 'pipeline operator with block open' do
expect(<<~EOF).to be_elixir_indentation
def test do
"a,b,c,d"
|> String.split(",")
|> Enum.first
|> case do
"a" -> "A"
_ -> "Z"
end
end
EOF
end
it 'using a record with pipeline' do
expect(<<~EOF).to be_elixir_indentation
defrecord RECORD, field_a: nil, field_b: nil
rec = RECORD.new
|> IO.inspect
EOF
end
end