mint 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -26
  3. data/README.md +138 -95
  4. data/bin/mint +2 -81
  5. data/config/templates/base/navigation.css +136 -0
  6. data/config/templates/base/print.css +152 -0
  7. data/config/templates/{reset.css → base/reset.css} +1 -1
  8. data/config/templates/base/style.css +117 -137
  9. data/config/templates/base/utilities.css +136 -0
  10. data/config/templates/base/variables.css +124 -0
  11. data/config/templates/basic/style.css +151 -0
  12. data/config/templates/default/layout.erb +33 -3
  13. data/config/templates/default/style.css +95 -164
  14. data/config/templates/magazine/style.css +383 -0
  15. data/config/templates/nord/style.css +105 -220
  16. data/config/templates/nord-dark/style.css +82 -263
  17. data/lib/mint/commandline/parse.rb +144 -0
  18. data/lib/mint/commandline/publish.rb +46 -0
  19. data/lib/mint/commandline/run.rb +30 -0
  20. data/lib/mint/config.rb +162 -0
  21. data/lib/mint/{css.rb → css_dsl.rb} +9 -9
  22. data/lib/mint/css_parser.rb +96 -0
  23. data/lib/mint/document.rb +251 -348
  24. data/lib/mint/document_tree.rb +163 -0
  25. data/lib/mint/exceptions.rb +2 -3
  26. data/lib/mint/helpers.rb +23 -180
  27. data/lib/mint/layout.rb +26 -9
  28. data/lib/mint/renderers/css_renderer.rb +32 -0
  29. data/lib/mint/renderers/erb_renderer.rb +11 -0
  30. data/lib/mint/renderers/markdown_renderer.rb +45 -0
  31. data/lib/mint/style.rb +21 -31
  32. data/lib/mint/template.rb +30 -0
  33. data/lib/mint/version.rb +1 -1
  34. data/lib/mint/workspace.rb +171 -0
  35. data/lib/mint.rb +44 -12
  36. data/man/mint.1 +88 -47
  37. data/spec/cli/README.md +13 -13
  38. data/spec/cli/argument_parsing_spec.rb +103 -131
  39. data/spec/cli/bin_integration_spec.rb +23 -243
  40. data/spec/cli/full_workflow_integration_spec.rb +99 -442
  41. data/spec/cli/original_style_integration_spec.rb +58 -0
  42. data/spec/cli/publish_workflow_spec.rb +72 -70
  43. data/spec/commandline_path_integration_spec.rb +230 -0
  44. data/spec/config_file_integration_spec.rb +362 -0
  45. data/spec/{css_spec.rb → css_dsl_spec.rb} +7 -3
  46. data/spec/css_parser_spec.rb +207 -0
  47. data/spec/document_spec.rb +37 -242
  48. data/spec/flattened_path_spec.rb +150 -0
  49. data/spec/layout_spec.rb +42 -3
  50. data/spec/mint_spec.rb +22 -217
  51. data/spec/path_handling_spec.rb +237 -0
  52. data/spec/run_cli_tests.rb +1 -1
  53. data/spec/spec_helper.rb +3 -10
  54. data/spec/style_spec.rb +31 -56
  55. data/spec/support/cli_helpers.rb +7 -10
  56. data/spec/support/matchers.rb +1 -1
  57. data/spec/template_spec.rb +31 -0
  58. data/spec/workspace_spec.rb +177 -0
  59. metadata +78 -93
  60. data/bin/mint-epub +0 -20
  61. data/config/templates/default/css/style.css +0 -205
  62. data/config/templates/garden/layout.erb +0 -38
  63. data/config/templates/garden/style.css +0 -303
  64. data/config/templates/newspaper/layout.erb +0 -16
  65. data/config/templates/nord/layout.erb +0 -11
  66. data/config/templates/nord-dark/layout.erb +0 -11
  67. data/config/templates/protocol/layout.erb +0 -9
  68. data/config/templates/protocol/style.css +0 -25
  69. data/config/templates/zen/layout.erb +0 -11
  70. data/config/templates/zen/style.css +0 -114
  71. data/lib/mint/command_line.rb +0 -360
  72. data/lib/mint/css_template.rb +0 -37
  73. data/lib/mint/markdown_template.rb +0 -47
  74. data/lib/mint/mint.rb +0 -313
  75. data/lib/mint/plugin.rb +0 -136
  76. data/lib/mint/plugins/epub.rb +0 -293
  77. data/lib/mint/resource.rb +0 -101
  78. data/plugins/templates/epub/layouts/container.haml +0 -5
  79. data/plugins/templates/epub/layouts/content.haml +0 -35
  80. data/plugins/templates/epub/layouts/layout.haml +0 -6
  81. data/plugins/templates/epub/layouts/title.haml +0 -11
  82. data/plugins/templates/epub/layouts/toc.haml +0 -26
  83. data/spec/cli/configuration_management_spec.rb +0 -363
  84. data/spec/cli/template_management_spec.rb +0 -300
  85. data/spec/helpers_spec.rb +0 -249
  86. data/spec/plugin_spec.rb +0 -449
  87. data/spec/resource_spec.rb +0 -135
@@ -1,363 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe "CLI Configuration Management" do
4
- describe "configuration operations" do
5
- context "in isolated environment" do
6
- around(:each) do |example|
7
- in_temp_dir do |dir|
8
- @test_dir = dir
9
- example.run
10
- end
11
- end
12
-
13
- describe "Mint::CommandLine.set" do
14
- it "sets configuration values at local scope" do
15
- expect {
16
- Mint::CommandLine.set("layout", "custom", :local)
17
- }.not_to raise_error
18
-
19
- expect(File.exist?(".mint/config.yaml")).to be true
20
- config = YAML.load_file(".mint/config.yaml")
21
- expect(config["layout"]).to eq("custom")
22
- end
23
-
24
- it "sets configuration values at different scopes" do
25
- # Test local scope (should work)
26
- Mint::CommandLine.set("layout", "local-template", :local)
27
- expect(File.exist?(".mint/config.yaml")).to be true
28
-
29
- local_config = YAML.load_file(".mint/config.yaml")
30
- expect(local_config["layout"]).to eq("local-template")
31
-
32
- # For user/global scopes, we'd test the path construction
33
- # but can't actually write to those locations in tests
34
- end
35
-
36
- it "creates config directory if it doesn't exist" do
37
- expect(File.exist?(".mint")).to be false
38
-
39
- Mint::CommandLine.set("style", "minimal", :local)
40
-
41
- expect(File.exist?(".mint")).to be true
42
- expect(File.directory?(".mint")).to be true
43
- expect(File.exist?(".mint/config.yaml")).to be true
44
- end
45
-
46
- it "updates existing configuration values" do
47
- # Set initial value
48
- Mint::CommandLine.set("layout", "initial", :local)
49
- initial_config = YAML.load_file(".mint/config.yaml")
50
- expect(initial_config["layout"]).to eq("initial")
51
-
52
- # Update value
53
- Mint::CommandLine.set("layout", "updated", :local)
54
- updated_config = YAML.load_file(".mint/config.yaml")
55
- expect(updated_config["layout"]).to eq("updated")
56
- end
57
-
58
- it "preserves other configuration values" do
59
- # Set multiple values
60
- Mint::CommandLine.set("layout", "my-layout", :local)
61
- Mint::CommandLine.set("style", "my-style", :local)
62
- Mint::CommandLine.set("destination", "output", :local)
63
-
64
- config = YAML.load_file(".mint/config.yaml")
65
- expect(config["layout"]).to eq("my-layout")
66
- expect(config["style"]).to eq("my-style")
67
- expect(config["destination"]).to eq("output")
68
-
69
- # Update one value
70
- Mint::CommandLine.set("layout", "new-layout", :local)
71
-
72
- updated_config = YAML.load_file(".mint/config.yaml")
73
- expect(updated_config["layout"]).to eq("new-layout")
74
- expect(updated_config["style"]).to eq("my-style") # preserved
75
- expect(updated_config["destination"]).to eq("output") # preserved
76
- end
77
-
78
- it "handles various data types" do
79
- Mint::CommandLine.set("string_value", "text", :local)
80
- Mint::CommandLine.set("boolean_value", true, :local)
81
- Mint::CommandLine.set("number_value", 42, :local)
82
- Mint::CommandLine.set("nil_value", nil, :local)
83
-
84
- config = YAML.load_file(".mint/config.yaml")
85
- expect(config["string_value"]).to eq("text")
86
- expect(config["boolean_value"]).to be true
87
- expect(config["number_value"]).to eq(42)
88
- expect(config["nil_value"]).to be_nil
89
- end
90
-
91
- it "defaults to local scope" do
92
- Mint::CommandLine.set("test_key", "test_value") # no scope specified
93
-
94
- expect(File.exist?(".mint/config.yaml")).to be true
95
- config = YAML.load_file(".mint/config.yaml")
96
- expect(config["test_key"]).to eq("test_value")
97
- end
98
- end
99
-
100
- describe "Mint::CommandLine.configure" do
101
- it "sets multiple configuration options at once" do
102
- options = {
103
- "layout" => "custom",
104
- "style" => "minimal",
105
- "destination" => "build",
106
- "verbose" => true
107
- }
108
-
109
- expect {
110
- Mint::CommandLine.configure(options, :local)
111
- }.not_to raise_error
112
-
113
- config = YAML.load_file(".mint/config.yaml")
114
- expect(config["layout"]).to eq("custom")
115
- expect(config["style"]).to eq("minimal")
116
- expect(config["destination"]).to eq("build")
117
- expect(config["verbose"]).to be true
118
- end
119
-
120
- it "merges with existing configuration" do
121
- # Set initial config
122
- initial_options = {
123
- "layout" => "default",
124
- "style" => "default",
125
- "author" => "Test Author"
126
- }
127
- Mint::CommandLine.configure(initial_options, :local)
128
-
129
- # Add more options
130
- additional_options = {
131
- "layout" => "updated", # should override
132
- "destination" => "output", # should add
133
- "verbose" => true # should add
134
- }
135
- Mint::CommandLine.configure(additional_options, :local)
136
-
137
- config = YAML.load_file(".mint/config.yaml")
138
- expect(config["layout"]).to eq("updated") # overridden
139
- expect(config["style"]).to eq("default") # preserved
140
- expect(config["author"]).to eq("Test Author") # preserved
141
- expect(config["destination"]).to eq("output") # added
142
- expect(config["verbose"]).to be true # added
143
- end
144
-
145
- it "handles empty options" do
146
- expect {
147
- Mint::CommandLine.configure({}, :local)
148
- }.not_to raise_error
149
-
150
- # Should create an empty config file
151
- expect(File.exist?(".mint/config.yaml")).to be true
152
- end
153
-
154
- it "handles symbol keys" do
155
- options = {
156
- layout: "symbol-layout",
157
- style: "symbol-style"
158
- }
159
-
160
- Mint::CommandLine.configure(options, :local)
161
-
162
- config = YAML.load_file(".mint/config.yaml")
163
- # Symbol keys remain as symbols in YAML
164
- expect(config[:layout]).to eq("symbol-layout")
165
- expect(config[:style]).to eq("symbol-style")
166
- end
167
- end
168
-
169
- describe "Mint::CommandLine.config" do
170
- it "displays current configuration" do
171
- # Set up some configuration
172
- Mint::CommandLine.set("layout", "test-layout", :local)
173
- Mint::CommandLine.set("style", "test-style", :local)
174
-
175
- stdout, stderr = capture_output do
176
- Mint::CommandLine.config
177
- end
178
-
179
- expect(stdout).to include("layout")
180
- expect(stdout).to include("test-layout")
181
- expect(stdout).to include("style")
182
- expect(stdout).to include("test-style")
183
- end
184
-
185
- it "shows empty configuration when none exists" do
186
- stdout, stderr = capture_output do
187
- Mint::CommandLine.config
188
- end
189
-
190
- # Should show default configuration or empty YAML
191
- expect(stdout).to include("---") # YAML document start
192
- end
193
-
194
- it "merges configuration from multiple scopes" do
195
- # This is more complex to test since we can't easily create
196
- # user/global configs, but we can test the concept
197
- setup_basic_config(:local)
198
-
199
- stdout, stderr = capture_output do
200
- Mint::CommandLine.config
201
- end
202
-
203
- expect(stdout).to include("layout")
204
- expect(stdout).to include("default")
205
- end
206
- end
207
-
208
- describe "configuration precedence and merging" do
209
- describe "Mint.configuration" do
210
- it "provides default configuration when no files exist" do
211
- config = Mint.configuration
212
-
213
- expect(config).to be_a(Hash)
214
- expect(config[:layout_or_style_or_template]).to eq([:template, "default"])
215
- end
216
-
217
- it "merges local configuration with defaults" do
218
- Mint::CommandLine.set("layout", "custom", :local)
219
- Mint::CommandLine.set("author", "Test Author", :local)
220
-
221
- config = Mint.configuration
222
-
223
- expect(config[:layout]).to eq("custom") # from local config
224
- expect(config[:layout_or_style_or_template]).to eq([:template, "default"]) # from defaults
225
- expect(config[:author]).to eq("Test Author") # from local config
226
- end
227
- end
228
-
229
- describe "Mint.configuration_with" do
230
- it "merges additional options with configuration" do
231
- Mint::CommandLine.set("layout", "from-config", :local)
232
-
233
- config = Mint.configuration_with({
234
- style: "from-options",
235
- destination: "custom-dest"
236
- })
237
-
238
- expect(config[:layout]).to eq("from-config") # from config file
239
- expect(config[:style]).to eq("from-options") # from options
240
- expect(config[:destination]).to eq("custom-dest") # from options
241
- end
242
-
243
- it "allows options to override configuration" do
244
- Mint::CommandLine.set("layout", "config-layout", :local)
245
- Mint::CommandLine.set("style", "config-style", :local)
246
-
247
- config = Mint.configuration_with({
248
- layout: "override-layout" # should override config
249
- })
250
-
251
- expect(config[:layout]).to eq("override-layout") # overridden
252
- expect(config[:style]).to eq("config-style") # preserved
253
- end
254
-
255
- it "handles scope-specific configuration" do
256
- # Test that scope flags affect which configs are loaded
257
- # This is more complex but important for the new scope system
258
- setup_basic_config(:local)
259
-
260
- # Test with different scope selections
261
- config_local = Mint.configuration_with({ scope: :local })
262
- config_with_defaults = Mint.configuration_with({})
263
-
264
- expect(config_local).to include(:layout)
265
- expect(config_with_defaults).to include(:layout)
266
- end
267
- end
268
- end
269
-
270
- describe "configuration file handling" do
271
- it "creates valid YAML files" do
272
- Mint::CommandLine.set("test", "value", :local)
273
-
274
- expect(File.exist?(".mint/config.yaml")).to be true
275
-
276
- # Should be parseable YAML
277
- expect {
278
- YAML.load_file(".mint/config.yaml")
279
- }.not_to raise_error
280
- end
281
-
282
- it "handles special characters in values" do
283
- special_values = {
284
- "quotes" => 'Value with "quotes"',
285
- "newlines" => "Line 1\nLine 2",
286
- "unicode" => "Unicode: 中文 🚀",
287
- "symbols" => "Symbols: @#$%^&*()"
288
- }
289
-
290
- special_values.each do |key, value|
291
- Mint::CommandLine.set(key, value, :local)
292
- end
293
-
294
- config = YAML.load_file(".mint/config.yaml")
295
- special_values.each do |key, expected_value|
296
- expect(config[key]).to eq(expected_value)
297
- end
298
- end
299
-
300
- it "handles concurrent access gracefully" do
301
- # This is difficult to test properly, but we can at least
302
- # verify that multiple rapid operations don't corrupt the file
303
- 10.times do |i|
304
- Mint::CommandLine.set("key#{i}", "value#{i}", :local)
305
- end
306
-
307
- config = YAML.load_file(".mint/config.yaml")
308
- 10.times do |i|
309
- expect(config["key#{i}"]).to eq("value#{i}")
310
- end
311
- end
312
-
313
- it "preserves file permissions" do
314
- Mint::CommandLine.set("test", "value", :local)
315
-
316
- file_stat = File.stat(".mint/config.yaml")
317
- original_mode = file_stat.mode
318
-
319
- Mint::CommandLine.set("test2", "value2", :local)
320
-
321
- new_file_stat = File.stat(".mint/config.yaml")
322
- expect(new_file_stat.mode).to eq(original_mode)
323
- end
324
- end
325
-
326
- describe "error handling" do
327
- it "handles invalid YAML gracefully" do
328
- # Create an invalid YAML file
329
- FileUtils.mkdir_p(".mint")
330
- File.write(".mint/config.yaml", "invalid: yaml: content: [unclosed")
331
-
332
- expect {
333
- Mint.configuration
334
- }.not_to raise_error # Should handle gracefully
335
- end
336
-
337
- it "handles permission errors" do
338
- # Create config directory but make it read-only
339
- FileUtils.mkdir_p(".mint")
340
- File.chmod(0444, ".mint")
341
-
342
- begin
343
- expect {
344
- Mint::CommandLine.set("test", "value", :local)
345
- }.to raise_error(Errno::EACCES) # Should fail due to permissions
346
- ensure
347
- # Restore permissions for cleanup
348
- File.chmod(0755, ".mint")
349
- end
350
- end
351
-
352
- it "handles missing parent directories" do
353
- # This should work - the set method should create directories
354
- expect {
355
- Mint::CommandLine.set("test", "value", :local)
356
- }.not_to raise_error
357
-
358
- expect(File.exist?(".mint/config.yaml")).to be true
359
- end
360
- end
361
- end
362
- end
363
- end
@@ -1,300 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe "CLI Template Management" do
4
- describe "template operations" do
5
- context "in isolated environment" do
6
- around(:each) do |example|
7
- in_temp_dir do |dir|
8
- @test_dir = dir
9
- example.run
10
- end
11
- end
12
-
13
- describe "Mint::CommandLine.templates" do
14
- it "lists templates from specified scope" do
15
- create_template_directory("custom")
16
- create_template_directory("minimal")
17
-
18
- stdout, stderr = capture_output do
19
- Mint::CommandLine.templates("", :local)
20
- end
21
-
22
- expect(stdout).to include("custom")
23
- expect(stdout).to include("minimal")
24
- end
25
-
26
- it "filters templates by pattern" do
27
- create_template_directory("custom-dark")
28
- create_template_directory("custom-light")
29
- create_template_directory("minimal")
30
-
31
- stdout, stderr = capture_output do
32
- Mint::CommandLine.templates("custom", :local)
33
- end
34
-
35
- expect(stdout).to include("custom-dark")
36
- expect(stdout).to include("custom-light")
37
- expect(stdout).not_to include("minimal")
38
- end
39
-
40
- it "shows template paths in output" do
41
- create_template_directory("test-template")
42
-
43
- stdout, stderr = capture_output do
44
- Mint::CommandLine.templates("", :local)
45
- end
46
-
47
- expect(stdout).to include("test-template")
48
- expect(stdout).to include(".mint/templates/test-template")
49
- end
50
-
51
- it "handles empty template directory" do
52
- stdout, stderr = capture_output do
53
- Mint::CommandLine.templates("", :local)
54
- end
55
-
56
- expect(stdout.strip).to eq("")
57
- end
58
- end
59
-
60
- describe "Mint::CommandLine.install" do
61
- it "installs a layout template file" do
62
- layout_content = "<html><body><%= yield %></body></html>"
63
- create_template_file("custom.erb", :layout, layout_content)
64
-
65
- expect {
66
- Mint::CommandLine.install("custom.erb", "mytemplate", :local)
67
- }.not_to raise_error
68
-
69
- installed_file = ".mint/templates/mytemplate/layout.erb"
70
- expect(File.exist?(installed_file)).to be true
71
- expect(File.read(installed_file)).to eq(layout_content)
72
- end
73
-
74
- it "installs a style template file" do
75
- style_content = "body { background: #f0f0f0; }"
76
- create_template_file("custom.css", :style, style_content)
77
-
78
- expect {
79
- Mint::CommandLine.install("custom.css", "mystyle", :local)
80
- }.not_to raise_error
81
-
82
- installed_file = ".mint/templates/mystyle/style.css"
83
- expect(File.exist?(installed_file)).to be true
84
- expect(File.read(installed_file)).to eq(style_content)
85
- end
86
-
87
- it "creates template directory if it doesn't exist" do
88
- create_template_file("layout.erb", :layout)
89
-
90
- expect(File.exist?(".mint/templates/newtemplate")).to be false
91
-
92
- Mint::CommandLine.install("layout.erb", "newtemplate", :local)
93
-
94
- expect(File.exist?(".mint/templates/newtemplate")).to be true
95
- expect(File.exist?(".mint/templates/newtemplate/layout.erb")).to be true
96
- end
97
-
98
- it "determines template type by file extension" do
99
- # Create different file types
100
- File.write("layout.haml", "%html\n %body= yield")
101
- File.write("style.scss", "$primary: #333;\nbody { color: $primary; }")
102
-
103
- Mint::CommandLine.install("layout.haml", "haml-template", :local)
104
- Mint::CommandLine.install("style.scss", "scss-template", :local)
105
-
106
- expect(File.exist?(".mint/templates/haml-template/layout.haml")).to be true
107
- expect(File.exist?(".mint/templates/scss-template/style.scss")).to be true
108
- end
109
-
110
- it "raises error for non-existent source file" do
111
- expect {
112
- Mint::CommandLine.install("nonexistent.erb", "test", :local)
113
- }.to raise_error(RuntimeError, /No such file/)
114
- end
115
-
116
- end
117
-
118
- describe "Mint::CommandLine.uninstall" do
119
- it "removes an entire template directory" do
120
- create_template_directory("removeme", with_layout: true, with_style: true)
121
-
122
- expect(File.exist?(".mint/templates/removeme")).to be true
123
-
124
- Mint::CommandLine.uninstall("removeme", :local)
125
-
126
- expect(File.exist?(".mint/templates/removeme")).to be false
127
- end
128
-
129
- it "handles non-existent templates gracefully" do
130
- expect {
131
- Mint::CommandLine.uninstall("nonexistent", :local)
132
- }.to raise_error(Errno::ENOENT)
133
- end
134
- end
135
-
136
- describe "Mint::CommandLine.edit" do
137
- it "opens layout template in editor" do
138
- create_template_directory("editable", with_layout: true)
139
- template_file = ".mint/templates/editable/layout.erb"
140
-
141
- silence_output do
142
- mock_editor do
143
- expect {
144
- Mint::CommandLine.edit("editable", :layout, :local)
145
- }.not_to raise_error
146
- end
147
- end
148
- end
149
-
150
- it "opens style template in editor" do
151
- create_template_directory("editable", with_style: true)
152
-
153
- silence_output do
154
- mock_editor do
155
- expect {
156
- Mint::CommandLine.edit("editable", :style, :local)
157
- }.not_to raise_error
158
- end
159
- end
160
- end
161
-
162
- it "prompts to create template if it doesn't exist" do
163
- # Mock STDIN to simulate user input
164
- allow(STDIN).to receive(:gets).and_return("y\n")
165
-
166
- silence_output do
167
- mock_editor do
168
- expect {
169
- Mint::CommandLine.edit("newtemplate", :layout, :local)
170
- }.not_to raise_error
171
- end
172
- end
173
-
174
- expect(File.exist?(".mint/templates/newtemplate/layout.erb")).to be true
175
- end
176
-
177
- it "cancels creation when user says no" do
178
- allow(STDIN).to receive(:gets).and_return("n\n")
179
-
180
- silence_output do
181
- expect {
182
- Mint::CommandLine.edit("newtemplate", :layout, :local)
183
- }.to raise_error(SystemExit)
184
- end
185
- end
186
-
187
- it "rejects invalid template types" do
188
- silence_output do
189
- expect {
190
- Mint::CommandLine.edit("template", :invalid, :local)
191
- }.to raise_error(SystemExit, /Invalid template type/)
192
- end
193
- end
194
-
195
- it "requires template name" do
196
- silence_output do
197
- expect {
198
- Mint::CommandLine.edit("", :layout, :local)
199
- }.to raise_error(SystemExit, /No template specified/)
200
-
201
- expect {
202
- Mint::CommandLine.edit(nil, :layout, :local)
203
- }.to raise_error(SystemExit, /No template specified/)
204
- end
205
- end
206
- end
207
-
208
- describe "template creation helpers" do
209
- describe "Mint::CommandLine.create_template" do
210
- it "creates a layout template with default content" do
211
- template_file = Mint::CommandLine.create_template("newlayout", :layout, :local)
212
-
213
- expect(File.exist?(template_file)).to be true
214
- content = File.read(template_file)
215
- expect(content).to include("<!DOCTYPE html>")
216
- expect(content).to include("<%= content %>")
217
- expect(template_file).to end_with("/layout.erb")
218
- end
219
-
220
- it "creates a style template with default content" do
221
- template_file = Mint::CommandLine.create_template("newstyle", :style, :local)
222
-
223
- expect(File.exist?(template_file)).to be true
224
- content = File.read(template_file)
225
- expect(content).to include("body {")
226
- expect(content).to include("font-family:")
227
- expect(template_file).to end_with("/style.css")
228
- end
229
-
230
- it "creates template directory structure" do
231
- Mint::CommandLine.create_template("organized", :layout, :local)
232
-
233
- expect(File.exist?(".mint/templates/organized")).to be true
234
- expect(File.directory?(".mint/templates/organized")).to be true
235
- end
236
-
237
- it "rejects invalid template types" do
238
- silence_output do
239
- expect {
240
- Mint::CommandLine.create_template("test", :invalid, :local)
241
- }.to raise_error(SystemExit, /Invalid template type/)
242
- end
243
- end
244
- end
245
-
246
- describe "default template content" do
247
- it "provides valid HTML5 layout template" do
248
- content = Mint::CommandLine.default_layout_content
249
-
250
- expect(content).to include("<!DOCTYPE html>")
251
- expect(content).to include("<html>")
252
- expect(content).to include("<title>Document</title>")
253
- expect(content).to include("<%= content %>")
254
- expect(content).to include("<%= style %>")
255
- end
256
-
257
- it "provides basic CSS style template" do
258
- content = Mint::CommandLine.default_style_content
259
-
260
- expect(content).to include("body {")
261
- expect(content).to include("font-family:")
262
- expect(content).to include("max-width:")
263
- expect(content).to include("code {")
264
- end
265
- end
266
- end
267
-
268
- describe "template lookup integration" do
269
- it "finds installed templates via lookup methods" do
270
- create_template_directory("findme", with_layout: true, with_style: true)
271
-
272
- layout_file = Mint.lookup_layout("findme")
273
- style_file = Mint.lookup_style("findme")
274
- template_dir = Mint.lookup_template("findme")
275
-
276
- expect(layout_file).to include("findme/layout.erb")
277
- expect(style_file).to include("findme/style.css")
278
- expect(template_dir.to_s).to include("findme")
279
- expect(File.exist?(layout_file)).to be true
280
- expect(File.exist?(style_file)).to be true
281
- expect(File.directory?(template_dir)).to be true
282
- end
283
-
284
- it "raises TemplateNotFoundException for missing templates" do
285
- expect {
286
- Mint.lookup_layout("missing")
287
- }.to raise_error(Mint::TemplateNotFoundException)
288
-
289
- expect {
290
- Mint.lookup_style("missing")
291
- }.to raise_error(Mint::TemplateNotFoundException)
292
-
293
- expect {
294
- Mint.lookup_template("missing")
295
- }.to raise_error(Mint::TemplateNotFoundException)
296
- end
297
- end
298
- end
299
- end
300
- end