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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/mkbrut/segments/bare_bones.rb', line 31
def other_operations(project_root)
[
MKBrut::Ops::InsertRoute.new(
project_root: @project_root,
code: %{path "/trigger_exception", method: :get}
),
MKBrut::Ops::InsertCodeInMethod.new(
file: @project_root / "app" / "src" / "app.rb",
class_name: "App",
method_name: "initialize",
code: %{
Brut.container.store(
"trigger_exception_key",
String,
"String used to prevent anyone from triggering exceptions in TriggerExceptionHandler"
) do
ENV.fetch("TRIGGER_EXCEPTION_KEY")
end},
),
InsertCustomElement.new(
project_root: @project_root,
element_class_name: "Example",
),
MKBrut::Ops::InsertCodeInMethod.new(
file: @project_root / "app" / "src" / "front_end" / "pages" / "home_page.rb",
class_name: "HomePage",
method_name: "page_template",
code: %{
#{ @erb_binding.prefix }_example(
transform: "upper",
class: [ "pos-fixed",
"bottom-0",
"left-0",
"w-100",
"ff-sans",
"lh-title",
"tracked",
"f-5",
"f-6-ns",
"tc",
"pa-3",
"mt-3",
"db", ]
) do
"We Like the Web"
end
}
),
InsertEndToEndTestCode.new(
file: @project_root / "specs" / "e2e" / "home_page.spec.rb",
code: %{
example = page.locator("#{ @erb_binding.prefix }-example")
# The #{ @erb_binding.prefix }-example custom element will transform
# the text it contains. Since this is an end-to-end test
# the element should've done its thing and given us
# upper-case text.
expect(example).to have_text("WE LIKE THE WEB") }
),
MKBrut::Ops::AppendToFile.new(
file: @project_root / ".env.development",
content: %{
# Key used to allow triggering an exception. This is required to prevent
# just anyone from triggering one.
TRIGGER_EXCEPTION_KEY=dev-trigger-exception
}
),
MKBrut::Ops::AppendToFile.new(
file: @project_root / ".env.test",
content: "TRIGGER_EXCEPTION_KEY=test-trigger-exception"
),
]
end
|