|
3 | 3 | require 'spec_helper' |
4 | 4 |
|
5 | 5 | describe 'Indenting blocks' do |
6 | | - it "'do' indenting" do |
7 | | - expect(<<~EOF).to be_elixir_indentation |
8 | | - do |
9 | | - something |
10 | | - end |
11 | | - EOF |
| 6 | + i <<~EOF |
| 7 | + do |
| 8 | + something |
12 | 9 | end |
| 10 | + EOF |
13 | 11 |
|
14 | | - it 'does not consider :end as end' do |
15 | | - expect(<<~EOF).to be_elixir_indentation |
16 | | - defmodule Test do |
17 | | - def lol do |
18 | | - IO.inspect :end |
19 | | - end |
| 12 | + i <<~EOF |
| 13 | + defmodule Test do |
| 14 | + def lol do |
| 15 | + IO.inspect :end |
20 | 16 | end |
21 | | - EOF |
22 | 17 | end |
| 18 | + EOF |
23 | 19 |
|
24 | | - it 'indent inline functions' do |
25 | | - expect(<<~EOF).to be_elixir_indentation |
26 | | - defmodule Hello do |
27 | | - def name, do: IO.puts "bobmarley" |
28 | | - # expect next line starting here |
| 20 | + i <<~EOF |
| 21 | + defmodule Hello do |
| 22 | + def name, do: IO.puts "bobmarley" |
| 23 | + # expect next line starting here |
29 | 24 |
|
30 | | - def name(param) do |
31 | | - param |
32 | | - end |
| 25 | + def name(param) do |
| 26 | + param |
33 | 27 | end |
34 | | - EOF |
35 | 28 | end |
| 29 | + EOF |
36 | 30 |
|
37 | | - it 'type inline functions' do |
38 | | - expect(<<~EOF).to be_typed_with_right_indent |
39 | | - defmodule Hello do |
40 | | - def name, do: IO.puts "bobmarley" |
| 31 | + i <<~EOF |
| 32 | + defmodule Hello do |
| 33 | + def name, do: IO.puts "bobmarley" |
41 | 34 |
|
42 | | - def name(param) do |
43 | | - param |
44 | | - end |
| 35 | + def name(param) do |
| 36 | + param |
45 | 37 | end |
46 | | - EOF |
47 | 38 | end |
| 39 | + EOF |
48 | 40 |
|
49 | | - it 'does not consider do: as the start of a block' do |
50 | | - expect(<<~EOF).to be_elixir_indentation |
51 | | - def f do |
52 | | - if true, do: 42 |
53 | | - end |
54 | | - EOF |
| 41 | + i <<~EOF |
| 42 | + def f do |
| 43 | + if true, do: 42 |
55 | 44 | end |
| 45 | + EOF |
56 | 46 |
|
57 | | - it "do not mislead atom ':do'" do |
58 | | - expect(<<~EOF).to be_elixir_indentation |
59 | | - def f do |
60 | | - x = :do |
61 | | - end |
62 | | - EOF |
| 47 | + i <<~EOF |
| 48 | + def f do |
| 49 | + x = :do |
63 | 50 | end |
| 51 | + EOF |
64 | 52 |
|
65 | | - it 'multiline assignment' do |
66 | | - expect(<<~EOF).to be_elixir_indentation |
67 | | - defmodule Test do |
68 | | - def test do |
69 | | - one = |
70 | | - user |
71 | | - |> build_assoc(:videos) |
72 | | - |> Video.changeset() |
73 | | -
|
74 | | - other = |
75 | | - user2 |
76 | | - |> build_assoc(:videos) |
77 | | - |> Video.changeset() |
78 | | - end |
| 53 | + i <<~EOF |
| 54 | + defmodule Test do |
| 55 | + def test do |
| 56 | + one = |
| 57 | + user |
| 58 | + |> build_assoc(:videos) |
| 59 | + |> Video.changeset() |
| 60 | +
|
| 61 | + other = |
| 62 | + user2 |
| 63 | + |> build_assoc(:videos) |
| 64 | + |> Video.changeset() |
79 | 65 | end |
80 | | - EOF |
81 | 66 | end |
| 67 | + EOF |
82 | 68 |
|
83 | | - it 'does not indent based on opening symbols inside strings' do |
84 | | - expect(<<~EOF).to be_elixir_indentation |
85 | | - defmodule MyMod do |
86 | | - def how_are_you do |
87 | | - IO.puts "I'm filling bad :(" |
88 | | - IO.puts "really bad" |
89 | | - end |
| 69 | + i <<~EOF |
| 70 | + defmodule MyMod do |
| 71 | + def how_are_you do |
| 72 | + IO.puts "I'm filling bad :(" |
| 73 | + IO.puts "really bad" |
90 | 74 | end |
91 | | - EOF |
92 | 75 | end |
| 76 | + EOF |
93 | 77 |
|
94 | | - describe 'indenting while typing' do |
95 | | - it 'close block' do |
96 | | - expect(<<~EOF).to be_typed_with_right_indent |
97 | | - defmodule MyMod do |
98 | | - def how_are_you do |
99 | | - "function return" |
100 | | - end |
101 | | - end |
102 | | - EOF |
| 78 | + i <<~EOF |
| 79 | + defmodule MyMod do |
| 80 | + def how_are_you do |
| 81 | + "function return" |
103 | 82 | end |
104 | 83 | end |
| 84 | + EOF |
105 | 85 |
|
106 | | - it 'indenting with a blank line in it' do |
107 | | - expect(<<~EOF).to be_elixir_indentation |
108 | | - scope "/", API do |
109 | | - pipe_through :api # Use the default browser stack |
| 86 | + i <<~EOF |
| 87 | + scope "/", API do |
| 88 | + pipe_through :api # Use the default browser stack |
110 | 89 |
|
111 | | - get "/url", Controller, :index |
112 | | - post "/url", Controller, :create |
113 | | - end |
114 | | - EOF |
| 90 | + get "/url", Controller, :index |
| 91 | + post "/url", Controller, :create |
115 | 92 | end |
| 93 | + EOF |
116 | 94 |
|
117 | 95 | i <<~EOF |
118 | 96 | def hello do |
|
0 commit comments